Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add ANSI_SQL_PARSER
  • Loading branch information
wangyum committed Jul 13, 2019
commit 45af58f58c0a44dc3055959192d20db8e4424f47
26 changes: 13 additions & 13 deletions sql/core/src/test/resources/sql-tests/inputs/pgSQL/boolean.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ SELECT 1 AS one;

SELECT true AS true;

SELECT false AS false;
SELECT false AS `false`;

SELECT boolean('t') AS true;

-- [SPARK-27931] Trim the string when cast string type to boolean type
SELECT boolean(' f ') AS false;
SELECT boolean(' f ') AS `false`;

SELECT boolean('true') AS true;

-- [SPARK-27923] PostgreSQL does not accept 'test' but Spark SQL accepts it and sets it to NULL
SELECT boolean('test') AS error;

SELECT boolean('false') AS false;
SELECT boolean('false') AS `false`;

-- [SPARK-27923] PostgreSQL does not accept 'foo' but Spark SQL accepts it and sets it to NULL
SELECT boolean('foo') AS error;
Expand All @@ -41,20 +41,20 @@ SELECT boolean('yes') AS true;
-- [SPARK-27923] PostgreSQL does not accept 'yeah' but Spark SQL accepts it and sets it to NULL
SELECT boolean('yeah') AS error;

SELECT boolean('n') AS false;
SELECT boolean('n') AS `false`;

SELECT boolean('no') AS false;
SELECT boolean('no') AS `false`;

-- [SPARK-27923] PostgreSQL does not accept 'nay' but Spark SQL accepts it and sets it to NULL
SELECT boolean('nay') AS error;

-- [SPARK-27931] Accept 'on' and 'off' as input for boolean data type
SELECT boolean('on') AS true;

SELECT boolean('off') AS false;
SELECT boolean('off') AS `false`;

-- [SPARK-27931] Accept unique prefixes thereof
SELECT boolean('of') AS false;
SELECT boolean('of') AS `false`;

-- [SPARK-27923] PostgreSQL does not accept 'o' but Spark SQL accepts it and sets it to NULL
SELECT boolean('o') AS error;
Expand All @@ -70,7 +70,7 @@ SELECT boolean('1') AS true;
-- [SPARK-27923] PostgreSQL does not accept '11' but Spark SQL accepts it and sets it to NULL
SELECT boolean('11') AS error;

SELECT boolean('0') AS false;
SELECT boolean('0') AS `false`;

-- [SPARK-27923] PostgreSQL does not accept '000' but Spark SQL accepts it and sets it to NULL
SELECT boolean('000') AS error;
Expand All @@ -82,11 +82,11 @@ SELECT boolean('') AS error;

SELECT boolean('t') or boolean('f') AS true;

SELECT boolean('t') and boolean('f') AS false;
SELECT boolean('t') and boolean('f') AS `false`;

SELECT not boolean('f') AS true;

SELECT boolean('t') = boolean('f') AS false;
SELECT boolean('t') = boolean('f') AS `false`;

SELECT boolean('t') <> boolean('f') AS true;

Expand All @@ -99,11 +99,11 @@ SELECT boolean('f') < boolean('t') AS true;
SELECT boolean('f') <= boolean('t') AS true;

-- explicit casts to/from text
SELECT boolean(string('TrUe')) AS true, boolean(string('fAlse')) AS false;
SELECT boolean(string('TrUe')) AS true, boolean(string('fAlse')) AS `false`;
-- [SPARK-27931] Trim the string when cast to boolean type
SELECT boolean(string(' true ')) AS true,
boolean(string(' FALSE')) AS false;
SELECT string(boolean(true)) AS true, string(boolean(false)) AS false;
boolean(string(' FALSE')) AS `false`;
SELECT string(boolean(true)) AS true, string(boolean(false)) AS `false`;

-- [SPARK-27923] PostgreSQL does not accept ' tru e ' but Spark SQL accepts it and sets it to NULL
SELECT boolean(string(' tru e ')) AS invalid; -- error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ SELECT int('2') * smallint('2') = smallint('16') / int('4') AS true;

SELECT smallint('2') * int('2') = int('16') / smallint('4') AS true;

SELECT int('1000') < int('999') AS false;
SELECT int('1000') < int('999') AS `false`;

-- [SPARK-28027] Our ! and !! has different meanings
-- SELECT 4! AS twenty_four;
Expand Down
4 changes: 2 additions & 2 deletions sql/core/src/test/resources/sql-tests/inputs/pgSQL/int8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ SELECT * FROM INT8_TBL WHERE smallint('123') <= q1;
SELECT * FROM INT8_TBL WHERE smallint('123') >= q1;


SELECT '' AS five, q1 AS plus, -q1 AS minus FROM INT8_TBL;
SELECT '' AS five, q1 AS plus, -q1 AS `minus` FROM INT8_TBL;

SELECT '' AS five, q1, q2, q1 + q2 AS plus FROM INT8_TBL;
SELECT '' AS five, q1, q2, q1 - q2 AS minus FROM INT8_TBL;
SELECT '' AS five, q1, q2, q1 - q2 AS `minus` FROM INT8_TBL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add SPARK-28349 before this line.

SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL;
SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL
WHERE q1 < 1000 or (q2 > 0 and q2 < 1000);
Expand Down
26 changes: 13 additions & 13 deletions sql/core/src/test/resources/sql-tests/results/pgSQL/boolean.sql.out
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ true


-- !query 2
SELECT false AS false
SELECT false AS `false`
-- !query 2 schema
struct<false:boolean>
-- !query 2 output
Expand All @@ -35,7 +35,7 @@ true


-- !query 4
SELECT boolean(' f ') AS false
SELECT boolean(' f ') AS `false`
-- !query 4 schema
struct<false:boolean>
-- !query 4 output
Expand All @@ -59,7 +59,7 @@ NULL


-- !query 7
SELECT boolean('false') AS false
SELECT boolean('false') AS `false`
-- !query 7 schema
struct<false:boolean>
-- !query 7 output
Expand Down Expand Up @@ -99,15 +99,15 @@ NULL


-- !query 12
SELECT boolean('n') AS false
SELECT boolean('n') AS `false`
-- !query 12 schema
struct<false:boolean>
-- !query 12 output
false


-- !query 13
SELECT boolean('no') AS false
SELECT boolean('no') AS `false`
-- !query 13 schema
struct<false:boolean>
-- !query 13 output
Expand All @@ -131,15 +131,15 @@ NULL


-- !query 16
SELECT boolean('off') AS false
SELECT boolean('off') AS `false`
-- !query 16 schema
struct<false:boolean>
-- !query 16 output
NULL


-- !query 17
SELECT boolean('of') AS false
SELECT boolean('of') AS `false`
-- !query 17 schema
struct<false:boolean>
-- !query 17 output
Expand Down Expand Up @@ -187,7 +187,7 @@ NULL


-- !query 23
SELECT boolean('0') AS false
SELECT boolean('0') AS `false`
-- !query 23 schema
struct<false:boolean>
-- !query 23 output
Expand Down Expand Up @@ -219,7 +219,7 @@ true


-- !query 27
SELECT boolean('t') and boolean('f') AS false
SELECT boolean('t') and boolean('f') AS `false`
-- !query 27 schema
struct<false:boolean>
-- !query 27 output
Expand All @@ -235,7 +235,7 @@ true


-- !query 29
SELECT boolean('t') = boolean('f') AS false
SELECT boolean('t') = boolean('f') AS `false`
-- !query 29 schema
struct<false:boolean>
-- !query 29 output
Expand Down Expand Up @@ -283,7 +283,7 @@ true


-- !query 35
SELECT boolean(string('TrUe')) AS true, boolean(string('fAlse')) AS false
SELECT boolean(string('TrUe')) AS true, boolean(string('fAlse')) AS `false`
-- !query 35 schema
struct<true:boolean,false:boolean>
-- !query 35 output
Expand All @@ -292,15 +292,15 @@ true false

-- !query 36
SELECT boolean(string(' true ')) AS true,
boolean(string(' FALSE')) AS false
boolean(string(' FALSE')) AS `false`
-- !query 36 schema
struct<true:boolean,false:boolean>
-- !query 36 output
NULL NULL


-- !query 37
SELECT string(boolean(true)) AS true, string(boolean(false)) AS false
SELECT string(boolean(true)) AS true, string(boolean(false)) AS `false`
-- !query 37 schema
struct<true:string,false:string>
-- !query 37 output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ true


-- !query 42
SELECT int('1000') < int('999') AS false
SELECT int('1000') < int('999') AS `false`
-- !query 42 schema
struct<false:boolean>
-- !query 42 output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ struct<q1:bigint,q2:bigint>


-- !query 37
SELECT '' AS five, q1 AS plus, -q1 AS minus FROM INT8_TBL
SELECT '' AS five, q1 AS plus, -q1 AS `minus` FROM INT8_TBL
-- !query 37 schema
struct<five:string,plus:bigint,minus:bigint>
-- !query 37 output
Expand All @@ -375,7 +375,7 @@ struct<five:string,q1:bigint,q2:bigint,plus:bigint>


-- !query 39
SELECT '' AS five, q1, q2, q1 - q2 AS minus FROM INT8_TBL
SELECT '' AS five, q1, q2, q1 - q2 AS `minus` FROM INT8_TBL
-- !query 39 schema
struct<five:string,q1:bigint,q2:bigint,minus:bigint>
-- !query 39 output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext {
localSparkSession.udf.register("vol", (s: String) => s)
// PostgreSQL enabled cartesian product by default.
localSparkSession.conf.set(SQLConf.CROSS_JOINS_ENABLED.key, true)
localSparkSession.conf.set(SQLConf.ANSI_SQL_PARSER.key, true)
case _ => // Don't add UDFs in Regular tests.
}

Expand Down