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


##########
iceberg/iceberg-handler/src/test/queries/positive/update_iceberg_cow_null_identity_partition.q:
##########
@@ -0,0 +1,33 @@
+-- SORT_QUERY_RESULTS
+

Review Comment:
   Please set 
   ```
   set hive.explain.user=false;
   ```
   That type of plan has more details.



##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/ColumnPrunerProcFactory.java:
##########
@@ -496,13 +497,43 @@ public Object process(Node nd, Stack<Node> stack, 
NodeProcessorCtx ctx,
       }
 
       cols = cols == null ? new ArrayList<FieldNode>() : cols;
+      cols = includePartitionColumnsFromScanFilters(scanOp, cols);
 
       cppCtx.getPrunedColLists().put((Operator<? extends OperatorDesc>) nd, 
cols);
       RowSchema inputRS = scanOp.getSchema();
       setupNeededColumns(scanOp, inputRS, cols);
 
       return null;
     }
+
+    /**
+     * For storage handlers with non-native partitions (Iceberg), keep 
identity partition source
+     * columns in the scan when they are referenced by pushed storage filters 
or child filters.
+     * Without this, filters above the scan can reference partition columns 
that were pruned from
+     * the read projection.
+     */
+    private static List<FieldNode> 
includePartitionColumnsFromScanFilters(TableScanOperator scanOp,
+        List<FieldNode> cols) {
+      TableScanDesc desc = scanOp.getConf();
+      Table table = desc.getTableMetadata();
+      if (table == null || !table.hasNonNativePartitionSupport()) {
+        return cols;
+      }
+
+      ExprNodeGenericFuncDesc filterExpr = desc.getFilterExpr();
+      if (filterExpr != null) {
+        cols = mergeFieldNodesWithDesc(cols, filterExpr);
+      }
+
+      if (scanOp.getChildOperators() != null) {
+        for (Operator<? extends OperatorDesc> child : 
scanOp.getChildOperators()) {
+          if (child instanceof FilterOperator filterOperator) {

Review Comment:
   Could you please verify whether `FilterOperator` is guaranteed to be a 
direct child of TS?



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