korowa commented on code in PR #12967:
URL: https://github.com/apache/datafusion/pull/12967#discussion_r1805129489
##########
datafusion/core/src/physical_optimizer/join_selection.rs:
##########
@@ -1287,6 +1289,29 @@ mod tests_statistical {
);
}
+ #[tokio::test]
+ async fn test_hash_join_swap_on_joins_with_projections() -> Result<()> {
+ let (big, small) = create_big_and_small();
+ let join = Arc::new(HashJoinExec::try_new(
+ Arc::clone(&big),
+ Arc::clone(&small),
+ vec![(
+ Arc::new(Column::new_with_schema("big_col", &big.schema())?),
+ Arc::new(Column::new_with_schema("small_col",
&small.schema())?),
+ )],
+ None,
+ &JoinType::Inner,
+ Some(vec![1]),
+ PartitionMode::Partitioned,
+ false,
+ )?);
+ let swapped = swap_hash_join(&join.clone(), PartitionMode::Partitioned)
+ .expect("swap_hash_join must support joins with projections");
+ assert_eq!(swapped.schema().fields.len(), 1);
+ assert_eq!(swapped.schema().fields[0].name(), "small_col");
+ Ok(())
+ }
+
Review Comment:
I suppose
[checking](https://github.com/apache/datafusion/pull/12967/files#diff-4708a2cf52c334b07864e98889c4b818126b846bd6551fe1a467be17f3d72f4cR1310)
that output schema of swapped join contains one field (which is what's been
passed as a projection arg) should be enough to assert that projection is not
lost after swap.
--
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]