From 028a80474ffe86783db72451b6dd1f3e038eec29 Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Thu, 6 Oct 2022 22:20:57 -0700 Subject: [PATCH 1/3] move the flag under spark.sql.ansi.enabled --- .../apache/spark/sql/internal/SQLConf.scala | 20 +- .../inputs/ansi/double-quoted-identifiers.sql | 2 + .../ansi/double-quoted-identifiers.sql.out | 607 ++++++++++++++++++ .../results/double-quoted-identifiers.sql.out | 201 +++--- 4 files changed, 737 insertions(+), 93 deletions(-) create mode 100644 sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers.sql create mode 100644 sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala index 376bcece3c61c..bbe5bdd7035e4 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala @@ -2909,7 +2909,15 @@ object SQLConf { .booleanConf .createWithDefault(sys.env.get("SPARK_ANSI_SQL_MODE").contains("true")) - val DOUBLE_QUOTED_IDENTIFIERS = buildConf("spark.sql.ansi.double_quoted_identifiers") + val ENFORCE_RESERVED_KEYWORDS = buildConf("spark.sql.ansi.enforceReservedKeywords") + .doc(s"When true and '${ANSI_ENABLED.key}' is true, the Spark SQL parser enforces the ANSI " + + "reserved keywords and forbids SQL queries that use reserved keywords as alias names " + + "and/or identifiers for table, view, function, etc.") + .version("3.3.0") + .booleanConf + .createWithDefault(false) + + val DOUBLE_QUOTED_IDENTIFIERS = buildConf("spark.sql.ansi.doubleQuotedIdentifiers") .doc("When true, Spark SQL reads literals enclosed in double quoted (\") as identifiers. " + "When false they are read as string literals.") .version("3.4.0") @@ -2964,14 +2972,6 @@ object SQLConf { .booleanConf .createWithDefault(false) - val ENFORCE_RESERVED_KEYWORDS = buildConf("spark.sql.ansi.enforceReservedKeywords") - .doc(s"When true and '${ANSI_ENABLED.key}' is true, the Spark SQL parser enforces the ANSI " + - "reserved keywords and forbids SQL queries that use reserved keywords as alias names " + - "and/or identifiers for table, view, function, etc.") - .version("3.3.0") - .booleanConf - .createWithDefault(false) - val SORT_BEFORE_REPARTITION = buildConf("spark.sql.execution.sortBeforeRepartition") .internal() @@ -4592,7 +4592,7 @@ class SQLConf extends Serializable with Logging { def enforceReservedKeywords: Boolean = ansiEnabled && getConf(ENFORCE_RESERVED_KEYWORDS) - def doubleQuotedIdentifiers: Boolean = getConf(DOUBLE_QUOTED_IDENTIFIERS) + def doubleQuotedIdentifiers: Boolean = ansiEnabled && getConf(DOUBLE_QUOTED_IDENTIFIERS) def timestampType: AtomicType = getConf(TIMESTAMP_TYPE) match { case "TIMESTAMP_LTZ" => diff --git a/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers.sql b/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers.sql new file mode 100644 index 0000000000000..a20694d96040c --- /dev/null +++ b/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers.sql @@ -0,0 +1,2 @@ +--IMPORT double-quoted-identifiers.sql + diff --git a/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out b/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out new file mode 100644 index 0000000000000..a67a5cffd31ca --- /dev/null +++ b/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out @@ -0,0 +1,607 @@ +-- Automatically generated by SQLQueryTestSuite +-- !query +SET spark.sql.ansi.double_quoted_identifiers = false +-- !query schema +struct +-- !query output +spark.sql.ansi.double_quoted_identifiers false + + +-- !query +SELECT 1 FROM "not_exist" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +USE SCHEMA "not_exist" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +ALTER TABLE "not_exist" ADD COLUMN not_exist int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +ALTER TABLE not_exist ADD COLUMN "not_exist" int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +SELECT 1 AS "not_exist" FROM not_exist +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +SELECT 1 FROM not_exist AS X("hello") +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"hello\"'", + "hint" : "" + } +} + + +-- !query +SELECT "not_exist"() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +SELECT "not_exist".not_exist() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +SELECT 1 FROM `hello` +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: hello; line 1 pos 14 + + +-- !query +USE SCHEMA `not_exist` +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException +Database 'not_exist' not found + + +-- !query +ALTER TABLE `not_exist` ADD COLUMN not_exist int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table not found: not_exist; line 1 pos 12 + + +-- !query +ALTER TABLE not_exist ADD COLUMN `not_exist` int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table not found: not_exist; line 1 pos 12 + + +-- !query +SELECT 1 AS `not_exist` FROM `not_exist` +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: not_exist; line 1 pos 29 + + +-- !query +SELECT 1 FROM not_exist AS X(`hello`) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: not_exist; line 1 pos 14 + + +-- !query +SELECT `not_exist`() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +{ + "errorClass" : "_LEGACY_ERROR_TEMP_1242", + "messageParameters" : { + "fullName" : "spark_catalog.default.not_exist", + "rawName" : "not_exist" + }, + "queryContext" : [ { + "objectType" : "", + "objectName" : "", + "startIndex" : 8, + "stopIndex" : 20, + "fragment" : "`not_exist`()" + } ] +} + + +-- !query +SELECT `not_exist`.not_exist() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +{ + "errorClass" : "_LEGACY_ERROR_TEMP_1243", + "messageParameters" : { + "rawName" : "not_exist.not_exist" + }, + "queryContext" : [ { + "objectType" : "", + "objectName" : "", + "startIndex" : 8, + "stopIndex" : 30, + "fragment" : "`not_exist`.not_exist()" + } ] +} + + +-- !query +SELECT "hello" +-- !query schema +struct +-- !query output +hello + + +-- !query +CREATE TEMPORARY VIEW v(c1 COMMENT "hello") AS SELECT 1 +-- !query schema +struct<> +-- !query output + + + +-- !query +DROP VIEW v +-- !query schema +struct<> +-- !query output + + + +-- !query +SELECT INTERVAL "1" YEAR +-- !query schema +struct +-- !query output +1-0 + + +-- !query +SET spark.sql.ansi.double_quoted_identifiers = true +-- !query schema +struct +-- !query output +spark.sql.ansi.double_quoted_identifiers true + + +-- !query +SELECT 1 FROM "not_exist" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: not_exist; line 1 pos 14 + + +-- !query +USE SCHEMA "not_exist" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException +Database 'not_exist' not found + + +-- !query +ALTER TABLE "not_exist" ADD COLUMN not_exist int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table not found: not_exist; line 1 pos 12 + + +-- !query +ALTER TABLE not_exist ADD COLUMN "not_exist" int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table not found: not_exist; line 1 pos 12 + + +-- !query +SELECT 1 AS "not_exist" FROM not_exist +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: not_exist; line 1 pos 29 + + +-- !query +SELECT 1 FROM not_exist AS X("hello") +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: not_exist; line 1 pos 14 + + +-- !query +SELECT "not_exist"() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +{ + "errorClass" : "_LEGACY_ERROR_TEMP_1242", + "messageParameters" : { + "fullName" : "spark_catalog.default.not_exist", + "rawName" : "not_exist" + }, + "queryContext" : [ { + "objectType" : "", + "objectName" : "", + "startIndex" : 8, + "stopIndex" : 20, + "fragment" : "\"not_exist\"()" + } ] +} + + +-- !query +SELECT "not_exist".not_exist() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +{ + "errorClass" : "_LEGACY_ERROR_TEMP_1243", + "messageParameters" : { + "rawName" : "not_exist.not_exist" + }, + "queryContext" : [ { + "objectType" : "", + "objectName" : "", + "startIndex" : 8, + "stopIndex" : 30, + "fragment" : "\"not_exist\".not_exist()" + } ] +} + + +-- !query +SELECT "hello" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +{ + "errorClass" : "UNRESOLVED_COLUMN.WITHOUT_SUGGESTION", + "sqlState" : "42000", + "messageParameters" : { + "objectName" : "`hello`" + }, + "queryContext" : [ { + "objectType" : "", + "objectName" : "", + "startIndex" : 8, + "stopIndex" : 14, + "fragment" : "\"hello\"" + } ] +} + + +-- !query +SELECT 1 FROM `hello` +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: hello; line 1 pos 14 + + +-- !query +USE SCHEMA `not_exist` +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException +Database 'not_exist' not found + + +-- !query +ALTER TABLE `not_exist` ADD COLUMN not_exist int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table not found: not_exist; line 1 pos 12 + + +-- !query +ALTER TABLE not_exist ADD COLUMN `not_exist` int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table not found: not_exist; line 1 pos 12 + + +-- !query +SELECT 1 AS `not_exist` FROM `not_exist` +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: not_exist; line 1 pos 29 + + +-- !query +SELECT 1 FROM not_exist AS X(`hello`) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: not_exist; line 1 pos 14 + + +-- !query +SELECT `not_exist`() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +{ + "errorClass" : "_LEGACY_ERROR_TEMP_1242", + "messageParameters" : { + "fullName" : "spark_catalog.default.not_exist", + "rawName" : "not_exist" + }, + "queryContext" : [ { + "objectType" : "", + "objectName" : "", + "startIndex" : 8, + "stopIndex" : 20, + "fragment" : "`not_exist`()" + } ] +} + + +-- !query +SELECT `not_exist`.not_exist() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +{ + "errorClass" : "_LEGACY_ERROR_TEMP_1243", + "messageParameters" : { + "rawName" : "not_exist.not_exist" + }, + "queryContext" : [ { + "objectType" : "", + "objectName" : "", + "startIndex" : 8, + "stopIndex" : 30, + "fragment" : "`not_exist`.not_exist()" + } ] +} + + +-- !query +CREATE TEMPORARY VIEW v(c1 COMMENT "hello") AS SELECT 1 +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"hello\"'", + "hint" : "" + } +} + + +-- !query +DROP VIEW v +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.analysis.NoSuchTableException +{ + "errorClass" : "_LEGACY_ERROR_TEMP_1115", + "messageParameters" : { + "msg" : "Table spark_catalog.default.v not found" + } +} + + +-- !query +SELECT INTERVAL "1" YEAR +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"1\"'", + "hint" : "" + } +} + + +-- !query +SELECT 'hello' +-- !query schema +struct +-- !query output +hello + + +-- !query +CREATE TEMPORARY VIEW v(c1 COMMENT 'hello') AS SELECT 1 +-- !query schema +struct<> +-- !query output + + + +-- !query +DROP VIEW v +-- !query schema +struct<> +-- !query output + + + +-- !query +SELECT INTERVAL '1' YEAR +-- !query schema +struct +-- !query output +1-0 + + +-- !query +CREATE SCHEMA "myschema" +-- !query schema +struct<> +-- !query output + + + +-- !query +CREATE TEMPORARY VIEW "myview"("c1") AS + WITH "v"("a") AS (SELECT 1) SELECT "a" FROM "v" +-- !query schema +struct<> +-- !query output + + + +-- !query +SELECT "a1" AS "a2" FROM "myview" AS "atab"("a1") +-- !query schema +struct +-- !query output +1 + + +-- !query +DROP TABLE "myview" +-- !query schema +struct<> +-- !query output + + + +-- !query +DROP SCHEMA "myschema" +-- !query schema +struct<> +-- !query output + diff --git a/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out b/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out index a67a5cffd31ca..e66e91673f7f2 100644 --- a/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out @@ -277,8 +277,15 @@ SELECT 1 FROM "not_exist" -- !query schema struct<> -- !query output -org.apache.spark.sql.AnalysisException -Table or view not found: not_exist; line 1 pos 14 +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} -- !query @@ -286,8 +293,15 @@ USE SCHEMA "not_exist" -- !query schema struct<> -- !query output -org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException -Database 'not_exist' not found +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} -- !query @@ -295,8 +309,15 @@ ALTER TABLE "not_exist" ADD COLUMN not_exist int -- !query schema struct<> -- !query output -org.apache.spark.sql.AnalysisException -Table not found: not_exist; line 1 pos 12 +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} -- !query @@ -304,8 +325,15 @@ ALTER TABLE not_exist ADD COLUMN "not_exist" int -- !query schema struct<> -- !query output -org.apache.spark.sql.AnalysisException -Table not found: not_exist; line 1 pos 12 +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} -- !query @@ -313,8 +341,15 @@ SELECT 1 AS "not_exist" FROM not_exist -- !query schema struct<> -- !query output -org.apache.spark.sql.AnalysisException -Table or view not found: not_exist; line 1 pos 29 +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} -- !query @@ -322,8 +357,15 @@ SELECT 1 FROM not_exist AS X("hello") -- !query schema struct<> -- !query output -org.apache.spark.sql.AnalysisException -Table or view not found: not_exist; line 1 pos 14 +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"hello\"'", + "hint" : "" + } +} -- !query @@ -331,20 +373,14 @@ SELECT "not_exist"() -- !query schema struct<> -- !query output -org.apache.spark.sql.AnalysisException +org.apache.spark.sql.catalyst.parser.ParseException { - "errorClass" : "_LEGACY_ERROR_TEMP_1242", + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", "messageParameters" : { - "fullName" : "spark_catalog.default.not_exist", - "rawName" : "not_exist" - }, - "queryContext" : [ { - "objectType" : "", - "objectName" : "", - "startIndex" : 8, - "stopIndex" : 20, - "fragment" : "\"not_exist\"()" - } ] + "error" : "'\"not_exist\"'", + "hint" : "" + } } @@ -353,42 +389,23 @@ SELECT "not_exist".not_exist() -- !query schema struct<> -- !query output -org.apache.spark.sql.AnalysisException +org.apache.spark.sql.catalyst.parser.ParseException { - "errorClass" : "_LEGACY_ERROR_TEMP_1243", + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", "messageParameters" : { - "rawName" : "not_exist.not_exist" - }, - "queryContext" : [ { - "objectType" : "", - "objectName" : "", - "startIndex" : 8, - "stopIndex" : 30, - "fragment" : "\"not_exist\".not_exist()" - } ] + "error" : "'\"not_exist\"'", + "hint" : "" + } } -- !query SELECT "hello" -- !query schema -struct<> +struct -- !query output -org.apache.spark.sql.AnalysisException -{ - "errorClass" : "UNRESOLVED_COLUMN.WITHOUT_SUGGESTION", - "sqlState" : "42000", - "messageParameters" : { - "objectName" : "`hello`" - }, - "queryContext" : [ { - "objectType" : "", - "objectName" : "", - "startIndex" : 8, - "stopIndex" : 14, - "fragment" : "\"hello\"" - } ] -} +hello -- !query @@ -493,15 +510,7 @@ CREATE TEMPORARY VIEW v(c1 COMMENT "hello") AS SELECT 1 -- !query schema struct<> -- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"hello\"'", - "hint" : "" - } -} + -- !query @@ -509,29 +518,15 @@ DROP VIEW v -- !query schema struct<> -- !query output -org.apache.spark.sql.catalyst.analysis.NoSuchTableException -{ - "errorClass" : "_LEGACY_ERROR_TEMP_1115", - "messageParameters" : { - "msg" : "Table spark_catalog.default.v not found" - } -} + -- !query SELECT INTERVAL "1" YEAR -- !query schema -struct<> +struct -- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"1\"'", - "hint" : "" - } -} +1-0 -- !query @@ -571,7 +566,15 @@ CREATE SCHEMA "myschema" -- !query schema struct<> -- !query output - +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"myschema\"'", + "hint" : "" + } +} -- !query @@ -580,15 +583,31 @@ CREATE TEMPORARY VIEW "myview"("c1") AS -- !query schema struct<> -- !query output - +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"myview\"'", + "hint" : "" + } +} -- !query SELECT "a1" AS "a2" FROM "myview" AS "atab"("a1") -- !query schema -struct +struct<> -- !query output -1 +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"a2\"'", + "hint" : "" + } +} -- !query @@ -596,7 +615,15 @@ DROP TABLE "myview" -- !query schema struct<> -- !query output - +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"myview\"'", + "hint" : "" + } +} -- !query @@ -604,4 +631,12 @@ DROP SCHEMA "myschema" -- !query schema struct<> -- !query output - +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"myschema\"'", + "hint" : "" + } +} From 086775b6c41103cd1ca89e5eb82857be4a32c5c0 Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Fri, 7 Oct 2022 14:47:35 -0700 Subject: [PATCH 2/3] fix gloden files --- .../sql-tests/inputs/double-quoted-identifiers.sql | 4 ++-- .../results/ansi/double-quoted-identifiers.sql.out | 8 ++++---- .../sql-tests/results/double-quoted-identifiers.sql.out | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/double-quoted-identifiers.sql b/sql/core/src/test/resources/sql-tests/inputs/double-quoted-identifiers.sql index 7fe35e5a410ba..f83fa5ca458f6 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/double-quoted-identifiers.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/double-quoted-identifiers.sql @@ -1,7 +1,7 @@ -- test cases for spark.sql.ansi.double_quoted_identifiers -- Base line -SET spark.sql.ansi.double_quoted_identifiers = false; +SET spark.sql.ansi.doubleQuotedIdentifiers = false; -- All these should error out in the parser SELECT 1 FROM "not_exist"; @@ -46,7 +46,7 @@ DROP VIEW v; SELECT INTERVAL "1" YEAR; -- Now turn on the config. -SET spark.sql.ansi.double_quoted_identifiers = true; +SET spark.sql.ansi.doubleQuotedIdentifiers = true; -- All these should error out in analysis now SELECT 1 FROM "not_exist"; diff --git a/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out b/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out index a67a5cffd31ca..78dc3c5d69ec0 100644 --- a/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out @@ -1,10 +1,10 @@ -- Automatically generated by SQLQueryTestSuite -- !query -SET spark.sql.ansi.double_quoted_identifiers = false +SET spark.sql.ansi.doubleQuotedIdentifiers = false -- !query schema struct -- !query output -spark.sql.ansi.double_quoted_identifiers false +spark.sql.ansi.doubleQuotedIdentifiers false -- !query @@ -265,11 +265,11 @@ struct -- !query -SET spark.sql.ansi.double_quoted_identifiers = true +SET spark.sql.ansi.doubleQuotedIdentifiers = true -- !query schema struct -- !query output -spark.sql.ansi.double_quoted_identifiers true +spark.sql.ansi.doubleQuotedIdentifiers true -- !query diff --git a/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out b/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out index e66e91673f7f2..2d1f192efffa0 100644 --- a/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out @@ -1,10 +1,10 @@ -- Automatically generated by SQLQueryTestSuite -- !query -SET spark.sql.ansi.double_quoted_identifiers = false +SET spark.sql.ansi.doubleQuotedIdentifiers = false -- !query schema struct -- !query output -spark.sql.ansi.double_quoted_identifiers false +spark.sql.ansi.doubleQuotedIdentifiers false -- !query @@ -265,11 +265,11 @@ struct -- !query -SET spark.sql.ansi.double_quoted_identifiers = true +SET spark.sql.ansi.doubleQuotedIdentifiers = true -- !query schema struct -- !query output -spark.sql.ansi.double_quoted_identifiers true +spark.sql.ansi.doubleQuotedIdentifiers true -- !query From e68a18a2ea5efcf95e8282af76968c42b4aeaad3 Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Mon, 10 Oct 2022 22:34:10 -0700 Subject: [PATCH 3/3] refactor tests --- .../double-quoted-identifiers-disabled.sql | 2 + .../double-quoted-identifiers-enabled.sql | 3 + .../inputs/ansi/double-quoted-identifiers.sql | 2 - .../inputs/double-quoted-identifiers.sql | 50 --- ...double-quoted-identifiers-disabled.sql.out | 369 ++++++++++++++++++ ...double-quoted-identifiers-enabled.sql.out} | 315 +-------------- .../results/double-quoted-identifiers.sql.out | 273 ------------- 7 files changed, 395 insertions(+), 619 deletions(-) create mode 100644 sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers-disabled.sql create mode 100644 sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers-enabled.sql delete mode 100644 sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers.sql create mode 100644 sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers-disabled.sql.out rename sql/core/src/test/resources/sql-tests/results/ansi/{double-quoted-identifiers.sql.out => double-quoted-identifiers-enabled.sql.out} (54%) diff --git a/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers-disabled.sql b/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers-disabled.sql new file mode 100644 index 0000000000000..b8ff8cdb81376 --- /dev/null +++ b/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers-disabled.sql @@ -0,0 +1,2 @@ +--SET spark.sql.ansi.doubleQuotedIdentifiers=false +--IMPORT double-quoted-identifiers.sql diff --git a/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers-enabled.sql b/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers-enabled.sql new file mode 100644 index 0000000000000..9547d011c76ea --- /dev/null +++ b/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers-enabled.sql @@ -0,0 +1,3 @@ +--SET spark.sql.ansi.doubleQuotedIdentifiers=true +--IMPORT double-quoted-identifiers.sql + diff --git a/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers.sql b/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers.sql deleted file mode 100644 index a20694d96040c..0000000000000 --- a/sql/core/src/test/resources/sql-tests/inputs/ansi/double-quoted-identifiers.sql +++ /dev/null @@ -1,2 +0,0 @@ ---IMPORT double-quoted-identifiers.sql - diff --git a/sql/core/src/test/resources/sql-tests/inputs/double-quoted-identifiers.sql b/sql/core/src/test/resources/sql-tests/inputs/double-quoted-identifiers.sql index f83fa5ca458f6..ffb52b403346f 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/double-quoted-identifiers.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/double-quoted-identifiers.sql @@ -1,8 +1,3 @@ --- test cases for spark.sql.ansi.double_quoted_identifiers - --- Base line -SET spark.sql.ansi.doubleQuotedIdentifiers = false; - -- All these should error out in the parser SELECT 1 FROM "not_exist"; @@ -45,51 +40,6 @@ DROP VIEW v; SELECT INTERVAL "1" YEAR; --- Now turn on the config. -SET spark.sql.ansi.doubleQuotedIdentifiers = true; - --- All these should error out in analysis now -SELECT 1 FROM "not_exist"; - -USE SCHEMA "not_exist"; - -ALTER TABLE "not_exist" ADD COLUMN not_exist int; - -ALTER TABLE not_exist ADD COLUMN "not_exist" int; - -SELECT 1 AS "not_exist" FROM not_exist; - -SELECT 1 FROM not_exist AS X("hello"); - -SELECT "not_exist"(); - -SELECT "not_exist".not_exist(); - -SELECT "hello"; - --- Back ticks still work -SELECT 1 FROM `hello`; - -USE SCHEMA `not_exist`; - -ALTER TABLE `not_exist` ADD COLUMN not_exist int; - -ALTER TABLE not_exist ADD COLUMN `not_exist` int; - -SELECT 1 AS `not_exist` FROM `not_exist`; - -SELECT 1 FROM not_exist AS X(`hello`); - -SELECT `not_exist`(); - -SELECT `not_exist`.not_exist(); - --- These fail in the parser now -CREATE TEMPORARY VIEW v(c1 COMMENT "hello") AS SELECT 1; -DROP VIEW v; - -SELECT INTERVAL "1" YEAR; - -- Single ticks still work SELECT 'hello'; diff --git a/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers-disabled.sql.out b/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers-disabled.sql.out new file mode 100644 index 0000000000000..57fad89d57c94 --- /dev/null +++ b/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers-disabled.sql.out @@ -0,0 +1,369 @@ +-- Automatically generated by SQLQueryTestSuite +-- !query +SELECT 1 FROM "not_exist" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +USE SCHEMA "not_exist" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +ALTER TABLE "not_exist" ADD COLUMN not_exist int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +ALTER TABLE not_exist ADD COLUMN "not_exist" int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +SELECT 1 AS "not_exist" FROM not_exist +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +SELECT 1 FROM not_exist AS X("hello") +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"hello\"'", + "hint" : "" + } +} + + +-- !query +SELECT "not_exist"() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +SELECT "not_exist".not_exist() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"not_exist\"'", + "hint" : "" + } +} + + +-- !query +SELECT 1 FROM `hello` +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: hello; line 1 pos 14 + + +-- !query +USE SCHEMA `not_exist` +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException +Database 'not_exist' not found + + +-- !query +ALTER TABLE `not_exist` ADD COLUMN not_exist int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table not found: not_exist; line 1 pos 12 + + +-- !query +ALTER TABLE not_exist ADD COLUMN `not_exist` int +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table not found: not_exist; line 1 pos 12 + + +-- !query +SELECT 1 AS `not_exist` FROM `not_exist` +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: not_exist; line 1 pos 29 + + +-- !query +SELECT 1 FROM not_exist AS X(`hello`) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +Table or view not found: not_exist; line 1 pos 14 + + +-- !query +SELECT `not_exist`() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +{ + "errorClass" : "_LEGACY_ERROR_TEMP_1242", + "messageParameters" : { + "fullName" : "spark_catalog.default.not_exist", + "rawName" : "not_exist" + }, + "queryContext" : [ { + "objectType" : "", + "objectName" : "", + "startIndex" : 8, + "stopIndex" : 20, + "fragment" : "`not_exist`()" + } ] +} + + +-- !query +SELECT `not_exist`.not_exist() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +{ + "errorClass" : "_LEGACY_ERROR_TEMP_1243", + "messageParameters" : { + "rawName" : "not_exist.not_exist" + }, + "queryContext" : [ { + "objectType" : "", + "objectName" : "", + "startIndex" : 8, + "stopIndex" : 30, + "fragment" : "`not_exist`.not_exist()" + } ] +} + + +-- !query +SELECT "hello" +-- !query schema +struct +-- !query output +hello + + +-- !query +CREATE TEMPORARY VIEW v(c1 COMMENT "hello") AS SELECT 1 +-- !query schema +struct<> +-- !query output + + + +-- !query +DROP VIEW v +-- !query schema +struct<> +-- !query output + + + +-- !query +SELECT INTERVAL "1" YEAR +-- !query schema +struct +-- !query output +1-0 + + +-- !query +SELECT 'hello' +-- !query schema +struct +-- !query output +hello + + +-- !query +CREATE TEMPORARY VIEW v(c1 COMMENT 'hello') AS SELECT 1 +-- !query schema +struct<> +-- !query output + + + +-- !query +DROP VIEW v +-- !query schema +struct<> +-- !query output + + + +-- !query +SELECT INTERVAL '1' YEAR +-- !query schema +struct +-- !query output +1-0 + + +-- !query +CREATE SCHEMA "myschema" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"myschema\"'", + "hint" : "" + } +} + + +-- !query +CREATE TEMPORARY VIEW "myview"("c1") AS + WITH "v"("a") AS (SELECT 1) SELECT "a" FROM "v" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"myview\"'", + "hint" : "" + } +} + + +-- !query +SELECT "a1" AS "a2" FROM "myview" AS "atab"("a1") +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"a2\"'", + "hint" : "" + } +} + + +-- !query +DROP TABLE "myview" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"myview\"'", + "hint" : "" + } +} + + +-- !query +DROP SCHEMA "myschema" +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +{ + "errorClass" : "PARSE_SYNTAX_ERROR", + "sqlState" : "42000", + "messageParameters" : { + "error" : "'\"myschema\"'", + "hint" : "" + } +} diff --git a/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out b/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers-enabled.sql.out similarity index 54% rename from sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out rename to sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers-enabled.sql.out index 78dc3c5d69ec0..fb34e9a16197a 100644 --- a/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/ansi/double-quoted-identifiers-enabled.sql.out @@ -1,151 +1,15 @@ -- Automatically generated by SQLQueryTestSuite --- !query -SET spark.sql.ansi.doubleQuotedIdentifiers = false --- !query schema -struct --- !query output -spark.sql.ansi.doubleQuotedIdentifiers false - - -- !query SELECT 1 FROM "not_exist" -- !query schema struct<> -- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -USE SCHEMA "not_exist" --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -ALTER TABLE "not_exist" ADD COLUMN not_exist int --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -ALTER TABLE not_exist ADD COLUMN "not_exist" int --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -SELECT 1 AS "not_exist" FROM not_exist --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -SELECT 1 FROM not_exist AS X("hello") --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"hello\"'", - "hint" : "" - } -} - - --- !query -SELECT "not_exist"() --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -SELECT "not_exist".not_exist() --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -SELECT 1 FROM `hello` --- !query schema -struct<> --- !query output org.apache.spark.sql.AnalysisException -Table or view not found: hello; line 1 pos 14 +Table or view not found: not_exist; line 1 pos 14 -- !query -USE SCHEMA `not_exist` +USE SCHEMA "not_exist" -- !query schema struct<> -- !query output @@ -154,7 +18,7 @@ Database 'not_exist' not found -- !query -ALTER TABLE `not_exist` ADD COLUMN not_exist int +ALTER TABLE "not_exist" ADD COLUMN not_exist int -- !query schema struct<> -- !query output @@ -163,7 +27,7 @@ Table not found: not_exist; line 1 pos 12 -- !query -ALTER TABLE not_exist ADD COLUMN `not_exist` int +ALTER TABLE not_exist ADD COLUMN "not_exist" int -- !query schema struct<> -- !query output @@ -172,7 +36,7 @@ Table not found: not_exist; line 1 pos 12 -- !query -SELECT 1 AS `not_exist` FROM `not_exist` +SELECT 1 AS "not_exist" FROM not_exist -- !query schema struct<> -- !query output @@ -181,7 +45,7 @@ Table or view not found: not_exist; line 1 pos 29 -- !query -SELECT 1 FROM not_exist AS X(`hello`) +SELECT 1 FROM not_exist AS X("hello") -- !query schema struct<> -- !query output @@ -190,7 +54,7 @@ Table or view not found: not_exist; line 1 pos 14 -- !query -SELECT `not_exist`() +SELECT "not_exist"() -- !query schema struct<> -- !query output @@ -206,13 +70,13 @@ org.apache.spark.sql.AnalysisException "objectName" : "", "startIndex" : 8, "stopIndex" : 20, - "fragment" : "`not_exist`()" + "fragment" : "\"not_exist\"()" } ] } -- !query -SELECT `not_exist`.not_exist() +SELECT "not_exist".not_exist() -- !query schema struct<> -- !query output @@ -227,62 +91,22 @@ org.apache.spark.sql.AnalysisException "objectName" : "", "startIndex" : 8, "stopIndex" : 30, - "fragment" : "`not_exist`.not_exist()" + "fragment" : "\"not_exist\".not_exist()" } ] } -- !query -SELECT "hello" --- !query schema -struct --- !query output -hello - - --- !query -CREATE TEMPORARY VIEW v(c1 COMMENT "hello") AS SELECT 1 --- !query schema -struct<> --- !query output - - - --- !query -DROP VIEW v --- !query schema -struct<> --- !query output - - - --- !query -SELECT INTERVAL "1" YEAR --- !query schema -struct --- !query output -1-0 - - --- !query -SET spark.sql.ansi.doubleQuotedIdentifiers = true --- !query schema -struct --- !query output -spark.sql.ansi.doubleQuotedIdentifiers true - - --- !query -SELECT 1 FROM "not_exist" +SELECT 1 FROM `hello` -- !query schema struct<> -- !query output org.apache.spark.sql.AnalysisException -Table or view not found: not_exist; line 1 pos 14 +Table or view not found: hello; line 1 pos 14 -- !query -USE SCHEMA "not_exist" +USE SCHEMA `not_exist` -- !query schema struct<> -- !query output @@ -291,7 +115,7 @@ Database 'not_exist' not found -- !query -ALTER TABLE "not_exist" ADD COLUMN not_exist int +ALTER TABLE `not_exist` ADD COLUMN not_exist int -- !query schema struct<> -- !query output @@ -300,7 +124,7 @@ Table not found: not_exist; line 1 pos 12 -- !query -ALTER TABLE not_exist ADD COLUMN "not_exist" int +ALTER TABLE not_exist ADD COLUMN `not_exist` int -- !query schema struct<> -- !query output @@ -309,7 +133,7 @@ Table not found: not_exist; line 1 pos 12 -- !query -SELECT 1 AS "not_exist" FROM not_exist +SELECT 1 AS `not_exist` FROM `not_exist` -- !query schema struct<> -- !query output @@ -318,7 +142,7 @@ Table or view not found: not_exist; line 1 pos 29 -- !query -SELECT 1 FROM not_exist AS X("hello") +SELECT 1 FROM not_exist AS X(`hello`) -- !query schema struct<> -- !query output @@ -327,7 +151,7 @@ Table or view not found: not_exist; line 1 pos 14 -- !query -SELECT "not_exist"() +SELECT `not_exist`() -- !query schema struct<> -- !query output @@ -343,13 +167,13 @@ org.apache.spark.sql.AnalysisException "objectName" : "", "startIndex" : 8, "stopIndex" : 20, - "fragment" : "\"not_exist\"()" + "fragment" : "`not_exist`()" } ] } -- !query -SELECT "not_exist".not_exist() +SELECT `not_exist`.not_exist() -- !query schema struct<> -- !query output @@ -364,7 +188,7 @@ org.apache.spark.sql.AnalysisException "objectName" : "", "startIndex" : 8, "stopIndex" : 30, - "fragment" : "\"not_exist\".not_exist()" + "fragment" : "`not_exist`.not_exist()" } ] } @@ -391,103 +215,6 @@ org.apache.spark.sql.AnalysisException } --- !query -SELECT 1 FROM `hello` --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table or view not found: hello; line 1 pos 14 - - --- !query -USE SCHEMA `not_exist` --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException -Database 'not_exist' not found - - --- !query -ALTER TABLE `not_exist` ADD COLUMN not_exist int --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table not found: not_exist; line 1 pos 12 - - --- !query -ALTER TABLE not_exist ADD COLUMN `not_exist` int --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table not found: not_exist; line 1 pos 12 - - --- !query -SELECT 1 AS `not_exist` FROM `not_exist` --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table or view not found: not_exist; line 1 pos 29 - - --- !query -SELECT 1 FROM not_exist AS X(`hello`) --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table or view not found: not_exist; line 1 pos 14 - - --- !query -SELECT `not_exist`() --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -{ - "errorClass" : "_LEGACY_ERROR_TEMP_1242", - "messageParameters" : { - "fullName" : "spark_catalog.default.not_exist", - "rawName" : "not_exist" - }, - "queryContext" : [ { - "objectType" : "", - "objectName" : "", - "startIndex" : 8, - "stopIndex" : 20, - "fragment" : "`not_exist`()" - } ] -} - - --- !query -SELECT `not_exist`.not_exist() --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -{ - "errorClass" : "_LEGACY_ERROR_TEMP_1243", - "messageParameters" : { - "rawName" : "not_exist.not_exist" - }, - "queryContext" : [ { - "objectType" : "", - "objectName" : "", - "startIndex" : 8, - "stopIndex" : 30, - "fragment" : "`not_exist`.not_exist()" - } ] -} - - -- !query CREATE TEMPORARY VIEW v(c1 COMMENT "hello") AS SELECT 1 -- !query schema diff --git a/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out b/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out index 2d1f192efffa0..57fad89d57c94 100644 --- a/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/double-quoted-identifiers.sql.out @@ -1,12 +1,4 @@ -- Automatically generated by SQLQueryTestSuite --- !query -SET spark.sql.ansi.doubleQuotedIdentifiers = false --- !query schema -struct --- !query output -spark.sql.ansi.doubleQuotedIdentifiers false - - -- !query SELECT 1 FROM "not_exist" -- !query schema @@ -256,271 +248,6 @@ struct<> --- !query -SELECT INTERVAL "1" YEAR --- !query schema -struct --- !query output -1-0 - - --- !query -SET spark.sql.ansi.doubleQuotedIdentifiers = true --- !query schema -struct --- !query output -spark.sql.ansi.doubleQuotedIdentifiers true - - --- !query -SELECT 1 FROM "not_exist" --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -USE SCHEMA "not_exist" --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -ALTER TABLE "not_exist" ADD COLUMN not_exist int --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -ALTER TABLE not_exist ADD COLUMN "not_exist" int --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -SELECT 1 AS "not_exist" FROM not_exist --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -SELECT 1 FROM not_exist AS X("hello") --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"hello\"'", - "hint" : "" - } -} - - --- !query -SELECT "not_exist"() --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -SELECT "not_exist".not_exist() --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.parser.ParseException -{ - "errorClass" : "PARSE_SYNTAX_ERROR", - "sqlState" : "42000", - "messageParameters" : { - "error" : "'\"not_exist\"'", - "hint" : "" - } -} - - --- !query -SELECT "hello" --- !query schema -struct --- !query output -hello - - --- !query -SELECT 1 FROM `hello` --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table or view not found: hello; line 1 pos 14 - - --- !query -USE SCHEMA `not_exist` --- !query schema -struct<> --- !query output -org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException -Database 'not_exist' not found - - --- !query -ALTER TABLE `not_exist` ADD COLUMN not_exist int --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table not found: not_exist; line 1 pos 12 - - --- !query -ALTER TABLE not_exist ADD COLUMN `not_exist` int --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table not found: not_exist; line 1 pos 12 - - --- !query -SELECT 1 AS `not_exist` FROM `not_exist` --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table or view not found: not_exist; line 1 pos 29 - - --- !query -SELECT 1 FROM not_exist AS X(`hello`) --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -Table or view not found: not_exist; line 1 pos 14 - - --- !query -SELECT `not_exist`() --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -{ - "errorClass" : "_LEGACY_ERROR_TEMP_1242", - "messageParameters" : { - "fullName" : "spark_catalog.default.not_exist", - "rawName" : "not_exist" - }, - "queryContext" : [ { - "objectType" : "", - "objectName" : "", - "startIndex" : 8, - "stopIndex" : 20, - "fragment" : "`not_exist`()" - } ] -} - - --- !query -SELECT `not_exist`.not_exist() --- !query schema -struct<> --- !query output -org.apache.spark.sql.AnalysisException -{ - "errorClass" : "_LEGACY_ERROR_TEMP_1243", - "messageParameters" : { - "rawName" : "not_exist.not_exist" - }, - "queryContext" : [ { - "objectType" : "", - "objectName" : "", - "startIndex" : 8, - "stopIndex" : 30, - "fragment" : "`not_exist`.not_exist()" - } ] -} - - --- !query -CREATE TEMPORARY VIEW v(c1 COMMENT "hello") AS SELECT 1 --- !query schema -struct<> --- !query output - - - --- !query -DROP VIEW v --- !query schema -struct<> --- !query output - - - -- !query SELECT INTERVAL "1" YEAR -- !query schema