@@ -884,7 +884,7 @@ impl Typecheck {
884884 }
885885
886886 for ( base_col, input_col) in t_base. iter_mut ( ) . zip_eq ( t_input) {
887- let diffs = column_subtype_difference ( base_col, & input_col) . into_iter ( ) . filter_map ( |diff| diff . ignore_nullability ( ) ) . collect_vec ( ) ;
887+ let diffs = scalar_subtype_difference ( & base_col. scalar_type , & input_col. scalar_type ) ;
888888 if !diffs. is_empty ( ) {
889889 return Err ( TypeError :: MismatchColumn {
890890 source : expr,
@@ -938,8 +938,8 @@ impl Typecheck {
938938 let id = Id :: Local ( id. clone ( ) ) ;
939939 if let Some ( ctx_typ) = ctx. get_mut ( & id) {
940940 for ( base_col, input_col) in ctx_typ. iter_mut ( ) . zip_eq ( typ) {
941- // we explicitly include nullability information---we expect an EXACT match
942- let diffs = column_subtype_difference ( base_col, & input_col) ;
941+ // we expect an EXACT match, but don't care about nullability
942+ let diffs = scalar_subtype_difference ( & base_col. scalar_type , & input_col. scalar_type ) ;
943943 if !diffs. is_empty ( ) {
944944 return Err ( TypeError :: MismatchColumn {
945945 source : expr,
@@ -1020,10 +1020,10 @@ impl Typecheck {
10201020 }
10211021
10221022 for ( base_col, input_col) in ctx_typ. iter_mut ( ) . zip_eq ( typ) {
1023- let diffs = column_subtype_difference ( base_col , & input_col )
1024- . into_iter ( )
1025- . filter_map ( |diff| diff . ignore_nullability ( ) )
1026- . collect_vec ( ) ;
1023+ let diffs = scalar_subtype_difference (
1024+ & base_col . scalar_type ,
1025+ & input_col . scalar_type ,
1026+ ) ;
10271027 if !diffs. is_empty ( ) {
10281028 return Err ( TypeError :: MismatchColumn {
10291029 source : expr,
@@ -1203,19 +1203,18 @@ impl Typecheck {
12031203 let mut then_type = tc. typecheck_scalar ( then, source, column_types) ?;
12041204 let else_type = tc. typecheck_scalar ( els, source, column_types) ?;
12051205
1206- let diffs = column_subtype_difference ( & then_type, & else_type)
1207- . into_iter ( )
1208- . filter_map ( |diff| diff. ignore_nullability ( ) )
1209- . collect_vec ( ) ;
1206+ let diffs =
1207+ scalar_subtype_difference ( & then_type. scalar_type , & else_type. scalar_type ) ;
12101208 if !diffs. is_empty ( ) {
12111209 return Err ( TypeError :: MismatchColumn {
12121210 source,
1213- got : then_type,
1214- expected : else_type,
1211+ got : then_type. clone ( ) ,
1212+ expected : else_type. clone ( ) ,
12151213 diffs,
12161214 message : "couldn't compute union of column types for If" . to_string ( ) ,
12171215 } ) ;
12181216 }
1217+
12191218 then_type. nullable |= else_type. nullable ;
12201219 Ok ( then_type)
12211220 }
0 commit comments