You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a7c7c08
Browse filesBrowse the repository at this point in the historyBrowse files
Show nullability of an explicit CastExpr target in its display (apache#26359)
## Which issue does this PR close?
- Closesapache#26358.
## Rationale for this change
A cast to an explicit target field can change only the nullability of
its input. `UnionExec` adds one to align its inputs. `CastExpr`
displayed only the data type, so EXPLAIN showed a same-type cast such as
`CAST(1 AS Int64)` with no visible effect.
## What changes are included in this PR?
- `CastExpr`'s `Display` appends `;N`, the notation schemas already use,
when the cast has an explicit target field that is nullable.
- Casts built from a bare type and `fmt_sql` are unchanged.
- Updated plan expectations. The only change in each is the added `;N`.
## What is the testing strategy for this PR?
- New unit test `test_display_explicit_target_nullability` in `cast.rs`.
- Existing sqllogictest, insta and pruning predicate expectations
updated.
## Are there any user-facing changes?
Physical plan text in EXPLAIN changes for these casts. No API changes.
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Dictionary(UInt16, Utf8)) <= test AND test <= CAST(c1_max@1 AS Dictionary(UInt16, Utf8))";
5153
+
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Dictionary(UInt16, Utf8);N) <= test AND test <= CAST(c1_max@1 AS Dictionary(UInt16, Utf8);N)";
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Dictionary(UInt16, Date64)) <= 1970-01-01 AND 1970-01-01 <= CAST(c1_max@1 AS Dictionary(UInt16, Date64))";
5213
+
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Dictionary(UInt16, Date64);N) <= 1970-01-01 AND 1970-01-01 <= CAST(c1_max@1 AS Dictionary(UInt16, Date64);N)";
5214
5214
5215
5215
// Test with a cast to a different date type
5216
5216
let expr = cast(
@@ -5282,7 +5282,7 @@ mod tests {
5282
5282
],
5283
5283
false,
5284
5284
));
5285
-
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Int64) <= 1 AND 1 <= CAST(c1_max@1 AS Int64) OR c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Int64) <= 2 AND 2 <= CAST(c1_max@1 AS Int64) OR c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Int64) <= 3 AND 3 <= CAST(c1_max@1 AS Int64)";
5285
+
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Int64;N) <= 1 AND 1 <= CAST(c1_max@1 AS Int64;N) OR c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Int64;N) <= 2 AND 2 <= CAST(c1_max@1 AS Int64;N) OR c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Int64;N) <= 3 AND 3 <= CAST(c1_max@1 AS Int64;N)";
let expected_expr = "c1_null_count@2 != row_count@3 AND (CAST(c1_min@0 AS Int64) != 1 OR 1 != CAST(c1_max@1 AS Int64)) AND c1_null_count@2 != row_count@3 AND (CAST(c1_min@0 AS Int64) != 2 OR 2 != CAST(c1_max@1 AS Int64)) AND c1_null_count@2 != row_count@3 AND (CAST(c1_min@0 AS Int64) != 3 OR 3 != CAST(c1_max@1 AS Int64))";
5299
+
let expected_expr = "c1_null_count@2 != row_count@3 AND (CAST(c1_min@0 AS Int64;N) != 1 OR 1 != CAST(c1_max@1 AS Int64;N)) AND c1_null_count@2 != row_count@3 AND (CAST(c1_min@0 AS Int64;N) != 2 OR 2 != CAST(c1_max@1 AS Int64;N)) AND c1_null_count@2 != row_count@3 AND (CAST(c1_min@0 AS Int64;N) != 3 OR 3 != CAST(c1_max@1 AS Int64;N))";
04)------DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/cte/test.parquet]]}, projection=[CAST(k@0 AS Int64) as k, CAST(v1@1 AS Int64) as v1], output_ordering=[k@0 ASC NULLS LAST], file_type=parquet
1696
+
04)------DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/cte/test.parquet]]}, projection=[CAST(k@0 AS Int64;N) as k, CAST(v1@1 AS Int64;N) as v1], output_ordering=[k@0 ASC NULLS LAST], file_type=parquet
1697
1697
05)------CoalescePartitionsExec
1698
1698
06)--------ProjectionExec: expr=[k@0 * 10 as k, v1@1 as v1]
0 commit comments