nuno-faria commented on code in PR #16716:
URL: https://github.com/apache/datafusion/pull/16716#discussion_r2194739991
##########
datafusion/physical-plan/src/joins/utils.rs:
##########
@@ -928,6 +929,55 @@ pub(crate) fn build_batch_from_indices(
Ok(RecordBatch::try_new(Arc::new(schema.clone()), columns)?)
}
+/// Returns a new [RecordBatch] resulting of a join where the build/left side
is empty.
+/// The resulting batch has [Schema] `schema`.
+pub(crate) fn build_batch_empty_build_side(
+ schema: &Schema,
+ build_batch: &RecordBatch,
+ probe_batch: &RecordBatch,
+ column_indices: &[ColumnIndex],
+ join_type: JoinType,
+) -> Result<RecordBatch> {
+ match join_type {
+ // these join types only return data if the left side is not empty, so
we return an
+ // empty RecordBatch
+ JoinType::Inner
Review Comment:
Cross joins with an empty relation already appear to run well in the
`CrossJoinExec` operator.
Here is the `CrossJoinExec` operator for `SELECT * FROM t1, t2`, where `t1`
has 100M rows and `t2` has none:
```
CrossJoinExec, metrics=[
output_rows=0,
elapsed_compute=351.714µs,
build_input_batches=0,
build_input_rows=0,
input_batches=0,
input_rows=0,
output_batches=0,
build_mem_used=0,
build_time=351.7µs,
join_time=12ns
]
```
--
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]