cloud-fan commented on a change in pull request #29146:
URL: https://github.com/apache/spark/pull/29146#discussion_r464172446
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala
##########
@@ -66,17 +68,29 @@ class SparkSqlAstBuilder(conf: SQLConf) extends
AstBuilder(conf) {
* character in the raw string.
*/
override def visitSetConfiguration(ctx: SetConfigurationContext):
LogicalPlan = withOrigin(ctx) {
- // Construct the command.
- val raw = remainder(ctx.SET.getSymbol)
- val keyValueSeparatorIndex = raw.indexOf('=')
- if (keyValueSeparatorIndex >= 0) {
- val key = raw.substring(0, keyValueSeparatorIndex).trim
- val value = raw.substring(keyValueSeparatorIndex + 1).trim
- SetCommand(Some(key -> Option(value)))
- } else if (raw.nonEmpty) {
- SetCommand(Some(raw.trim -> None))
+ val configKeyValueDef = """([a-zA-Z_\d\\.:]+)\s*=(.*)""".r
+ remainder(ctx.SET.getSymbol).trim match {
+ case configKeyValueDef(key, value) =>
+ SetCommand(Some(key -> Option(value.trim)))
+ case configKeyDef(key) =>
+ SetCommand(Some(key -> None))
+ case s if s == "-v" =>
+ SetCommand(Some("-v" -> None))
+ case s if s.isEmpty =>
+ SetCommand(None)
+ case _ => throw new 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.", ctx)
+ }
+ }
+
+ override def visitSetQuotedConfiguration(ctx: SetQuotedConfigurationContext)
+ : LogicalPlan = withOrigin(ctx) {
+ val keyStr = ctx.quotedConfigKey().getText
+ if (ctx.value != null) {
+ SetCommand(Some(keyStr -> Option(remainder(ctx.EQ().getSymbol).trim)))
Review comment:
`(EQ value=.*)` we have an alias, can we use it here?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]