UBarney commented on code in PR #19602:
URL: https://github.com/apache/datafusion/pull/19602#discussion_r2659556702
##########
datafusion/physical-plan/src/joins/hash_join/partitioned_hash_eval.rs:
##########
@@ -327,12 +329,24 @@ impl PhysicalExpr for HashTableLookupExpr {
Ok(false)
}
- fn evaluate(
- &self,
- batch: &arrow::record_batch::RecordBatch,
- ) -> Result<ColumnarValue> {
+ fn evaluate(&self, batch: &RecordBatch) -> Result<ColumnarValue> {
let num_rows = batch.num_rows();
+ // Optimization: if hash_expr is HashExpr, compute hashes directly
into callback
+ // to avoid redundant allocations and copies.
+ if let Some(hash_expr) =
self.hash_expr.as_any().downcast_ref::<HashExpr>() {
Review Comment:
That's a great point. Storing the inner expressions directly is indeed a
better approach, especially since the perfect hash join(which is being worked
on [in that separate pending
PR](https://github.com/apache/datafusion/pull/19411/changes#diff-c89cc13760a9e27ff7901446ad0982fab905ae292b57803b53f749603168c7b6R361-R362))
needs direct access to `on_columns` to identify the join key columns.
I initially considered changing `HashTableLookupExpr.hash_expr` to a
concrete `HashExpr` type (which I've actually already done in another [unmerged
PR for perfect hash
join](https://github.com/apache/datafusion/pull/19411/changes#diff-c89cc13760a9e27ff7901446ad0982fab905ae292b57803b53f749603168c7b6R222)).
However, I think that accessing the columns through `hash_expr.on_columns`
feels a bit clunky 😂.
--
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]