leesf commented on a change in pull request #2761:
URL: https://github.com/apache/hudi/pull/2761#discussion_r614777699



##########
File path: 
hudi-spark-datasource/hudi-spark3-extensions_2.12/src/main/scala/org/apache/spark/sql/catalyst/analysis/HudiOperationsCheck.scala
##########
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.catalyst.analysis
+
+import org.apache.hudi.execution.HudiSQLUtils
+import org.apache.spark.sql.{AnalysisException, SparkSession}
+import org.apache.spark.sql.catalyst.TableIdentifier
+import org.apache.spark.sql.catalyst.expressions.{Expression, InSubquery, 
Literal, Not}
+import org.apache.spark.sql.catalyst.merge.HudiMergeIntoTable
+import org.apache.spark.sql.catalyst.plans.logical.{DeleteFromTable, 
LogicalPlan}
+import org.apache.spark.sql.execution.command._
+
+/**
+  * check rule which can intercept unSupportOperation for hudi
+  */
+class HudiOperationsCheck(spark: SparkSession) extends (LogicalPlan => Unit) {
+  val catalog = spark.sessionState.catalog
+
+  override def apply(plan: LogicalPlan): Unit = {
+    plan foreach {
+      case AlterTableAddPartitionCommand(tableName, _, _) if 
(checkHudiTable(tableName)) =>
+        throw new AnalysisException("AlterTableAddPartitionCommand are not 
currently supported in HUDI")
+
+      case a: AlterTableDropPartitionCommand if (checkHudiTable(a.tableName)) 
=>
+        throw new AnalysisException("AlterTableDropPartitionCommand are not 
currently supported in HUDI")
+
+      case AlterTableChangeColumnCommand(tableName, _, _) if 
(checkHudiTable(tableName)) =>
+        throw new AnalysisException("AlterTableChangeColumnCommand are not 
currently supported in HUDI")
+
+      case AlterTableRenamePartitionCommand(tableName, _, _) if 
(checkHudiTable(tableName)) =>
+        throw new AnalysisException("AlterTableRenamePartitionCommand are not 
currently supported in HUDI")
+
+      case AlterTableRecoverPartitionsCommand(tableName, _) if 
(checkHudiTable(tableName)) =>
+        throw new AnalysisException("AlterTableRecoverPartitionsCommand are 
not currently supported in HUDI")
+
+      case AlterTableSetLocationCommand(tableName, _, _) if 
(checkHudiTable(tableName)) =>
+        throw new AnalysisException("AlterTableSetLocationCommand are not 
currently supported in HUDI")
+
+      case DeleteFromTable(target, Some(condition)) if 
(hasNullAwarePredicateWithNot(condition) && checkHudiTable(target)) =>
+        throw new AnalysisException("Null-aware predicate sub-squeries a are 
not currently supported for DELETE")
+
+      case HudiMergeIntoTable(target, _, _, _, noMatchedClauses, _) =>
+        noMatchedClauses.map { m =>
+          m.resolvedActions.foreach { action =>
+            if (action.targetColNameParts.size > 1) {
+              throw new AnalysisException(s"cannot insert nested values: 
${action.targetColNameParts.mkString("<") }")

Review comment:
       would you please describe why would not insert nested values?




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


Reply via email to