MaxGekk commented on code in PR #36561:
URL: https://github.com/apache/spark/pull/36561#discussion_r875157818
##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryParsingErrorsSuite.scala:
##########
@@ -642,4 +642,92 @@ class QueryParsingErrorsSuite extends QueryTest with
QueryErrorsSuiteBase {
|^^^
|""".stripMargin)
}
+
+ test("UNSUPPORTED_FEATURE: cannot set reserved namespace property") {
+ val sql = "CREATE NAMESPACE IF NOT EXISTS a.b.c WITH PROPERTIES
('location'='/home/user/db')"
+ validateParsingError(
+ sqlText = sql,
+ errorClass = "UNSUPPORTED_FEATURE",
+ errorSubClass = Some("SET_NAMESPACE_PROPERTY"),
+ sqlState = "0A000",
+ message =
+ """The feature is not supported: location is a reserved namespace
property, """ +
+ """please use the LOCATION clause to specify it.(line 1, pos 0)""" +
+ s"""
+ |
+ |== SQL ==
+ |$sql
+ |^^^
+ |""".stripMargin)
+ }
+
+ test("UNSUPPORTED_FEATURE: cannot set reserved table property") {
+ val sql = "CREATE TABLE student (id INT, name STRING, age INT) " +
+ "USING PARQUET TBLPROPERTIES ('provider'='parquet')"
+ validateParsingError(
+ sqlText = sql,
+ errorClass = "UNSUPPORTED_FEATURE",
+ errorSubClass = Some("SET_TABLE_PROPERTY"),
+ sqlState = "0A000",
+ message =
+ """The feature is not supported: provider is a reserved table
property, """ +
+ """please use the USING clause to specify it.(line 1, pos 66)""" +
+ s"""
+ |
+ |== SQL ==
+ |$sql
+
|------------------------------------------------------------------^^^
+ |""".stripMargin)
+ }
+
+ test("INVALID_PROPERTY_KEY: invalid property key for set quoted
configuration") {
+ val sql = "set =`value`"
+ validateParsingError(
+ sqlText = sql,
+ errorClass = "INVALID_PROPERTY_KEY",
+ sqlState = null,
+ message =
+ s"""'' is an invalid property key, please use quotes, e.g. SET
``=`value`(line 1, pos 0)
+ |
+ |== SQL ==
+ |$sql
+ |^^^
+ |""".stripMargin)
+ }
+
+ test("INVALID_PROPERTY_VALUE: invalid property value for set quoted
configuration") {
+ val sql = "set `key`=1;2;;"
+ validateParsingError(
+ sqlText = sql,
+ errorClass = "INVALID_PROPERTY_VALUE",
+ sqlState = null,
+ message =
+ """'1;2;;' is an invalid property value, please use quotes, """ +
Review Comment:
We should use double quotes for configs and their values, see
https://github.com/apache/spark/pull/36335 and
https://github.com/apache/spark/pull/36579.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala:
##########
@@ -380,14 +390,16 @@ object QueryParsingErrors extends QueryErrorsBase {
def invalidPropertyKeyForSetQuotedConfigurationError(
keyCandidate: String, valueStr: String, ctx: ParserRuleContext):
Throwable = {
- new ParseException(s"'$keyCandidate' is an invalid property key, please " +
- s"use quotes, e.g. SET `$keyCandidate`=`$valueStr`", ctx)
+ new ParseException(errorClass = "INVALID_PROPERTY_KEY",
+ messageParameters = Array(keyCandidate, keyCandidate, valueStr),
Review Comment:
Wrap keyCandidate by toSQLConf(), please.
##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryParsingErrorsSuite.scala:
##########
@@ -642,4 +642,92 @@ class QueryParsingErrorsSuite extends QueryTest with
QueryErrorsSuiteBase {
|^^^
|""".stripMargin)
}
+
+ test("UNSUPPORTED_FEATURE: cannot set reserved namespace property") {
+ val sql = "CREATE NAMESPACE IF NOT EXISTS a.b.c WITH PROPERTIES
('location'='/home/user/db')"
+ validateParsingError(
+ sqlText = sql,
+ errorClass = "UNSUPPORTED_FEATURE",
+ errorSubClass = Some("SET_NAMESPACE_PROPERTY"),
+ sqlState = "0A000",
+ message =
+ """The feature is not supported: location is a reserved namespace
property, """ +
+ """please use the LOCATION clause to specify it.(line 1, pos 0)""" +
+ s"""
+ |
+ |== SQL ==
+ |$sql
+ |^^^
+ |""".stripMargin)
+ }
+
+ test("UNSUPPORTED_FEATURE: cannot set reserved table property") {
+ val sql = "CREATE TABLE student (id INT, name STRING, age INT) " +
+ "USING PARQUET TBLPROPERTIES ('provider'='parquet')"
+ validateParsingError(
+ sqlText = sql,
+ errorClass = "UNSUPPORTED_FEATURE",
+ errorSubClass = Some("SET_TABLE_PROPERTY"),
+ sqlState = "0A000",
+ message =
+ """The feature is not supported: provider is a reserved table
property, """ +
+ """please use the USING clause to specify it.(line 1, pos 66)""" +
+ s"""
+ |
+ |== SQL ==
+ |$sql
+
|------------------------------------------------------------------^^^
+ |""".stripMargin)
+ }
+
+ test("INVALID_PROPERTY_KEY: invalid property key for set quoted
configuration") {
+ val sql = "set =`value`"
+ validateParsingError(
+ sqlText = sql,
+ errorClass = "INVALID_PROPERTY_KEY",
+ sqlState = null,
+ message =
+ s"""'' is an invalid property key, please use quotes, e.g. SET
``=`value`(line 1, pos 0)
+ |
+ |== SQL ==
+ |$sql
+ |^^^
+ |""".stripMargin)
+ }
+
+ test("INVALID_PROPERTY_VALUE: invalid property value for set quoted
configuration") {
+ val sql = "set `key`=1;2;;"
+ validateParsingError(
+ sqlText = sql,
+ errorClass = "INVALID_PROPERTY_VALUE",
+ sqlState = null,
+ message =
+ """'1;2;;' is an invalid property value, please use quotes, """ +
+ """e.g. SET `key`=`1;2;;`(line 1, pos 0)""" +
+ s"""
+ |
+ |== SQL ==
+ |$sql
+ |^^^
+ |""".stripMargin)
+ }
+
+ test("UNSUPPORTED_FEATURE: cannot set Properties and DbProperties at the
same time") {
+ val sql = "CREATE NAMESPACE IF NOT EXISTS a.b.c WITH PROPERTIES ('a'='a',
'b'='b', 'c'='c') " +
+ "WITH DBPROPERTIES('a'='a', 'b'='b', 'c'='c')"
+ validateParsingError(
+ sqlText = sql,
+ errorClass = "UNSUPPORTED_FEATURE",
+ errorSubClass = Some("SET_PROPERTIES_AND_DBPROPERTIES"),
+ sqlState = "0A000",
+ message =
+ """The feature is not supported: Either PROPERTIES or DBPROPERTIES """
+
Review Comment:
The message might confuse users:
not supported: ... is allowed.
If they are allowed, what is not supported?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]