nsivarajan commented on code in PR #63974:
URL: https://github.com/apache/doris/pull/63974#discussion_r3581258685


##########
fe/fe-core/src/main/java/org/apache/doris/statistics/query/QueryStatsRecorder.java:
##########
@@ -308,14 +373,38 @@ private static void walkPlan(Plan plan,
                 }
             }
         }
-        // filterHit for JOIN ON conditions (hash equality and non-equality 
predicates).
+        // filterHit for all JOIN ON conditions; mark conjuncts are a separate 
field not included
+        // in hashJoinConjuncts or otherJoinConjuncts (IN/EXISTS subquery 
semi-join predicates).
         if (plan instanceof AbstractPhysicalJoin) {
             AbstractPhysicalJoin<?, ?> join = (AbstractPhysicalJoin<?, ?>) 
plan;
             for (Expression conjunct : join.getHashJoinConjuncts()) {
-                recordInputSlotsAsFilterHit(conjunct, exprIdToScan, 
exprIdToColName, deltas);
+                recordInputSlotsAsFilterHit(conjunct, exprIdToScan, 
exprIdToColName, deltas, aggOutputToInputSlots);
             }
             for (Expression conjunct : join.getOtherJoinConjuncts()) {
-                recordInputSlotsAsFilterHit(conjunct, exprIdToScan, 
exprIdToColName, deltas);
+                recordInputSlotsAsFilterHit(conjunct, exprIdToScan, 
exprIdToColName, deltas, aggOutputToInputSlots);
+            }
+            for (Expression conjunct : join.getMarkJoinConjuncts()) {
+                recordInputSlotsAsFilterHit(conjunct, exprIdToScan, 
exprIdToColName, deltas, aggOutputToInputSlots);
+            }
+        }
+        // UNION / INTERSECT / EXCEPT: record queryHit for each child's 
contributing columns.
+        if (plan instanceof PhysicalSetOperation) {
+            recordSetOpChildrenOutputs(
+                    ((PhysicalSetOperation) plan).getRegularChildrenOutputs(),
+                    exprIdToScan, exprIdToColName, deltas);
+        }
+        // PhysicalRecursiveUnion extends PhysicalBinary (not 
PhysicalSetOperation); handle its
+        // getRegularChildrenOutputs() explicitly. Recursive-case 
(WorkTableReference) slots skipped.
+        if (plan instanceof PhysicalRecursiveUnion) {
+            recordSetOpChildrenOutputs(
+                    ((PhysicalRecursiveUnion<?, ?>) 
plan).getRegularChildrenOutputs(),
+                    exprIdToScan, exprIdToColName, deltas);
+        }
+        // LATERAL VIEW / EXPLODE: record queryHit for the generator input 
columns (e.g. the
+        // array column passed to EXPLODE). Generated output slots are 
synthetic and skipped.
+        if (plan instanceof PhysicalGenerate) {

Review Comment:
   Fixed. Added a loop over generate.getConjuncts() calling 
recordInputSlotsAsFilterHit(conjunct, exprIdToScan, exprIdToColName, deltas, 
aggOutputToInputSlots) alongside the existing generator-input queryHit loop 
.same helper already used for PhysicalFilter/AbstractPhysicalJoin, so no new 
logic, just wiring it up for this node too.
   
   Added a regression case for the table-function join ON predicate:
   
   ```sql
   select s.val from stats_table left join lateral unnest(split(k7, ',')) 
s(val) on k7 != ''
   ```
   
   asserting filterHit on k7. Note the predicate has to reference a real column 
(k7), not the generator's own synthetic output (val) — an ON clause like s.val 
= 'x' only compares the exploded array element itself, which has no scan column 
to attribute back to. Caught that the hard way in my first version of this test.



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