You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "MaxGekk (via GitHub)" <gi...@apache.org> on 2023/05/17 07:51:54 UTC

[GitHub] [spark] MaxGekk commented on a diff in pull request #41191: [SPARK-43529][SQL] Support general expressions as OPTIONS values in the parser

MaxGekk commented on code in PR #41191:
URL: https://github.com/apache/spark/pull/41191#discussion_r1196089093


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -3187,7 +3187,24 @@ class AstBuilder extends SqlBaseParserBaseVisitor[AnyRef] with SQLConfHelper wit
       ctx: PropertyListContext): Map[String, String] = withOrigin(ctx) {
     val properties = ctx.property.asScala.map { property =>
       val key = visitPropertyKey(property.key)
-      val value = visitPropertyValue(property.value)
+      // A property value can be String, Integer, Boolean or Decimal. Here we extract the property
+      // value based on whether its a string, integer, boolean or decimal literal.
+      val value =
+      if (property.value == null) {
+        null
+      } else {
+        expression(property.value) match {
+          case Literal(str: UTF8String, StringType) => str.toString
+          case Literal(_, BooleanType) => property.value.getText.toLowerCase(Locale.ROOT)
+          case Literal(_, IntegerType | DecimalType()) => property.value.getText

Review Comment:
   Are there any reasons to support only literals but not foldable expressions?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org