kasakrisz commented on code in PR #4748:
URL: https://github.com/apache/hive/pull/4748#discussion_r1347436089


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java:
##########
@@ -287,6 +299,25 @@ private void reparseAndSuperAnalyze(ASTNode tree, Table 
mTable, ASTNode tabNameN
     }
   }
 
+  private void checkAndPerformStorageMetadataUpdate(Table table, 
HiveStorageHandler storageHandler) {
+    if (deleting() && storageHandler != null) {
+      Map<String, TableScanOperator> topOps = getParseContext().getTopOps();
+      if (topOps.containsKey(table.getTableName())) {
+        ExprNodeGenericFuncDesc hiveFilter = getParseContext().getTopOps()
+                .get(table.getTableName()).getConf().getFilterExpr();
+        if (hiveFilter != null && 
ConvertAstToSearchArg.isCompleteConversion(ctx.getConf(), hiveFilter)) {
+          SearchArgument sarg = ConvertAstToSearchArg.create(ctx.getConf(), 
hiveFilter);
+          if (storageHandler.canPerformMetadataDelete(table, sarg)) {

Review Comment:
   Could you please invert these if statements? None of them has else branch 
and it would help getting rid of lots of indentation.



##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/misc/metadata/StorageMetadataUpdateOperation.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.hadoop.hive.ql.ddl.table.misc.metadata;
+
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.ql.Context;
+import org.apache.hadoop.hive.ql.ddl.DDLOperation;
+import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.io.sarg.ConvertAstToSearchArg;
+import org.apache.hadoop.hive.ql.io.sarg.SearchArgument;
+import org.apache.hadoop.hive.ql.metadata.Table;
+import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
+
+public class StorageMetadataUpdateOperation extends 
DDLOperation<StorageMetadataUpdateDesc> {
+
+  public StorageMetadataUpdateOperation(DDLOperationContext context, 
StorageMetadataUpdateDesc desc) {
+    super(context, desc);
+  }
+
+  @Override
+  public int execute() throws Exception {
+    TableName tableName = desc.getTableName();
+    ExprNodeGenericFuncDesc hiveFilter = desc.getHiveFilter();
+    SearchArgument sarg = ConvertAstToSearchArg.create(context.getConf(), 
hiveFilter);
+    Table table = context.getDb().getTable(tableName);
+    if (table.getStorageHandler() != null && 
table.getStorageHandler().supportsMetadataDelete()

Review Comment:
   What happens if StorageHandler does not support metadata delete? Is there 
any fallback logic to normal delete?



##########
ql/src/java/org/apache/hadoop/hive/ql/io/sarg/ConvertAstToSearchArg.java:
##########
@@ -552,6 +564,10 @@ private static SearchArgument 
getSearchArgumentFromExpression(Configuration conf
     }
   }
 
+  public static boolean isCompleteConversion(Configuration conf, 
ExprNodeGenericFuncDesc expression) {

Review Comment:
   Could you please add some unit tests to test this method:
   
https://github.com/apache/hive/blob/master/ql/src/test/org/apache/hadoop/hive/ql/io/sarg/TestConvertAstToSearchArg.java



##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/misc/metadata/StorageMetadataUpdateDesc.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.hadoop.hive.ql.ddl.table.misc.metadata;
+
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.ql.Context;
+import org.apache.hadoop.hive.ql.ddl.DDLDesc;
+import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
+
+public class StorageMetadataUpdateDesc implements DDLDesc {
+  private TableName tableName;
+  private ExprNodeGenericFuncDesc hiveFilter;
+  private Context.Operation operation;

Review Comment:
   nit. these can be final



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to