Skip to content

Commit a7c7c08

Browse files
authored
Show nullability of an explicit CastExpr target in its display (apache#26359)
## Which issue does this PR close? - Closes apache#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.
1 parent 7f493a5 commit a7c7c08

10 files changed

Lines changed: 64 additions & 29 deletions

File tree

‎datafusion/core/tests/sql/explain_analyze.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ async fn parquet_recursive_projection_pushdown() -> Result<()> {
11461146
SortExec: expr=[id@0 ASC NULLS LAST], preserve_partitioning=[false]
11471147
RecursiveQueryExec: name=number_series, is_distinct=false
11481148
CoalescePartitionsExec
1149-
ProjectionExec: expr=[CAST(id@0 AS Int64) as id, CAST(1 AS Int64) as level]
1149+
ProjectionExec: expr=[CAST(id@0 AS Int64;N) as id, CAST(1 AS Int64;N) as level]
11501150
FilterExec: id@0 = 1
11511151
RepartitionExec: partitioning=RoundRobinBatch(NUM_CORES), input_partitions=1
11521152
DataSourceExec: file_groups={1 group: [[TMP_DIR/hierarchy.parquet]]}, projection=[id], file_type=parquet, predicate=id@0 = 1, pruning_predicate=id_null_count@2 != row_count@3 AND id_min@0 <= 1 AND 1 <= id_max@1, required_guarantees=[id in (1)]

‎datafusion/physical-expr/src/expressions/cast.rs‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,14 @@ fn deserialize_cast_options(
565565

566566
impl fmt::Display for CastExpr {
567567
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
568-
write!(f, "CAST({} AS {})", self.expr, self.cast_type())
568+
write!(f, "CAST({} AS {}", self.expr, self.cast_type())?;
569+
// A cast to an explicit field can change only the nullability (for
570+
// example when a union aligns its inputs), so show it the way schemas
571+
// do: `;N` marks a nullable field.
572+
if self.explicit_target && self.target_field.is_nullable() {
573+
write!(f, ";N")?;
574+
}
575+
write!(f, ")")
569576
}
570577
}
571578

@@ -1840,6 +1847,33 @@ mod tests {
18401847
Ok(())
18411848
}
18421849

1850+
#[test]
1851+
fn test_display_explicit_target_nullability() -> Result<()> {
1852+
let schema = Schema::new(vec![Field::new("a", Int32, false)]);
1853+
1854+
// A same-type cast to a nullable field only relabels the nullability
1855+
let expr = CastExpr::new_with_target_field(
1856+
col("a", &schema)?,
1857+
Arc::new(Field::new("a", Int32, true)),
1858+
None,
1859+
);
1860+
assert_eq!(expr.to_string(), "CAST(a@0 AS Int32;N)");
1861+
assert_eq!(fmt_sql(&expr).to_string(), "CAST(a AS Int32)");
1862+
1863+
let expr = CastExpr::new_with_target_field(
1864+
col("a", &schema)?,
1865+
Arc::new(Field::new("a", Int32, false)),
1866+
None,
1867+
);
1868+
assert_eq!(expr.to_string(), "CAST(a@0 AS Int32)");
1869+
1870+
// A cast to a bare type is unchanged
1871+
let expr = CastExpr::new(col("a", &schema)?, Int64, None);
1872+
assert_eq!(expr.to_string(), "CAST(a@0 AS Int64)");
1873+
1874+
Ok(())
1875+
}
1876+
18431877
#[test]
18441878
fn type_only_cast_strips_extension_metadata() -> Result<()> {
18451879
// When using type-only cast (new()), extension metadata from source should NOT propagate

‎datafusion/pruning/src/pruning_predicate.rs‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4949,7 +4949,7 @@ mod tests {
49494949
#[test]
49504950
fn row_group_predicate_cast_int_int() -> Result<()> {
49514951
let schema = Schema::new(vec![Field::new("c1", DataType::Int32, false)]);
4952-
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)";
4952+
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)";
49534953

49544954
// test cast(c1 as int64) = 1
49554955
// test column on the left
@@ -4987,7 +4987,7 @@ mod tests {
49874987
#[test]
49884988
fn row_group_predicate_cast_string_string() -> Result<()> {
49894989
let schema = Schema::new(vec![Field::new("c1", DataType::Utf8View, false)]);
4990-
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Utf8) <= 1 AND 1 <= CAST(c1_max@1 AS Utf8)";
4990+
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Utf8;N) <= 1 AND 1 <= CAST(c1_max@1 AS Utf8;N)";
49914991

49924992
// test column on the left
49934993
let expr = cast(col("c1"), DataType::Utf8)
@@ -5051,7 +5051,7 @@ mod tests {
50515051
#[test]
50525052
fn row_group_predicate_date_date() -> Result<()> {
50535053
let schema = Schema::new(vec![Field::new("c1", DataType::Date32, false)]);
5054-
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Date64) <= 1970-01-01 AND 1970-01-01 <= CAST(c1_max@1 AS Date64)";
5054+
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Date64;N) <= 1970-01-01 AND 1970-01-01 <= CAST(c1_max@1 AS Date64;N)";
50555055

50565056
// test column on the left
50575057
let expr =
@@ -5150,7 +5150,7 @@ mod tests {
51505150
.eq(lit(ScalarValue::Utf8(Some("test".to_string()))));
51515151
let predicate_expr =
51525152
test_build_predicate_expression(&expr, &schema, &mut RequiredColumns::new());
5153-
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)";
51545154
assert_eq!(predicate_expr.to_string(), expected_expr);
51555155

51565156
Ok(())
@@ -5164,7 +5164,7 @@ mod tests {
51645164
DataType::Dictionary(Box::new(DataType::UInt8), Box::new(DataType::Int32)),
51655165
false,
51665166
)]);
5167-
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Int64) <= 123 AND 123 <= CAST(c1_max@1 AS Int64)";
5167+
let expected_expr = "c1_null_count@2 != row_count@3 AND CAST(c1_min@0 AS Int64;N) <= 123 AND 123 <= CAST(c1_max@1 AS Int64;N)";
51685168

51695169
// Test with literal of a different type
51705170
let expr =
@@ -5210,7 +5210,7 @@ mod tests {
52105210
DataType::Dictionary(Box::new(DataType::UInt8), Box::new(DataType::Date32)),
52115211
false,
52125212
)]);
5213-
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)";
52145214

52155215
// Test with a cast to a different date type
52165216
let expr = cast(
@@ -5282,7 +5282,7 @@ mod tests {
52825282
],
52835283
false,
52845284
));
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)";
52865286
let predicate_expr =
52875287
test_build_predicate_expression(&expr, &schema, &mut RequiredColumns::new());
52885288
assert_eq!(predicate_expr.to_string(), expected_expr);
@@ -5296,7 +5296,7 @@ mod tests {
52965296
],
52975297
true,
52985298
));
5299-
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))";
53005300
let predicate_expr =
53015301
test_build_predicate_expression(&expr, &schema, &mut RequiredColumns::new());
53025302
assert_eq!(predicate_expr.to_string(), expected_expr);
@@ -6763,7 +6763,8 @@ mod tests {
67636763
let (result_left, _, result_right) =
67646764
rewrite_expr_to_prunable(&left_input, Operator::Gt, &right_input, &schema)
67656765
.unwrap();
6766-
assert_eq!(result_left.to_string(), left_input.to_string());
6766+
// The rewrite rebuilds the cast with its nullable target field
6767+
assert_eq!(result_left.to_string(), "CAST(a@0 AS Decimal128(20, 3);N)");
67676768
assert_eq!(result_right.to_string(), right_input.to_string());
67686769

67696770
// try_cast op lit

‎datafusion/sqllogictest/test_files/array_agg.slt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,15 +578,15 @@ physical_plan
578578
03)----RepartitionExec: partitioning=Hash([id@0], 4), input_partitions=5
579579
04)------AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[array_agg(DISTINCT a.foo), sum(DISTINCT Int64(1))]
580580
05)--------UnionExec
581-
06)----------ProjectionExec: expr=[1 as id, CAST(2 AS Int64) as foo]
581+
06)----------ProjectionExec: expr=[1 as id, CAST(2 AS Int64;N) as foo]
582582
07)------------PlaceholderRowExec
583583
08)----------ProjectionExec: expr=[1 as id, NULL as foo]
584584
09)------------PlaceholderRowExec
585585
10)----------ProjectionExec: expr=[1 as id, NULL as foo]
586586
11)------------PlaceholderRowExec
587-
12)----------ProjectionExec: expr=[1 as id, CAST(3 AS Int64) as foo]
587+
12)----------ProjectionExec: expr=[1 as id, CAST(3 AS Int64;N) as foo]
588588
13)------------PlaceholderRowExec
589-
14)----------ProjectionExec: expr=[1 as id, CAST(2 AS Int64) as foo]
589+
14)----------ProjectionExec: expr=[1 as id, CAST(2 AS Int64;N) as foo]
590590
15)------------PlaceholderRowExec
591591

592592
#######

‎datafusion/sqllogictest/test_files/cte.slt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ logical_plan
171171
07)--------TableScan: nodes projection=[id]
172172
physical_plan
173173
01)RecursiveQueryExec: name=nodes, is_distinct=false
174-
02)--ProjectionExec: expr=[CAST(1 AS Int64) as id]
174+
02)--ProjectionExec: expr=[CAST(1 AS Int64;N) as id]
175175
03)----PlaceholderRowExec
176176
04)--CoalescePartitionsExec
177177
05)----ProjectionExec: expr=[id@0 + 1 as id]
@@ -260,7 +260,7 @@ logical_plan
260260
07)--------TableScan: t projection=[n]
261261
physical_plan
262262
01)RecursiveQueryExec: name=t, is_distinct=false
263-
02)--ProjectionExec: expr=[CAST(1 AS Int64) as n]
263+
02)--ProjectionExec: expr=[CAST(1 AS Int64;N) as n]
264264
03)----PlaceholderRowExec
265265
04)--CoalescePartitionsExec
266266
05)----ProjectionExec: expr=[n@0 + 1 as n]
@@ -1183,7 +1183,7 @@ logical_plan
11831183
07)--------TableScan: numbers projection=[n]
11841184
physical_plan
11851185
01)RecursiveQueryExec: name=numbers, is_distinct=false
1186-
02)--ProjectionExec: expr=[CAST(1 AS Int64) as n]
1186+
02)--ProjectionExec: expr=[CAST(1 AS Int64;N) as n]
11871187
03)----PlaceholderRowExec
11881188
04)--CoalescePartitionsExec
11891189
05)----ProjectionExec: expr=[n@0 + 1 as n]
@@ -1208,7 +1208,7 @@ logical_plan
12081208
07)--------TableScan: numbers projection=[n]
12091209
physical_plan
12101210
01)RecursiveQueryExec: name=numbers, is_distinct=false
1211-
02)--ProjectionExec: expr=[CAST(1 AS Int64) as n]
1211+
02)--ProjectionExec: expr=[CAST(1 AS Int64;N) as n]
12121212
03)----PlaceholderRowExec
12131213
04)--CoalescePartitionsExec
12141214
05)----ProjectionExec: expr=[n@0 + 1 as n]
@@ -1265,7 +1265,7 @@ logical_plan
12651265
physical_plan
12661266
01)GlobalLimitExec: skip=0, fetch=5
12671267
02)--RecursiveQueryExec: name=r, is_distinct=false
1268-
03)----ProjectionExec: expr=[CAST(0 AS Int64) as k, CAST(0 AS Int64) as v]
1268+
03)----ProjectionExec: expr=[CAST(0 AS Int64;N) as k, CAST(0 AS Int64;N) as v]
12691269
04)------PlaceholderRowExec
12701270
05)----SortExec: TopK(fetch=1), expr=[v@1 ASC NULLS LAST], preserve_partitioning=[false]
12711271
06)------WorkTableExec: name=r
@@ -1693,7 +1693,7 @@ physical_plan
16931693
01)ScalarSubqueryExec: subqueries=1
16941694
02)--SortExec: expr=[k@0 ASC NULLS LAST, v1@1 ASC NULLS LAST], preserve_partitioning=[false]
16951695
03)----RecursiveQueryExec: name=r, is_distinct=false
1696-
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
16971697
05)------CoalescePartitionsExec
16981698
06)--------ProjectionExec: expr=[k@0 * 10 as k, v1@1 as v1]
16991699
07)----------FilterExec: k@0 < scalar_subquery(<pending>)

‎datafusion/sqllogictest/test_files/cte_materialized.slt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ physical_plan
311311
01)MaterializedCteExec: name=r
312312
02)--RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
313313
03)----RecursiveQueryExec: name=r, is_distinct=false
314-
04)------ProjectionExec: expr=[CAST(1 AS Int64) as n]
314+
04)------ProjectionExec: expr=[CAST(1 AS Int64;N) as n]
315315
05)--------PlaceholderRowExec
316316
06)------CoalescePartitionsExec
317317
07)--------ProjectionExec: expr=[n@0 + 1 as n]

‎datafusion/sqllogictest/test_files/file_row_index.slt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ EXPLAIN SELECT file_row_index(), column1 FROM parquet_table
3131
logical_plan
3232
01)Projection: file_row_index(), parquet_table.column1
3333
02)--TableScan: parquet_table projection=[column1]
34-
physical_plan DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/file_row_index/parquet_table/data.parquet]]}, projection=[CAST(__datafusion_file_row_index@1 AS Int64) as file_row_index(), column1], file_type=parquet
34+
physical_plan DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/file_row_index/parquet_table/data.parquet]]}, projection=[CAST(__datafusion_file_row_index@1 AS Int64;N) as file_row_index(), column1], file_type=parquet
3535

3636

3737
query II
@@ -78,7 +78,7 @@ logical_plan
7878
physical_plan
7979
01)SortExec: expr=[column1@0 ASC NULLS LAST], preserve_partitioning=[false]
8080
02)--FilterExec: __datafusion_extracted_1@0 > 2, projection=[column1@1]
81-
03)----DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/file_row_index/parquet_table/data.parquet]]}, projection=[CAST(__datafusion_file_row_index@1 AS Int64) as __datafusion_extracted_1, column1], file_type=parquet
81+
03)----DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/file_row_index/parquet_table/data.parquet]]}, projection=[CAST(__datafusion_file_row_index@1 AS Int64;N) as __datafusion_extracted_1, column1], file_type=parquet
8282

8383
query I
8484
SELECT column1 FROM parquet_table WHERE file_row_index() > 2 ORDER BY column1
@@ -103,7 +103,7 @@ logical_plan
103103
physical_plan
104104
01)SortExec: expr=[column1@0 ASC NULLS LAST], preserve_partitioning=[false]
105105
02)--FilterExec: __datafusion_extracted_1@0 > 2, projection=[column1@1]
106-
03)----DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/file_row_index/parquet_table/data.parquet]]}, projection=[CAST(__datafusion_file_row_index@1 AS Int64) as __datafusion_extracted_1, column1], file_type=parquet
106+
03)----DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/file_row_index/parquet_table/data.parquet]]}, projection=[CAST(__datafusion_file_row_index@1 AS Int64;N) as __datafusion_extracted_1, column1], file_type=parquet
107107

108108
query I
109109
SELECT column1 FROM parquet_table WHERE file_row_index() > 2 ORDER BY column1

‎datafusion/sqllogictest/test_files/parquet_metadata_functions.slt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ FROM test_table
5050
logical_plan
5151
01)Projection: input_file_name(), file_row_index(), test_table.column1
5252
02)--TableScan: test_table projection=[column1]
53-
physical_plan DataSourceExec: file_groups={2 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_metadata_functions/first.parquet], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_metadata_functions/second.parquet]]}, projection=[input_file_name() as input_file_name(), CAST(__datafusion_file_row_index@1 AS Int64) as file_row_index(), column1], file_type=parquet
53+
physical_plan DataSourceExec: file_groups={2 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_metadata_functions/first.parquet], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_metadata_functions/second.parquet]]}, projection=[input_file_name() as input_file_name(), CAST(__datafusion_file_row_index@1 AS Int64;N) as file_row_index(), column1], file_type=parquet
5454

5555

5656
# Make sure it also behaves consistently regardless of filter pushdown

‎datafusion/sqllogictest/test_files/parquet_statistics.slt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ EXPLAIN SELECT f32 FROM typed_table WHERE f32 = 2.5;
172172
physical_plan
173173
01)FilterExec: CAST(f32@0 AS Float64) = 2.5, statistics=[Rows=Inexact(1), Bytes=Inexact(1), [(Col[0]: Min=Exact(Float32(2.5)) Max=Exact(Float32(2.5)) Null=Inexact(0) Distinct=Inexact(1) ScanBytes=Inexact(1))]]
174174
02)--RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1, statistics=[Rows=Inexact(5), Bytes=Inexact(20), [(Col[0]: Min=Inexact(Float32(1.5)) Max=Inexact(Float32(5.5)) Null=Inexact(0) ScanBytes=Inexact(20))]]
175-
03)----DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_statistics/typed_table.parquet]]}, projection=[f32], file_type=parquet, predicate=CAST(f32@2 AS Float64) = 2.5, pruning_predicate=f32_null_count@2 != row_count@3 AND CAST(f32_min@0 AS Float64) <= 2.5 AND 2.5 <= CAST(f32_max@1 AS Float64), required_guarantees=[], statistics=[Rows=Inexact(5), Bytes=Inexact(20), [(Col[0]: Min=Inexact(Float32(1.5)) Max=Inexact(Float32(5.5)) Null=Inexact(0) ScanBytes=Inexact(20))]]
175+
03)----DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_statistics/typed_table.parquet]]}, projection=[f32], file_type=parquet, predicate=CAST(f32@2 AS Float64) = 2.5, pruning_predicate=f32_null_count@2 != row_count@3 AND CAST(f32_min@0 AS Float64;N) <= 2.5 AND 2.5 <= CAST(f32_max@1 AS Float64;N), required_guarantees=[], statistics=[Rows=Inexact(5), Bytes=Inexact(20), [(Col[0]: Min=Inexact(Float32(1.5)) Max=Inexact(Float32(5.5)) Null=Inexact(0) ScanBytes=Inexact(20))]]
176176

177177
# Reversed operand order: literal = column (Float64)
178178
query TT

‎datafusion/sqllogictest/test_files/union.slt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ logical_plan
661661
physical_plan
662662
01)CoalescePartitionsExec: fetch=3
663663
02)--UnionExec
664-
03)----ProjectionExec: expr=[CAST(count(Int64(1))@0 AS Int64) as cnt]
664+
03)----ProjectionExec: expr=[CAST(count(Int64(1))@0 AS Int64;N) as cnt]
665665
04)------GlobalLimitExec: skip=0, fetch=3
666666
05)--------AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
667667
06)----------CoalescePartitionsExec
@@ -673,7 +673,7 @@ physical_plan
673673
12)----------------------FilterExec: c13@1 != C2GT5KVyOPZpgKVl110TyZO0NcJ434, projection=[c1@0]
674674
13)------------------------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
675675
14)--------------------------DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/testing/data/csv/aggregate_test_100.csv]]}, projection=[c1, c13], file_type=csv, has_header=true
676-
15)----ProjectionExec: expr=[CAST(1 AS Int64) as cnt]
676+
15)----ProjectionExec: expr=[CAST(1 AS Int64;N) as cnt]
677677
16)------PlaceholderRowExec
678678
17)----ProjectionExec: expr=[lead(b.c1,Int64(1)) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING@1 as cnt]
679679
18)------GlobalLimitExec: skip=0, fetch=3
@@ -810,7 +810,7 @@ logical_plan
810810
11)----------EmptyRelation: rows=1
811811
physical_plan
812812
01)UnionExec
813-
02)--ProjectionExec: expr=[count(Int64(1))@1 as count, CAST(n@0 AS Int64) as n]
813+
02)--ProjectionExec: expr=[count(Int64(1))@1 as count, CAST(n@0 AS Int64;N) as n]
814814
03)----AggregateExec: mode=SinglePartitioned, gby=[n@0 as n], aggr=[count(Int64(1))]
815815
04)------ProjectionExec: expr=[5 as n]
816816
05)--------PlaceholderRowExec

0 commit comments

Comments
 (0)