c6109ba918
### What changes were proposed in this pull request? This PR modified the parser code to handle invalid usages of a SET/RESET command. For example; ``` SET spark.sql.ansi.enabled true ``` The above SQL command does not change the configuration value and it just tries to display the value of the configuration `spark.sql.ansi.enabled true`. This PR disallows using special characters including spaces in the configuration name and reports a user-friendly error instead. In the error message, it tells users a workaround to use quotes or a string literal if they still needs to specify a configuration with them. Before this PR: ``` scala> sql("SET spark.sql.ansi.enabled true").show(1, -1) +---------------------------+-----------+ |key |value | +---------------------------+-----------+ |spark.sql.ansi.enabled true|<undefined>| +---------------------------+-----------+ ``` After this PR: ``` scala> sql("SET spark.sql.ansi.enabled true") org.apache.spark.sql.catalyst.parser.ParseException: Expected format is 'SET', 'SET key', or 'SET key=value'. If you want to include special characters in key, please use quotes, e.g., SET `ke y`=value.(line 1, pos 0) == SQL == SET spark.sql.ansi.enabled true ^^^ ``` ### Why are the changes needed? For better user-friendly errors. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added tests in `SparkSqlParserSuite`. Closes #29146 from maropu/SPARK-32257. Lead-authored-by: Takeshi Yamamuro <yamamuro@apache.org> Co-authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> |
||
---|---|---|
.. | ||
main | ||
test |