diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/aggregates_part2.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/aggregates_part2.sql.out index 2606d2eba7468..2b5371a657196 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/aggregates_part2.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/aggregates_part2.sql.out @@ -18,14 +18,11 @@ struct<> -- !query 1 SELECT - -- boolean and transitions - -- null because strict (NULL AND NULL) IS NULL AS `t`, (TRUE AND NULL) IS NULL AS `t`, (FALSE AND NULL) IS NULL AS `t`, (NULL AND TRUE) IS NULL AS `t`, (NULL AND FALSE) IS NULL AS `t`, - -- and actual computations (TRUE AND TRUE) AS `t`, NOT (TRUE AND FALSE) AS `t`, NOT (FALSE AND TRUE) AS `t`, @@ -38,14 +35,11 @@ true true false true false true true true true -- !query 2 SELECT - -- boolean or transitions - -- null because strict (NULL OR NULL) IS NULL AS `t`, (TRUE OR NULL) IS NULL AS `t`, (FALSE OR NULL) IS NULL AS `t`, (NULL OR TRUE) IS NULL AS `t`, (NULL OR FALSE) IS NULL AS `t`, - -- actual computations (TRUE OR TRUE) AS `t`, (TRUE OR FALSE) AS `t`, (FALSE OR TRUE) AS `t`, diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/boolean.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/boolean.sql.out index 332754652b0fb..c7903c8a34ef4 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/boolean.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/boolean.sql.out @@ -316,7 +316,6 @@ NULL -- !query 39 --- error SELECT boolean(string('')) AS invalid -- !query 39 schema struct @@ -325,8 +324,6 @@ NULL -- !query 40 --- error - CREATE TABLE BOOLTBL1 (f1 boolean) USING parquet -- !query 40 schema struct<> diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/date.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/date.sql.out index 3f45c386fb90a..46101ebce8113 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/date.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/date.sql.out @@ -452,17 +452,15 @@ struct -- !query 44 --- out of range SELECT date '5874897-12-31' -- !query 44 schema struct<> -- !query 44 output org.apache.spark.sql.catalyst.parser.ParseException -Cannot parse the DATE value: 5874897-12-31(line 2, pos 7) +Cannot parse the DATE value: 5874897-12-31(line 1, pos 7) == SQL == --- out of range SELECT date '5874897-12-31' -------^^^ @@ -482,10 +480,6 @@ SELECT date '5874898-01-01' -- !query 46 --- out of range - - - SELECT f1 - date '2000-01-01' AS `Days From 2K` FROM DATE_TBL -- !query 46 schema struct diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/join.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/join.sql.out index 0730066719764..f75fe0519645b 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/join.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/join.sql.out @@ -3257,18 +3257,16 @@ Reference 'f1' is ambiguous, could be: j.f1, j.f1.; line 2 pos 63 -- !query 168 --- error select * from int8_tbl x join (int4_tbl x cross join int4_tbl y) j on q1 = y.f1 -- !query 168 schema struct<> -- !query 168 output org.apache.spark.sql.AnalysisException -cannot resolve '`y.f1`' given input columns: [j.f1, j.f1, x.q1, x.q2]; line 3 pos 63 +cannot resolve '`y.f1`' given input columns: [j.f1, j.f1, x.q1, x.q2]; line 2 pos 63 -- !query 169 --- error select * from int8_tbl x join (int4_tbl x cross join int4_tbl y(ff)) j on q1 = f1 -- !query 169 schema @@ -3278,72 +3276,42 @@ struct -- !query 170 --- ok - - select t1.uunique1 from tenk1 t1 join tenk2 t2 on t1.two = t2.two -- !query 170 schema struct<> -- !query 170 output org.apache.spark.sql.AnalysisException -cannot resolve '`t1.uunique1`' given input columns: [t1.even, t2.even, t1.fivethous, t2.fivethous, t1.four, t2.four, t1.hundred, t2.hundred, t1.odd, t2.odd, t1.string4, t2.string4, t1.stringu1, t2.stringu1, t1.stringu2, t2.stringu2, t1.ten, t2.ten, t1.tenthous, t2.tenthous, t1.thousand, t2.thousand, t1.twenty, t2.twenty, t1.two, t2.two, t1.twothousand, t2.twothousand, t1.unique1, t2.unique1, t1.unique2, t2.unique2]; line 4 pos 7 +cannot resolve '`t1.uunique1`' given input columns: [t1.even, t2.even, t1.fivethous, t2.fivethous, t1.four, t2.four, t1.hundred, t2.hundred, t1.odd, t2.odd, t1.string4, t2.string4, t1.stringu1, t2.stringu1, t1.stringu2, t2.stringu2, t1.ten, t2.ten, t1.tenthous, t2.tenthous, t1.thousand, t2.thousand, t1.twenty, t2.twenty, t1.two, t2.two, t1.twothousand, t2.twothousand, t1.unique1, t2.unique1, t1.unique2, t2.unique2]; line 1 pos 7 -- !query 171 --- error, prefer "t1" suggestion select t2.uunique1 from tenk1 t1 join tenk2 t2 on t1.two = t2.two -- !query 171 schema struct<> -- !query 171 output org.apache.spark.sql.AnalysisException -cannot resolve '`t2.uunique1`' given input columns: [t1.even, t2.even, t1.fivethous, t2.fivethous, t1.four, t2.four, t1.hundred, t2.hundred, t1.odd, t2.odd, t1.string4, t2.string4, t1.stringu1, t2.stringu1, t1.stringu2, t2.stringu2, t1.ten, t2.ten, t1.tenthous, t2.tenthous, t1.thousand, t2.thousand, t1.twenty, t2.twenty, t1.two, t2.two, t1.twothousand, t2.twothousand, t1.unique1, t2.unique1, t1.unique2, t2.unique2]; line 2 pos 7 +cannot resolve '`t2.uunique1`' given input columns: [t1.even, t2.even, t1.fivethous, t2.fivethous, t1.four, t2.four, t1.hundred, t2.hundred, t1.odd, t2.odd, t1.string4, t2.string4, t1.stringu1, t2.stringu1, t1.stringu2, t2.stringu2, t1.ten, t2.ten, t1.tenthous, t2.tenthous, t1.thousand, t2.thousand, t1.twenty, t2.twenty, t1.two, t2.two, t1.twothousand, t2.twothousand, t1.unique1, t2.unique1, t1.unique2, t2.unique2]; line 1 pos 7 -- !query 172 --- error, prefer "t2" suggestion select uunique1 from tenk1 t1 join tenk2 t2 on t1.two = t2.two -- !query 172 schema struct<> -- !query 172 output org.apache.spark.sql.AnalysisException -cannot resolve '`uunique1`' given input columns: [t1.even, t2.even, t1.fivethous, t2.fivethous, t1.four, t2.four, t1.hundred, t2.hundred, t1.odd, t2.odd, t1.string4, t2.string4, t1.stringu1, t2.stringu1, t1.stringu2, t2.stringu2, t1.ten, t2.ten, t1.tenthous, t2.tenthous, t1.thousand, t2.thousand, t1.twenty, t2.twenty, t1.two, t2.two, t1.twothousand, t2.twothousand, t1.unique1, t2.unique1, t1.unique2, t2.unique2]; line 2 pos 7 +cannot resolve '`uunique1`' given input columns: [t1.even, t2.even, t1.fivethous, t2.fivethous, t1.four, t2.four, t1.hundred, t2.hundred, t1.odd, t2.odd, t1.string4, t2.string4, t1.stringu1, t2.stringu1, t1.stringu2, t2.stringu2, t1.ten, t2.ten, t1.tenthous, t2.tenthous, t1.thousand, t2.thousand, t1.twenty, t2.twenty, t1.two, t2.two, t1.twothousand, t2.twothousand, t1.unique1, t2.unique1, t1.unique2, t2.unique2]; line 1 pos 7 -- !query 173 --- error, suggest both at once - - - - - - - - - - - - - - - - - - - - - - - - select f1,g from int4_tbl a, (select f1 as g) ss -- !query 173 schema struct<> -- !query 173 output org.apache.spark.sql.AnalysisException -cannot resolve '`f1`' given input columns: []; line 26 pos 37 +cannot resolve '`f1`' given input columns: []; line 1 pos 37 -- !query 174 diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/select.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/select.sql.out index 797f808dad11e..e54de1d6fdbdc 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/select.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/select.sql.out @@ -399,7 +399,6 @@ NULL -- !query 22 --- same thing SELECT * FROM foo ORDER BY f1 NULLS FIRST -- !query 22 schema struct diff --git a/sql/core/src/test/resources/sql-tests/results/pgSQL/with.sql.out b/sql/core/src/test/resources/sql-tests/results/pgSQL/with.sql.out index 366b65f3659cd..91b0ff20b6ab0 100644 --- a/sql/core/src/test/resources/sql-tests/results/pgSQL/with.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/pgSQL/with.sql.out @@ -358,23 +358,20 @@ create table foo (with baz) -- !query 38 --- fail, WITH is a reserved word create table foo (with ordinality) -- !query 38 schema struct<> -- !query 38 output org.apache.spark.sql.catalyst.parser.ParseException -no viable alternative at input 'with'(line 2, pos 18) +no viable alternative at input 'with'(line 1, pos 18) == SQL == --- fail, WITH is a reserved word create table foo (with ordinality) ------------------^^^ -- !query 39 --- fail, WITH is a reserved word with ordinality as (select 1 as x) select * from ordinality -- !query 39 schema struct diff --git a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column-literal.sql.out b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column-literal.sql.out index a16e98af9a417..f02f760727976 100644 --- a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column-literal.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column-literal.sql.out @@ -16,8 +16,6 @@ struct<> -- !query 1 --- Case 5 - -- (one null column with no match -> row is returned) SELECT * FROM m WHERE b = 1.0 -- Matches (null, 1.0) @@ -29,8 +27,6 @@ NULL 1 -- !query 2 --- Case 6 - -- (no null columns with match -> row not returned) SELECT * FROM m WHERE b = 3.0 -- Matches (2, 3.0) @@ -42,8 +38,6 @@ struct -- !query 3 --- Case 7 - -- (no null columns with no match -> row is returned) SELECT * FROM m WHERE b = 5.0 -- Matches (4, 5.0) diff --git a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column.sql.out b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column.sql.out index aa5f64b8ebf55..a27a66e3f27f5 100644 --- a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column.sql.out @@ -29,8 +29,6 @@ struct<> -- !query 2 --- Case 1 - -- (subquery is empty -> row is returned) SELECT * FROM m WHERE (a, b) NOT IN (SELECT * @@ -46,8 +44,6 @@ NULL NULL -- !query 3 --- Case 2 - -- (subquery contains a row with null in all columns -> row not returned) SELECT * FROM m WHERE (a, b) NOT IN (SELECT * @@ -60,8 +56,6 @@ struct -- !query 4 --- Case 3 - -- (probe-side columns are all null -> row not returned) SELECT * FROM m WHERE a IS NULL AND b IS NULL -- Matches only (null, null) @@ -75,8 +69,6 @@ struct -- !query 5 --- Case 4 - -- (one column null, other column matches a row in the subquery result -> row not returned) SELECT * FROM m WHERE b = 1.0 -- Matches (null, 1.0) @@ -90,8 +82,6 @@ struct -- !query 6 --- Case 5 - -- (one null column with no match -> row is returned) SELECT * FROM m WHERE b = 1.0 -- Matches (null, 1.0) @@ -105,8 +95,6 @@ NULL 1 -- !query 7 --- Case 6 - -- (no null columns with match -> row not returned) SELECT * FROM m WHERE b = 3.0 -- Matches (2, 3.0) @@ -120,8 +108,6 @@ struct -- !query 8 --- Case 7 - -- (no null columns with no match -> row is returned) SELECT * FROM m WHERE b = 5.0 -- Matches (4, 5.0) diff --git a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column-literal.sql.out b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column-literal.sql.out index 446447e890449..cf8f03eaa9311 100644 --- a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column-literal.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column-literal.sql.out @@ -15,12 +15,6 @@ struct<> -- !query 1 --- Uncorrelated NOT IN Subquery test cases - -- Case 1 (not possible to write a literal with no rows, so we ignore it.) - -- (empty subquery -> all rows returned) - - -- Case 2 - -- (subquery includes null -> no rows returned) SELECT * FROM m WHERE a NOT IN (null) @@ -31,8 +25,6 @@ struct -- !query 2 --- Case 3 - -- (probe column is null -> row not returned) SELECT * FROM m WHERE b = 1.0 -- Only matches (null, 1.0) @@ -44,8 +36,6 @@ struct -- !query 3 --- Case 4 - -- (probe column matches subquery row -> row not returned) SELECT * FROM m WHERE b = 3.0 -- Only matches (2, 3.0) @@ -57,8 +47,6 @@ struct -- !query 4 --- Case 5 - -- (probe column does not match subquery row -> row is returned) SELECT * FROM m WHERE b = 3.0 -- Only matches (2, 3.0) diff --git a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column.sql.out b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column.sql.out index f58ebeacc2872..d07981cfd11e5 100644 --- a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column.sql.out @@ -27,9 +27,6 @@ struct<> -- !query 2 --- Uncorrelated NOT IN Subquery test cases - -- Case 1 - -- (empty subquery -> all rows returned) SELECT * FROM m WHERE a NOT IN (SELECT c @@ -44,8 +41,6 @@ NULL 1 -- !query 3 --- Case 2 - -- (subquery includes null -> no rows returned) SELECT * FROM m WHERE a NOT IN (SELECT c @@ -58,8 +53,6 @@ struct -- !query 4 --- Case 3 - -- (probe column is null -> row not returned) SELECT * FROM m WHERE b = 1.0 -- Only matches (null, 1.0) @@ -73,8 +66,6 @@ struct -- !query 5 --- Case 4 - -- (probe column matches subquery row -> row not returned) SELECT * FROM m WHERE b = 3.0 -- Only matches (2, 3.0) @@ -88,8 +79,6 @@ struct -- !query 6 --- Case 5 - -- (probe column does not match subquery row -> row is returned) SELECT * FROM m WHERE b = 3.0 -- Only matches (2, 3.0) @@ -103,9 +92,6 @@ struct -- !query 7 --- Correlated NOT IN subquery test cases - -- Case 2->1 - -- (subquery had nulls but they are removed by correlated subquery -> all rows returned) SELECT * FROM m WHERE a NOT IN (SELECT c @@ -120,8 +106,6 @@ NULL 1 -- !query 8 --- Case 3->1 - -- (probe column is null but subquery returns no rows -> row is returned) SELECT * FROM m WHERE b = 1.0 -- Only matches (null, 1.0) @@ -135,8 +119,6 @@ NULL 1 -- !query 9 --- Case 4->1 - -- (probe column matches row which is filtered out by correlated subquery -> row is returned) SELECT * FROM m WHERE b = 3.0 -- Only matches (2, 3.0) diff --git a/sql/core/src/test/resources/sql-tests/results/udf/pgSQL/udf-aggregates_part2.sql.out b/sql/core/src/test/resources/sql-tests/results/udf/pgSQL/udf-aggregates_part2.sql.out index 9fe943874c3e5..ad2f1bdf77d7a 100644 --- a/sql/core/src/test/resources/sql-tests/results/udf/pgSQL/udf-aggregates_part2.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/udf/pgSQL/udf-aggregates_part2.sql.out @@ -18,14 +18,11 @@ struct<> -- !query 1 SELECT - -- boolean and transitions - -- null because strict (NULL AND NULL) IS NULL AS `t`, (TRUE AND NULL) IS NULL AS `t`, (FALSE AND NULL) IS NULL AS `t`, (NULL AND TRUE) IS NULL AS `t`, (NULL AND FALSE) IS NULL AS `t`, - -- and actual computations (TRUE AND TRUE) AS `t`, NOT (TRUE AND FALSE) AS `t`, NOT (FALSE AND TRUE) AS `t`, @@ -38,14 +35,11 @@ true true false true false true true true true -- !query 2 SELECT - -- boolean or transitions - -- null because strict (NULL OR NULL) IS NULL AS `t`, (TRUE OR NULL) IS NULL AS `t`, (FALSE OR NULL) IS NULL AS `t`, (NULL OR TRUE) IS NULL AS `t`, (NULL OR FALSE) IS NULL AS `t`, - -- actual computations (TRUE OR TRUE) AS `t`, (TRUE OR FALSE) AS `t`, (FALSE OR TRUE) AS `t`, diff --git a/sql/core/src/test/resources/sql-tests/results/udf/udf-udaf.sql.out b/sql/core/src/test/resources/sql-tests/results/udf/udf-udaf.sql.out index e1747f466779f..f8e5fe6a62f33 100644 --- a/sql/core/src/test/resources/sql-tests/results/udf/udf-udaf.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/udf/udf-udaf.sql.out @@ -3,8 +3,6 @@ -- !query 0 --- This test file was converted from udaf.sql. - CREATE OR REPLACE TEMPORARY VIEW t1 AS SELECT * FROM VALUES (1), (2), (3), (4) as t1(int_col1) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala index c6fc84894a3f0..4bdf25051127c 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala @@ -225,11 +225,13 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext { private def runTest(testCase: TestCase): Unit = { val input = fileToString(new File(testCase.inputFile)) - val (comments, code) = input.split("\n").partition(_.startsWith("--")) + val (comments, code) = input.split("\n").partition(_.trim.startsWith("--")) // List of SQL queries to run // note: this is not a robust way to split queries using semicolon, but works for now. val queries = code.mkString("\n").split("(?<=[^\\\\]);").map(_.trim).filter(_ != "").toSeq + // Fix misplacement when comment is at the end of the query. + .map(_.split("\n").filterNot(_.startsWith("--")).mkString("\n")).map(_.trim).filter(_ != "") // When we are regenerating the golden files, we don't need to set any config as they // all need to return the same result