@@ -240,9 +240,6 @@ pub enum LogicalPlan {
240240 /// Join two logical plans on one or more join columns.
241241 /// This is used to implement SQL `JOIN`
242242 Join ( Join ) ,
243- /// Match each left row with at most one ordered row from the right input.
244- /// This is used to implement SQL `ASOF JOIN`.
245- AsOfJoin ( AsOfJoin ) ,
246243 /// Repartitions the input based on a partitioning scheme. This is
247244 /// used to add parallelism and is sometimes referred to as an
248245 /// "exchange" operator in other systems
@@ -299,6 +296,9 @@ pub enum LogicalPlan {
299296 Unnest ( Unnest ) ,
300297 /// A variadic query (e.g. "Recursive CTEs")
301298 RecursiveQuery ( RecursiveQuery ) ,
299+ /// Match each left row with at most one ordered row from the right input.
300+ /// This is used to implement SQL `ASOF JOIN`.
301+ AsOfJoin ( AsOfJoin ) ,
302302}
303303
304304impl Default for LogicalPlan {
@@ -4455,8 +4455,7 @@ impl AsOfJoin {
44554455 return plan_err ! ( "ASOF USING keys must be columns" ) ;
44564456 }
44574457
4458- let schema =
4459- build_asof_join_schema ( left. schema ( ) , right. schema ( ) , & on, join_constraint) ?;
4458+ let schema = build_asof_join_schema ( left. schema ( ) , right. schema ( ) ) ?;
44604459 Ok ( Self {
44614460 left,
44624461 right,
@@ -6867,6 +6866,32 @@ mod tests {
68676866 Ok ( ( ) )
68686867 }
68696868
6869+ #[ test]
6870+ fn test_asof_using_preserves_qualified_keys ( ) -> Result < ( ) > {
6871+ let schema = Schema :: new ( vec ! [
6872+ Field :: new( "id" , DataType :: Int32 , false ) ,
6873+ Field :: new( "ts" , DataType :: Int64 , false ) ,
6874+ ] ) ;
6875+ let left = Arc :: new ( table_scan ( Some ( "t1" ) , & schema, None ) ?. build ( ) ?) ;
6876+ let right = Arc :: new ( table_scan ( Some ( "t2" ) , & schema, None ) ?. build ( ) ?) ;
6877+ let join = AsOfJoin :: try_new (
6878+ left,
6879+ right,
6880+ vec ! [ ( col( "t1.id" ) , col( "t2.id" ) ) ] ,
6881+ AsOfMatch :: new ( col ( "t1.ts" ) , Operator :: GtEq , col ( "t2.ts" ) ) ,
6882+ JoinConstraint :: Using ,
6883+ ) ?;
6884+
6885+ assert_eq ! ( join. schema. fields( ) . len( ) , 4 ) ;
6886+ assert_eq ! (
6887+ join. schema
6888+ . index_of_column( & Column :: from_qualified_name( "t2.id" ) ) ?,
6889+ 2
6890+ ) ;
6891+ assert ! ( join. schema. field( 2 ) . is_nullable( ) ) ;
6892+ Ok ( ( ) )
6893+ }
6894+
68706895 #[ test]
68716896 fn test_join_try_new_schema_validation ( ) -> Result < ( ) > {
68726897 let left_schema = Schema :: new ( vec ! [
0 commit comments