You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/09/23 04:26:13 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #34072: [SPARK-36680][CATALYST] Supports Dynamic Table Options for Spark SQL

HyukjinKwon commented on a change in pull request #34072:
URL: https://github.com/apache/spark/pull/34072#discussion_r714462840



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -1244,15 +1245,21 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with SQLConfHelper with Logg
    * }}}
    */
   override def visitTable(ctx: TableContext): LogicalPlan = withOrigin(ctx) {
-    UnresolvedRelation(visitMultipartIdentifier(ctx.multipartIdentifier))
+    val tableId = visitMultipartIdentifier(ctx.multipartIdentifier)
+    val options = Option(ctx.optionHint).map(hint =>
+      visitPropertyKeyValues(hint.options)).getOrElse(Map.empty)
+    UnresolvedRelation(tableId, new CaseInsensitiveStringMap(options.asJava))
   }
 
   /**
    * Create an aliased table reference. This is typically used in FROM clauses.
    */
   override def visitTableName(ctx: TableNameContext): LogicalPlan = withOrigin(ctx) {
     val tableId = visitMultipartIdentifier(ctx.multipartIdentifier)
-    val table = mayApplyAliasPlan(ctx.tableAlias, UnresolvedRelation(tableId))
+    val options = Option(ctx.optionHint).map(hint =>
+      visitPropertyKeyValues(hint.options)).getOrElse(Map.empty)
+    val table = mayApplyAliasPlan(ctx.tableAlias,
+      UnresolvedRelation(tableId, new CaseInsensitiveStringMap(options.asJava)))

Review comment:
       I don't think this works for the tables already defined with options because Spark respects the table properties defined in the table. This `options` is only for DSv2 for now. Can you add an e2e test, and see if it works? e.g.) create a table view and set the option.




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