deniskuzZ commented on code in PR #6990:
URL: https://github.com/apache/hive/pull/6990#discussion_r4738212938


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -445,22 +451,23 @@ public boolean supportsExternalViewCatalog() {
   public DecomposedPredicate decomposePredicate(JobConf jobConf, Deserializer 
deserializer, ExprNodeDesc exprNodeDesc) {
     DecomposedPredicate predicate = new DecomposedPredicate();
     predicate.residualPredicate = (ExprNodeGenericFuncDesc) exprNodeDesc;
-    ExprNodeDesc pushedPredicate = exprNodeDesc.clone();
-
-    List<ExprNodeDesc> subExprNodes = pushedPredicate.getChildren();
-    Set<String> skipList =
-        Stream.of(FILE_PATH, PARTITION_SPEC_ID, PARTITION_HASH, PARTITION_NAME,
-                ROW_LINEAGE_ID, LAST_UPDATED_SEQUENCE_NUMBER)
-            .map(VirtualColumn::getName).collect(Collectors.toSet());
-
-    if (subExprNodes.removeIf(nodeDesc -> nodeDesc.getCols() != null &&
-          nodeDesc.getCols().stream().anyMatch(skipList::contains))) {
-      if (subExprNodes.size() == 1) {
-        pushedPredicate = (subExprNodes.getFirst() instanceof 
ExprNodeGenericFuncDesc) ?
-            subExprNodes.getFirst() : null;
-      } else if (subExprNodes.isEmpty()) {
-        pushedPredicate = null;
+    ExprNodeDesc pushedPredicate = null;
+
+    if (FunctionRegistry.isOpAnd(exprNodeDesc)) {
+      // Leaving out a conjunct only widens the pushed predicate; Hive still 
applies it through the residual predicate
+      pushedPredicate = exprNodeDesc.clone();
+      List<ExprNodeDesc> subExprNodes = pushedPredicate.getChildren();
+      if 
(subExprNodes.removeIf(HiveIcebergStorageHandler::readsNonPushableVirtualCol)) {
+        if (subExprNodes.size() == 1) {
+          pushedPredicate = (subExprNodes.getFirst() instanceof 
ExprNodeGenericFuncDesc) ?
+              subExprNodes.getFirst() : null;
+        } else if (subExprNodes.isEmpty()) {
+          pushedPredicate = null;
+        }
       }
+    } else if (!readsNonPushableVirtualCol(exprNodeDesc)) {
+      // Leaving out a disjunct or an operand would narrow the predicate and 
lose rows, so push all of it or nothing

Review Comment:
   Nit.
   For BETWEEN/IN, dropping an operand doesn't narrow the predicate, it makes 
it malformed. Maybe: 
   ````
   Leaving out a disjunct narrows the predicate and loses rows, and leaving out 
an operand makes it malformed, so push all of it or nothing.
   ````



-- 
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: [email protected]

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