Skip to content

Commit 92eae6f

Browse files
committed
rewrite spec test, fix union logic
1 parent 57fd166 commit 92eae6f

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/transform/src/typecheck.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/transform/tests/test_transforms/typecheck.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Return
222222
Get l1
223223

224224

225-
mismatched column types: couldn't compute union of column types in let rec: Can't union types: Bool and Int64
225+
mismatched column types: couldn't compute union of column types in LetRec
226226
got Int64
227227
expected Bool?
228228
Bool is a not a subtype of Int64
@@ -413,7 +413,7 @@ Reduce group_by=[#0] aggregates=[max(#1), min(#1), sum(distinct #1)] monotonic e
413413
- ("a", 2)
414414
- ("a", 4)
415415
----
416-
(String, Int64, Int64, Numeric { max_scale: Some(NumericMaxScale(0)) })
416+
(String, Int64, Int64, Numeric { max_scale: None })
417417

418418
# empty output type (no keys!)
419419
typecheck

0 commit comments

Comments
 (0)