korowa commented on code in PR #12967:
URL: https://github.com/apache/datafusion/pull/12967#discussion_r1806776711
##########
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:
> these assertions do not know if a projection is added or not
Got it -- I was thinking only about embedded projection, and completely
missed that it's also worth checking that no additional projection is added on
top of join :+1:
--
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]