Skip to content

Commit 615f592

Browse files
committed
remove todos, set ansi enabled
1 parent 4a356e5 commit 615f592

File tree

2 files changed

+65
-51
lines changed

2 files changed

+65
-51
lines changed

sql/core/src/test/resources/sql-tests/inputs/pgSQL/with.sql

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,8 @@ INSERT INTO department VALUES (7, 5, 'G');
244244
-- SELECT * FROM subdepartment;
245245
--
246246
--SELECT * FROM vsubdepartment ORDER BY name;
247-
248-
-- Check reverse listing
249-
-- [TODO] is there a way to show DDL of a view?
247+
--
248+
---- Check reverse listing
250249
--SELECT pg_get_viewdef('vsubdepartment'::regclass);
251250
--SELECT pg_get_viewdef('vsubdepartment'::regclass, true);
252251

@@ -259,8 +258,7 @@ INSERT INTO department VALUES (7, 5, 'G');
259258
-- SELECT n+1 FROM t WHERE n < 100
260259
--)
261260
--SELECT sum(n) FROM t;
262-
263-
-- [TODO] is there a way to show DDL of a view?
261+
--
264262
--\d+ sums_1_100
265263

266264
-- corner case in which sub-WITH gets initialized first
@@ -465,10 +463,10 @@ INSERT INTO y SELECT EXPLODE(SEQUENCE(1, 10));
465463
--SELECT * FROM y;
466464

467465
-- [NOTE] Spark SQL doesn't support UPDATE statement
468-
----WITH t AS (
469-
---- SELECT a FROM y
470-
----)
471-
----UPDATE y SET a = y.a-10 FROM t WHERE y.a > 20 AND t.a = y.a RETURNING y.a;
466+
--WITH t AS (
467+
-- SELECT a FROM y
468+
--)
469+
--UPDATE y SET a = y.a-10 FROM t WHERE y.a > 20 AND t.a = y.a RETURNING y.a;
472470
--
473471
--SELECT * FROM y;
474472

@@ -1184,10 +1182,10 @@ SELECT * FROM parent;
11841182
--DROP RULE y_rule ON y;
11851183

11861184
-- check that parser lookahead for WITH doesn't cause any odd behavior
1187-
-- [TODO] WITH should be a reserved keyword?
1185+
set spark.sql.parser.ansi.enabled=true;
11881186
create table foo (with baz); -- fail, WITH is a reserved word
1189-
-- [TODO] WITH should be a reserved keyword?
11901187
create table foo (with ordinality); -- fail, WITH is a reserved word
1188+
set spark.sql.parser.ansi.enabled=false;
11911189
with ordinality as (select 1 as x) select * from ordinality;
11921190

11931191
-- check sane response to attempt to modify CTE relation

sql/core/src/test/resources/sql-tests/results/pgSQL/with.sql.out

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 52
2+
-- Number of queries: 54
33

44

55
-- !query 0
@@ -352,128 +352,144 @@ struct<id:int,val:string>
352352

353353

354354
-- !query 38
355-
create table foo (with baz)
355+
set spark.sql.parser.ansi.enabled=true
356356
-- !query 38 schema
357-
struct<>
357+
struct<key:string,value:string>
358358
-- !query 38 output
359-
org.apache.spark.sql.catalyst.parser.ParseException
360-
361-
DataType baz is not supported.(line 1, pos 23)
362-
363-
== SQL ==
364-
create table foo (with baz)
365-
-----------------------^^^
359+
spark.sql.parser.ansi.enabled true
366360

367361

368362
-- !query 39
369-
-- fail, WITH is a reserved word
370-
create table foo (with ordinality)
363+
create table foo (with baz)
371364
-- !query 39 schema
372365
struct<>
373366
-- !query 39 output
374367
org.apache.spark.sql.catalyst.parser.ParseException
375368

376-
DataType ordinality is not supported.(line 2, pos 23)
369+
no viable alternative at input 'with'(line 1, pos 18)
377370

378371
== SQL ==
379-
-- fail, WITH is a reserved word
380-
create table foo (with ordinality)
381-
-----------------------^^^
372+
create table foo (with baz)
373+
------------------^^^
382374

383375

384376
-- !query 40
385377
-- fail, WITH is a reserved word
386-
with ordinality as (select 1 as x) select * from ordinality
378+
create table foo (with ordinality)
387379
-- !query 40 schema
388-
struct<x:int>
380+
struct<>
389381
-- !query 40 output
390-
1
382+
org.apache.spark.sql.catalyst.parser.ParseException
383+
384+
no viable alternative at input 'with'(line 2, pos 18)
385+
386+
== SQL ==
387+
-- fail, WITH is a reserved word
388+
create table foo (with ordinality)
389+
------------------^^^
391390

392391

393392
-- !query 41
394-
WITH test AS (SELECT 42) INSERT INTO test VALUES (1)
393+
-- fail, WITH is a reserved word
394+
set spark.sql.parser.ansi.enabled=false
395395
-- !query 41 schema
396-
struct<>
396+
struct<key:string,value:string>
397397
-- !query 41 output
398-
org.apache.spark.sql.AnalysisException
399-
Table not found: test;
398+
spark.sql.parser.ansi.enabled false
400399

401400

402401
-- !query 42
403-
create table test (i int) USING parquet
402+
with ordinality as (select 1 as x) select * from ordinality
404403
-- !query 42 schema
405-
struct<>
404+
struct<x:int>
406405
-- !query 42 output
407-
406+
1
408407

409408

410409
-- !query 43
411-
with test as (select 42) insert into test select * from test
410+
WITH test AS (SELECT 42) INSERT INTO test VALUES (1)
412411
-- !query 43 schema
413412
struct<>
414413
-- !query 43 output
415-
414+
org.apache.spark.sql.AnalysisException
415+
Table not found: test;
416416

417417

418418
-- !query 44
419-
select * from test
419+
create table test (i int) USING parquet
420420
-- !query 44 schema
421-
struct<i:int>
421+
struct<>
422422
-- !query 44 output
423-
42
423+
424424

425425

426426
-- !query 45
427-
drop table test
427+
with test as (select 42) insert into test select * from test
428428
-- !query 45 schema
429429
struct<>
430430
-- !query 45 output
431431

432432

433433

434434
-- !query 46
435-
DROP TABLE department
435+
select * from test
436436
-- !query 46 schema
437-
struct<>
437+
struct<i:int>
438438
-- !query 46 output
439-
439+
42
440440

441441

442442
-- !query 47
443-
DROP TABLE tree
443+
drop table test
444444
-- !query 47 schema
445445
struct<>
446446
-- !query 47 output
447447

448448

449449

450450
-- !query 48
451-
DROP TABLE graph
451+
DROP TABLE department
452452
-- !query 48 schema
453453
struct<>
454454
-- !query 48 output
455455

456456

457457

458458
-- !query 49
459-
DROP TABLE y
459+
DROP TABLE tree
460460
-- !query 49 schema
461461
struct<>
462462
-- !query 49 output
463463

464464

465465

466466
-- !query 50
467-
DROP TABLE yy
467+
DROP TABLE graph
468468
-- !query 50 schema
469469
struct<>
470470
-- !query 50 output
471471

472472

473473

474474
-- !query 51
475-
DROP TABLE parent
475+
DROP TABLE y
476476
-- !query 51 schema
477477
struct<>
478478
-- !query 51 output
479479

480+
481+
482+
-- !query 52
483+
DROP TABLE yy
484+
-- !query 52 schema
485+
struct<>
486+
-- !query 52 output
487+
488+
489+
490+
-- !query 53
491+
DROP TABLE parent
492+
-- !query 53 schema
493+
struct<>
494+
-- !query 53 output
495+

0 commit comments

Comments
 (0)