jayshrivastava commented on code in PR #23854:
URL: https://github.com/apache/datafusion/pull/23854#discussion_r3713726884


##########
datafusion/physical-plan/src/joins/hash_join/exec.rs:
##########
@@ -7035,8 +7047,7 @@ mod tests {
     }
 
     #[test]
-    fn test_partitioned_dynamic_filter_pushdown_rejects_range_partitioning() 
-> Result<()>
-    {
+    fn test_partitioned_dynamic_filter_pushdown_range_partitioning() -> 
Result<()> {

Review Comment:
   I think we're missing a test (or just a few lines in this one) to make sure 
that we still reject dynamic filtering for hash partitioned joins.



##########
datafusion/physical-plan/src/joins/hash_join/shared_bounds.rs:
##########
@@ -656,38 +661,99 @@ impl SharedBuildAccumulator {
                     }
                 }
 
-                let filter_expr = if has_canceled_unknown {
-                    let mut when_then_branches = empty_partition_ids
-                        .into_iter()
-                        .map(|partition_id| {
-                            (
-                                lit(ScalarValue::UInt64(Some(partition_id as 
u64))),
-                                lit(false),
-                            )
-                        })
-                        .collect::<Vec<_>>();
-                    when_then_branches.extend(real_branches);
-
-                    if when_then_branches.is_empty() {
-                        lit(true)
-                    } else {
-                        Arc::new(CaseExpr::try_new(
-                            Some(modulo_expr),
-                            when_then_branches,
-                            Some(lit(true)),
-                        )?) as Arc<dyn PhysicalExpr>
-                    }
-                } else if real_branches.is_empty() {
+                let filter_expr = if has_canceled_unknown
+                    && real_partition_ids.is_empty()
+                    && empty_partition_ids.is_empty()
+                {
+                    lit(true)
+                } else if !has_canceled_unknown && 
real_partition_ids.is_empty() {
                     lit(false)
-                } else if real_branches.len() == 1
+                } else if !has_canceled_unknown
+                    && real_partition_ids.len() == 1
                     && empty_partition_ids.len() + 1 == num_partitions
                 {
-                    Arc::clone(&real_branches[0].1)
+                    Arc::clone(&partition_filters[real_partition_ids[0]])
+                } else if let Some(range_partitioning) = 
&self.probe_range_partitioning {

Review Comment:
   Nice this is all much easier to read.



##########
datafusion/physical-plan/src/joins/hash_join/shared_bounds.rs:
##########
@@ -1017,6 +1087,56 @@ mod tests {
         );
     }
 
+    #[test]
+    fn partitioned_range_dynamic_filter_routes_with_searched_case() -> 
Result<()> {

Review Comment:
   It would be nice to see a more interesting test with null values, compound 
split points (ex. on null values), and `NULLS LAST` / `NULLS FIRST`



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