@@ -686,8 +686,10 @@ pub(crate) mod tests {
686686 metadata2. insert ( "PARQUET:field_id" . to_string ( ) , "2" . to_string ( ) ) ;
687687
688688 let source_schema = Schema :: new ( vec ! [
689- Field :: new( "user_id" , DataType :: Int64 , false ) . with_metadata( metadata1. clone( ) ) ,
690- Field :: new( "amount" , DataType :: Float64 , false ) . with_metadata( metadata2. clone( ) ) ,
689+ Field :: new( "user_id" , DataType :: Int64 , false )
690+ . with_metadata( metadata1. clone( ) ) ,
691+ Field :: new( "amount" , DataType :: Float64 , false )
692+ . with_metadata( metadata2. clone( ) ) ,
691693 ] ) ;
692694
693695 // Target schema: renamed columns but same field IDs
@@ -698,10 +700,16 @@ pub(crate) mod tests {
698700
699701 // Should match by field ID, not name
700702 let index = find_field_index ( "user_id" , & source_schema, & target_schema) ?;
701- assert_eq ! ( index, 0 , "user_id (field_id=1) should match customer_id at index 0" ) ;
703+ assert_eq ! (
704+ index, 0 ,
705+ "user_id (field_id=1) should match customer_id at index 0"
706+ ) ;
702707
703708 let index = find_field_index ( "amount" , & source_schema, & target_schema) ?;
704- assert_eq ! ( index, 1 , "amount (field_id=2) should match price at index 1" ) ;
709+ assert_eq ! (
710+ index, 1 ,
711+ "amount (field_id=2) should match price at index 1"
712+ ) ;
705713
706714 Ok ( ( ) )
707715 }
@@ -752,15 +760,20 @@ pub(crate) mod tests {
752760 ] ) ;
753761
754762 // Should fall back to name-based matching
755- assert_eq ! ( find_field_index( "user_id" , & source_schema, & target_schema) ?, 0 ) ;
756- assert_eq ! ( find_field_index( "amount" , & source_schema, & target_schema) ?, 1 ) ;
763+ assert_eq ! (
764+ find_field_index( "user_id" , & source_schema, & target_schema) ?,
765+ 0
766+ ) ;
767+ assert_eq ! (
768+ find_field_index( "amount" , & source_schema, & target_schema) ?,
769+ 1
770+ ) ;
757771
758772 Ok ( ( ) )
759773 }
760774
761775 #[ test]
762776 fn test_find_field_index_mixed_field_ids ( ) -> Result < ( ) > {
763-
764777 // Source schema: some fields have IDs, some don't
765778 let mut metadata1 = HashMap :: new ( ) ;
766779 metadata1. insert ( "PARQUET:field_id" . to_string ( ) , "1" . to_string ( ) ) ;
@@ -786,13 +799,9 @@ pub(crate) mod tests {
786799
787800 #[ test]
788801 fn test_find_field_index_not_found ( ) {
789- let source_schema = Schema :: new ( vec ! [
790- Field :: new( "a" , DataType :: Int64 , false ) ,
791- ] ) ;
802+ let source_schema = Schema :: new ( vec ! [ Field :: new( "a" , DataType :: Int64 , false ) ] ) ;
792803
793- let target_schema = Schema :: new ( vec ! [
794- Field :: new( "b" , DataType :: Int64 , false ) ,
795- ] ) ;
804+ let target_schema = Schema :: new ( vec ! [ Field :: new( "b" , DataType :: Int64 , false ) ] ) ;
796805
797806 // Should fail to find non-existent field
798807 let result = find_field_index ( "a" , & source_schema, & target_schema) ;
@@ -801,7 +810,6 @@ pub(crate) mod tests {
801810
802811 #[ test]
803812 fn test_reassign_expr_columns_with_field_ids_simple ( ) -> Result < ( ) > {
804-
805813 // Source schema: full file schema
806814 let mut meta1 = HashMap :: new ( ) ;
807815 meta1. insert ( "PARQUET:field_id" . to_string ( ) , "1" . to_string ( ) ) ;
@@ -826,18 +834,22 @@ pub(crate) mod tests {
826834 let expr: Arc < dyn PhysicalExpr > = Arc :: new ( Column :: new ( "age" , 2 ) ) ;
827835
828836 // After transformation, should reference age at index 1 in target schema
829- let result = reassign_expr_columns_with_field_ids ( expr, & source_schema, & target_schema) ?;
837+ let result =
838+ reassign_expr_columns_with_field_ids ( expr, & source_schema, & target_schema) ?;
830839
831840 let column = result. as_any ( ) . downcast_ref :: < Column > ( ) . unwrap ( ) ;
832841 assert_eq ! ( column. name( ) , "age" ) ;
833- assert_eq ! ( column. index( ) , 1 , "age should be at index 1 in target schema" ) ;
842+ assert_eq ! (
843+ column. index( ) ,
844+ 1 ,
845+ "age should be at index 1 in target schema"
846+ ) ;
834847
835848 Ok ( ( ) )
836849 }
837850
838851 #[ test]
839852 fn test_reassign_expr_columns_with_field_ids_complex ( ) -> Result < ( ) > {
840-
841853 // Source schema
842854 let mut meta1 = HashMap :: new ( ) ;
843855 meta1. insert ( "PARQUET:field_id" . to_string ( ) , "1" . to_string ( ) ) ;
@@ -867,27 +879,39 @@ pub(crate) mod tests {
867879 ) ?;
868880
869881 // After transformation: a@0 + c@1
870- let result = reassign_expr_columns_with_field_ids ( expr, & source_schema, & target_schema) ?;
882+ let result =
883+ reassign_expr_columns_with_field_ids ( expr, & source_schema, & target_schema) ?;
871884
872885 // Verify it's still a binary expression
873886 let binary_expr = result. as_any ( ) . downcast_ref :: < BinaryExpr > ( ) . unwrap ( ) ;
874887
875888 // Check left side (a)
876- let left_col = binary_expr. left ( ) . as_any ( ) . downcast_ref :: < Column > ( ) . unwrap ( ) ;
889+ let left_col = binary_expr
890+ . left ( )
891+ . as_any ( )
892+ . downcast_ref :: < Column > ( )
893+ . unwrap ( ) ;
877894 assert_eq ! ( left_col. name( ) , "a" ) ;
878895 assert_eq ! ( left_col. index( ) , 0 ) ;
879896
880897 // Check right side (c)
881- let right_col = binary_expr. right ( ) . as_any ( ) . downcast_ref :: < Column > ( ) . unwrap ( ) ;
898+ let right_col = binary_expr
899+ . right ( )
900+ . as_any ( )
901+ . downcast_ref :: < Column > ( )
902+ . unwrap ( ) ;
882903 assert_eq ! ( right_col. name( ) , "c" ) ;
883- assert_eq ! ( right_col. index( ) , 1 , "c should be remapped from index 2 to 1" ) ;
904+ assert_eq ! (
905+ right_col. index( ) ,
906+ 1 ,
907+ "c should be remapped from index 2 to 1"
908+ ) ;
884909
885910 Ok ( ( ) )
886911 }
887912
888913 #[ test]
889914 fn test_reassign_expr_columns_with_field_ids_renamed_columns ( ) -> Result < ( ) > {
890-
891915 // Source schema (file schema with old names)
892916 let mut meta1 = HashMap :: new ( ) ;
893917 meta1. insert ( "PARQUET:field_id" . to_string ( ) , "1" . to_string ( ) ) ;
@@ -909,11 +933,16 @@ pub(crate) mod tests {
909933 let expr: Arc < dyn PhysicalExpr > = Arc :: new ( Column :: new ( "user_id" , 0 ) ) ;
910934
911935 // After transformation, should still reference by old name but correct index
912- let result = reassign_expr_columns_with_field_ids ( expr, & source_schema, & target_schema) ?;
936+ let result =
937+ reassign_expr_columns_with_field_ids ( expr, & source_schema, & target_schema) ?;
913938
914939 let column = result. as_any ( ) . downcast_ref :: < Column > ( ) . unwrap ( ) ;
915940 assert_eq ! ( column. name( ) , "user_id" , "Name should remain user_id" ) ;
916- assert_eq ! ( column. index( ) , 0 , "Should match customer_id at index 0 via field_id" ) ;
941+ assert_eq ! (
942+ column. index( ) ,
943+ 0 ,
944+ "Should match customer_id at index 0 via field_id"
945+ ) ;
917946
918947 Ok ( ( ) )
919948 }
@@ -936,7 +965,8 @@ pub(crate) mod tests {
936965 let expr: Arc < dyn PhysicalExpr > = Arc :: new ( Column :: new ( "c" , 2 ) ) ;
937966
938967 // Should fall back to name-based matching
939- let result = reassign_expr_columns_with_field_ids ( expr, & source_schema, & target_schema) ?;
968+ let result =
969+ reassign_expr_columns_with_field_ids ( expr, & source_schema, & target_schema) ?;
940970
941971 let column = result. as_any ( ) . downcast_ref :: < Column > ( ) . unwrap ( ) ;
942972 assert_eq ! ( column. name( ) , "c" ) ;
0 commit comments