dtenedor commented on code in PR #41191: URL: https://github.com/apache/spark/pull/41191#discussion_r1196991836
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala: ########## @@ -3187,7 +3189,37 @@ 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 + val analyzed = analyzer.execute(Project(Seq(Alias(parsed, "col")()), OneRowRelation())) + analyzer.checkAnalysis(analyzed) + ConstantFolding(analyzed) + } catch { + case _: AnalysisException => throw error + } + val result: Expression = plan.collectFirst { + case Project(Seq(a: Alias), OneRowRelation()) => a.child + }.get + result match { + case expr if expr.foldable => expr.eval().toString Review Comment: This is done. -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org