cloud-fan commented on a change in pull request #32854:
URL: https://github.com/apache/spark/pull/32854#discussion_r649404199



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -3540,6 +3541,32 @@ class Analyzer(override val catalogManager: 
CatalogManager)
     }
   }
 
+  /**
+   * Rule to mostly resolve, normalize and rewrite column names based on case 
sensitivity
+   * for alter table commands.
+   */
+  object ResolveAlterTableCommands extends Rule[LogicalPlan] {
+    def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperatorsUp {
+      case a @ AlterTableDropColumns(r: ResolvedTable, colsToDrop) =>
+        val resolvedColsToDrop = colsToDrop.flatMap { col =>
+          resolveFieldNames(r.schema, col).orElse(Some(col))
+        }
+        a.copy(columnsToDrop = resolvedColsToDrop)
+    }
+
+    /**
+     * Returns the resolved field name if the field can be resolved, returns 
None if the column is
+     * not found. An error will be thrown in CheckAnalysis for columns that 
can't be resolved.

Review comment:
       Shall we fail here instead of in `CheckAnalysis`? Then we can avoid 
repeating the field name resolution logic in `CheckAnalysis`.




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



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

Reply via email to