Skip to content

Apache DataFusion SQL Query Engine

Show nullability of an explicit CastExpr target in its display (#26359)

Qi Zhua7c7c08365a3
diff --git a/datafusion/core/tests/sql/explain_analyze.rs b/datafusion/core/tests/sql/explain_analyze.rs
index 4536a7f350..4a11695f9d 100644
--- a/datafusion/core/tests/sql/explain_analyze.rs
+++ b/datafusion/core/tests/sql/explain_analyze.rs
@@ -1146,7 +1146,7 @@ async fn parquet_recursive_projection_pushdown() -> Result<()> {
SortExec: expr=[id@0 ASC NULLS LAST], preserve_partitioning=[false]
RecursiveQueryExec: name=number_series, is_distinct=false
CoalescePartitionsExec
- ProjectionExec: expr=[CAST(id@0 AS Int64) as id, CAST(1 AS Int64) as level]
+ ProjectionExec: expr=[CAST(id@0 AS Int64;N) as id, CAST(1 AS Int64;N) as level]
FilterExec: id@0 = 1
RepartitionExec: partitioning=RoundRobinBatch(NUM_CORES), input_partitions=1
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)]
diff --git a/datafusion/physical-expr/src/expressions/cast.rs b/datafusion/physical-expr/src/expressions/cast.rs
index 3bbb18a22d..c99f9a6867 100644
--- a/datafusion/physical-expr/src/expressions/cast.rs
+++ b/datafusion/physical-expr/src/expressions/cast.rs
@@ -565,7 +565,14 @@ fn deserialize_cast_options(
impl fmt::Display for CastExpr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "CAST({} AS {})", self.expr, self.cast_type())
+ write!(f, "CAST({} AS {}", self.expr, self.cast_type())?;
+ // A cast to an explicit field can change only the nullability (for
+ // example when a union aligns its inputs), so show it the way schemas
+ // do: `;N` marks a nullable field.
+ if self.explicit_target && self.target_field.is_nullable() {
+ write!(f, ";N")?;
+ }
+ write!(f, ")")
}
}
@@ -1840,6 +1847,33 @@ mod tests {
Ok(())
}
+ #[test]
+ fn test_display_explicit_target_nullability() -> Result<()> {
+ let schema = Schema::new(vec![Field::new("a", Int32, false)]);
+
+ // A same-type cast to a nullable field only relabels the nullability
+ let expr = CastExpr::new_with_target_field(
+ col("a", &schema)?,
+ Arc::new(Field::new("a", Int32, true)),
+ None,
+ );
+ assert_eq!(expr.to_string(), "CAST(a@0 AS Int32;N)");
+ assert_eq!(fmt_sql(&expr).to_string(), "CAST(a AS Int32)");
+
+ let expr = CastExpr::new_with_target_field(
+ col("a", &schema)?,
+ Arc::new(Field::new("a", Int32, false)),
+ None,
+ );
+ assert_eq!(expr.to_string(), "CAST(a@0 AS Int32)");
+
+ // A cast to a bare type is unchanged
+ let expr = CastExpr::new(col("a", &schema)?, Int64, None);
+ assert_eq!(expr.to_string(), "CAST(a@0 AS Int64)");
+
+ Ok(())
+ }
+
#[test]
fn type_only_cast_strips_extension_metadata() -> Result<()> {
// When using type-only cast (new()), extension metadata from source should NOT propagate
diff --git a/datafusion/pruning/src/pruning_predicate.rs b/datafusion/pruning/src/pruning_predicate.rs
index 6828c56fc8..b739a6021f 100644
--- a/datafusion/pruning/src/pruning_predicate.rs
+++ b/datafusion/pruning/src/pruning_predicate.rs
@@ -4949,7 +4949,7 @@ mod tests {
#[test]
fn row_group_predicate_cast_int_int() -> Result<()> {
let schema = Schema::new(vec![Field::new("c1", DataType::Int32, false)]);
- 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)";
+ 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)";
// test cast(c1 as int64) = 1
// test column on the left
@@ -4987,7 +4987,7 @@ mod tests {
#[test]
fn row_group_predicate_cast_string_string() -> Result<()> {
let schema = Schema::new(vec![Field::new("c1", DataType::Utf8View, false)]);
- 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)";
+ 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)";
// test column on the left
let expr = cast(col("c1"), DataType::Utf8)
@@ -5051,7 +5051,7 @@ mod tests {
#[test]
fn row_group_predicate_date_date() -> Result<()> {
let schema = Schema::new(vec![Field::new("c1", DataType::Date32, false)]);
- 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)";
+ 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)";
// test column on the left
let expr =
@@ -5150,7 +5150,7 @@ mod tests {
.eq(lit(ScalarValue::Utf8(Some("test".to_string()))));
let predicate_expr =
test_build_predicate_expression(&expr, &schema, &mut RequiredColumns::new());
- 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))";
+ 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)";
assert_eq!(predicate_expr.to_string(), expected_expr);
Ok(())
@@ -5164,7 +5164,7 @@ mod tests {
DataType::Dictionary(Box::new(DataType::UInt8), Box::new(DataType::Int32)),
false,
)]);
- 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)";
+ 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)";
// Test with literal of a different type
let expr =
@@ -5210,7 +5210,7 @@ mod tests {
DataType::Dictionary(Box::new(DataType::UInt8), Box::new(DataType::Date32)),
false,
)]);
- 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))";
+ 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)";
// Test with a cast to a different date type
let expr = cast(
@@ -5282,7 +5282,7 @@ mod tests {
],
false,
));
- 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)";
+ 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 predicate_expr =
test_build_predicate_expression(&expr, &schema, &mut RequiredColumns::new());
assert_eq!(predicate_expr.to_string(), expected_expr);
@@ -5296,7 +5296,7 @@ mod tests {
],
true,
));
- 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))";
+ 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))";
let predicate_expr =
test_build_predicate_expression(&expr, &schema, &mut RequiredColumns::new());
assert_eq!(predicate_expr.to_string(), expected_expr);
@@ -6763,7 +6763,8 @@ mod tests {
let (result_left, _, result_right) =
rewrite_expr_to_prunable(&left_input, Operator::Gt, &right_input, &schema)
.unwrap();
- assert_eq!(result_left.to_string(), left_input.to_string());
+ // The rewrite rebuilds the cast with its nullable target field
+ assert_eq!(result_left.to_string(), "CAST(a@0 AS Decimal128(20, 3);N)");
assert_eq!(result_right.to_string(), right_input.to_string());
// try_cast op lit
diff --git a/datafusion/sqllogictest/test_files/array_agg.slt b/datafusion/sqllogictest/test_files/array_agg.slt
index 5e9fad36e3..a3d839c113 100644
--- a/datafusion/sqllogictest/test_files/array_agg.slt
+++ b/datafusion/sqllogictest/test_files/array_agg.slt
@@ -578,15 +578,15 @@ physical_plan
03)----RepartitionExec: partitioning=Hash([id@0], 4), input_partitions=5
04)------AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[array_agg(DISTINCT a.foo), sum(DISTINCT Int64(1))]
05)--------UnionExec
-06)----------ProjectionExec: expr=[1 as id, CAST(2 AS Int64) as foo]
+06)----------ProjectionExec: expr=[1 as id, CAST(2 AS Int64;N) as foo]
07)------------PlaceholderRowExec
08)----------ProjectionExec: expr=[1 as id, NULL as foo]
09)------------PlaceholderRowExec
10)----------ProjectionExec: expr=[1 as id, NULL as foo]
11)------------PlaceholderRowExec
-12)----------ProjectionExec: expr=[1 as id, CAST(3 AS Int64) as foo]
+12)----------ProjectionExec: expr=[1 as id, CAST(3 AS Int64;N) as foo]
13)------------PlaceholderRowExec
-14)----------ProjectionExec: expr=[1 as id, CAST(2 AS Int64) as foo]
+14)----------ProjectionExec: expr=[1 as id, CAST(2 AS Int64;N) as foo]
15)------------PlaceholderRowExec
#######
diff --git a/datafusion/sqllogictest/test_files/cte.slt b/datafusion/sqllogictest/test_files/cte.slt
index 376fb82a27..fe02e39e3b 100644
--- a/datafusion/sqllogictest/test_files/cte.slt
+++ b/datafusion/sqllogictest/test_files/cte.slt
@@ -171,7 +171,7 @@ logical_plan
07)--------TableScan: nodes projection=[id]
physical_plan
01)RecursiveQueryExec: name=nodes, is_distinct=false
-02)--ProjectionExec: expr=[CAST(1 AS Int64) as id]
+02)--ProjectionExec: expr=[CAST(1 AS Int64;N) as id]
03)----PlaceholderRowExec
04)--CoalescePartitionsExec
05)----ProjectionExec: expr=[id@0 + 1 as id]
@@ -260,7 +260,7 @@ logical_plan
07)--------TableScan: t projection=[n]
physical_plan
01)RecursiveQueryExec: name=t, is_distinct=false
-02)--ProjectionExec: expr=[CAST(1 AS Int64) as n]
+02)--ProjectionExec: expr=[CAST(1 AS Int64;N) as n]
03)----PlaceholderRowExec
04)--CoalescePartitionsExec
05)----ProjectionExec: expr=[n@0 + 1 as n]
@@ -1183,7 +1183,7 @@ logical_plan
07)--------TableScan: numbers projection=[n]
physical_plan
01)RecursiveQueryExec: name=numbers, is_distinct=false
-02)--ProjectionExec: expr=[CAST(1 AS Int64) as n]
+02)--ProjectionExec: expr=[CAST(1 AS Int64;N) as n]
03)----PlaceholderRowExec
04)--CoalescePartitionsExec
05)----ProjectionExec: expr=[n@0 + 1 as n]
@@ -1208,7 +1208,7 @@ logical_plan
07)--------TableScan: numbers projection=[n]
physical_plan
01)RecursiveQueryExec: name=numbers, is_distinct=false
-02)--ProjectionExec: expr=[CAST(1 AS Int64) as n]
+02)--ProjectionExec: expr=[CAST(1 AS Int64;N) as n]
03)----PlaceholderRowExec
04)--CoalescePartitionsExec
05)----ProjectionExec: expr=[n@0 + 1 as n]
@@ -1265,7 +1265,7 @@ logical_plan
physical_plan
01)GlobalLimitExec: skip=0, fetch=5
02)--RecursiveQueryExec: name=r, is_distinct=false
-03)----ProjectionExec: expr=[CAST(0 AS Int64) as k, CAST(0 AS Int64) as v]
+03)----ProjectionExec: expr=[CAST(0 AS Int64;N) as k, CAST(0 AS Int64;N) as v]
04)------PlaceholderRowExec
05)----SortExec: TopK(fetch=1), expr=[v@1 ASC NULLS LAST], preserve_partitioning=[false]
06)------WorkTableExec: name=r
@@ -1693,7 +1693,7 @@ physical_plan
01)ScalarSubqueryExec: subqueries=1
02)--SortExec: expr=[k@0 ASC NULLS LAST, v1@1 ASC NULLS LAST], preserve_partitioning=[false]
03)----RecursiveQueryExec: name=r, is_distinct=false
-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
+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
05)------CoalescePartitionsExec
06)--------ProjectionExec: expr=[k@0 * 10 as k, v1@1 as v1]
07)----------FilterExec: k@0 < scalar_subquery(<pending>)
diff --git a/datafusion/sqllogictest/test_files/cte_materialized.slt b/datafusion/sqllogictest/test_files/cte_materialized.slt
index 74482b01da..cae4a397e8 100644
--- a/datafusion/sqllogictest/test_files/cte_materialized.slt
+++ b/datafusion/sqllogictest/test_files/cte_materialized.slt
@@ -311,7 +311,7 @@ physical_plan
01)MaterializedCteExec: name=r
02)--RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
03)----RecursiveQueryExec: name=r, is_distinct=false
-04)------ProjectionExec: expr=[CAST(1 AS Int64) as n]
+04)------ProjectionExec: expr=[CAST(1 AS Int64;N) as n]
05)--------PlaceholderRowExec
06)------CoalescePartitionsExec
07)--------ProjectionExec: expr=[n@0 + 1 as n]
diff --git a/datafusion/sqllogictest/test_files/file_row_index.slt b/datafusion/sqllogictest/test_files/file_row_index.slt
index c185f43a4a..e594fb99fe 100644
--- a/datafusion/sqllogictest/test_files/file_row_index.slt
+++ b/datafusion/sqllogictest/test_files/file_row_index.slt
@@ -31,7 +31,7 @@ EXPLAIN SELECT file_row_index(), column1 FROM parquet_table
logical_plan
01)Projection: file_row_index(), parquet_table.column1
02)--TableScan: parquet_table projection=[column1]
-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
+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
query II
@@ -78,7 +78,7 @@ logical_plan
physical_plan
01)SortExec: expr=[column1@0 ASC NULLS LAST], preserve_partitioning=[false]
02)--FilterExec: __datafusion_extracted_1@0 > 2, projection=[column1@1]
-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
+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
query I
SELECT column1 FROM parquet_table WHERE file_row_index() > 2 ORDER BY column1
@@ -103,7 +103,7 @@ logical_plan
physical_plan
01)SortExec: expr=[column1@0 ASC NULLS LAST], preserve_partitioning=[false]
02)--FilterExec: __datafusion_extracted_1@0 > 2, projection=[column1@1]
-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
+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
query I
SELECT column1 FROM parquet_table WHERE file_row_index() > 2 ORDER BY column1
diff --git a/datafusion/sqllogictest/test_files/parquet_metadata_functions.slt b/datafusion/sqllogictest/test_files/parquet_metadata_functions.slt
index dbf2c64785..16e05eeb70 100644
--- a/datafusion/sqllogictest/test_files/parquet_metadata_functions.slt
+++ b/datafusion/sqllogictest/test_files/parquet_metadata_functions.slt
@@ -50,7 +50,7 @@ FROM test_table
logical_plan
01)Projection: input_file_name(), file_row_index(), test_table.column1
02)--TableScan: test_table projection=[column1]
-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
+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
# Make sure it also behaves consistently regardless of filter pushdown
diff --git a/datafusion/sqllogictest/test_files/parquet_statistics.slt b/datafusion/sqllogictest/test_files/parquet_statistics.slt
index 84383413fa..e3fcee842e 100644
--- a/datafusion/sqllogictest/test_files/parquet_statistics.slt
+++ b/datafusion/sqllogictest/test_files/parquet_statistics.slt
@@ -172,7 +172,7 @@ EXPLAIN SELECT f32 FROM typed_table WHERE f32 = 2.5;
physical_plan
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))]]
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))]]
-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))]]
+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))]]
# Reversed operand order: literal = column (Float64)
query TT
diff --git a/datafusion/sqllogictest/test_files/union.slt b/datafusion/sqllogictest/test_files/union.slt
index 115a010330..ca83e4b652 100644
--- a/datafusion/sqllogictest/test_files/union.slt
+++ b/datafusion/sqllogictest/test_files/union.slt
@@ -661,7 +661,7 @@ logical_plan
physical_plan
01)CoalescePartitionsExec: fetch=3
02)--UnionExec
-03)----ProjectionExec: expr=[CAST(count(Int64(1))@0 AS Int64) as cnt]
+03)----ProjectionExec: expr=[CAST(count(Int64(1))@0 AS Int64;N) as cnt]
04)------GlobalLimitExec: skip=0, fetch=3
05)--------AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
06)----------CoalescePartitionsExec
@@ -673,7 +673,7 @@ physical_plan
12)----------------------FilterExec: c13@1 != C2GT5KVyOPZpgKVl110TyZO0NcJ434, projection=[c1@0]
13)------------------------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
14)--------------------------DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/testing/data/csv/aggregate_test_100.csv]]}, projection=[c1, c13], file_type=csv, has_header=true
-15)----ProjectionExec: expr=[CAST(1 AS Int64) as cnt]
+15)----ProjectionExec: expr=[CAST(1 AS Int64;N) as cnt]
16)------PlaceholderRowExec
17)----ProjectionExec: expr=[lead(b.c1,Int64(1)) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING@1 as cnt]
18)------GlobalLimitExec: skip=0, fetch=3
@@ -810,7 +810,7 @@ logical_plan
11)----------EmptyRelation: rows=1
physical_plan
01)UnionExec
-02)--ProjectionExec: expr=[count(Int64(1))@1 as count, CAST(n@0 AS Int64) as n]
+02)--ProjectionExec: expr=[count(Int64(1))@1 as count, CAST(n@0 AS Int64;N) as n]
03)----AggregateExec: mode=SinglePartitioned, gby=[n@0 as n], aggr=[count(Int64(1))]
04)------ProjectionExec: expr=[5 as n]
05)--------PlaceholderRowExec