cloud-fan commented on a change in pull request #27197: [SPARK-30507][SQL] 
TableCalalog reserved properties shoudn't be changed via options or tblpropeties
URL: https://github.com/apache/spark/pull/27197#discussion_r366870614
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ##########
 @@ -2669,6 +2667,47 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
         ctx.EXTENDED != null)
     }
 
+  /**
+   * When resolving TBLPROPERTIES, please let the `location` be None and 
`isOptionClause` be false
+   */
+  private def cleanTableProperties(
+      ctx: ParserRuleContext,
+      properties: Map[String, String],
+      location: Option[String] = None,
+      isOptionClause: Boolean = false): Map[String, String] = withOrigin(ctx) {
+    import TableCatalog._
+    val legacyOn = conf.getConf(SQLConf.LEGACY_PROPERTY_NON_RESERVED)
+    var pathDefined = false
+    val newProps = properties.filter {
+      case (PROP_PROVIDER, _) if !legacyOn =>
+        throw new ParseException(s"$PROP_PROVIDER is a reserved table 
property, please use" +
+          s" the USING clause to specify it.", ctx)
+      case (PROP_PROVIDER, _) => false
+      case (PROP_LOCATION, _) if !legacyOn =>
+        throw new ParseException(s"$PROP_LOCATION is a reserved table 
property, please use" +
+          s" the LOCATION clause to specify it.", ctx)
+      case (PROP_LOCATION, _) => false
+      case (path, _) if path.equalsIgnoreCase("path") && location.nonEmpty =>
+        throw new ParseException(s"LOCATION and 'path' in OPTIONS are both 
used to indicate the" +
+          s" custom table path, you can only specify one of them.", ctx)
+      case (path, _) if path.equalsIgnoreCase("path") && isOptionClause =>
+        if (pathDefined) {
+          throw new ParseException("Duplicated 'path' keys found in the 
OPTIONS clause", ctx)
+        } else {
+          pathDefined = true
+          true
 
 Review comment:
   we can keep the path instead of just a boolean flag `pathDefined`, then we 
can return false here and filter them out.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to