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

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

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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -3187,7 +3189,42 @@ 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)
+      // If the expression provided for the option value is a literal, use the string
+      // representation of the contents of the literal value provided here. Otherwise, if this
+      // expression is constant but non-literal, evaluate the expression and use its value instead.
+      val value = if (property.value == null) {
+        null
+      } else {
+        val parsed = expression(property.value)
+        def error: Throwable = {
+          new ParseException(
+            errorClass = "INVALID_SQL_SYNTAX",
+            messageParameters = Map(
+              "inputString" ->
+                s"option or property key $key is invalid; only constant expressions are supported"),
+            ctx)
+        }
+        val plan = try {
+          val analyzer: Analyzer = ResolveDefaultColumns.DefaultColumnAnalyzer

Review Comment:
   @dtenedor It's too hacky to use the analyzer within the parser.  Could you verify it in the analyzer?



-- 
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