Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update
  • Loading branch information
haohuaijin committed Sep 19, 2026
commit 0d64ef4533e1d01d788f72e8b91d76893a446f37
27 changes: 27 additions & 0 deletions datafusion/sqllogictest/test_files/parquet_statistics.slt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,33 @@ physical_plan
statement ok
DROP TABLE cast_stats_ints;

# An out-of-range minimum or maximum must prevent aggregate folding and preserve
# the runtime cast error, even when the other endpoint fits in Int8.
statement ok
COPY (SELECT CAST(a AS BIGINT) AS a, CAST(b AS BIGINT) AS b
FROM (VALUES (-129, -128), (0, 0), (127, 128), (NULL, NULL)) AS t(a, b))
TO 'test_files/scratch/parquet_statistics/cast_ints_overflow.parquet' STORED AS PARQUET;

statement ok
CREATE EXTERNAL TABLE cast_stats_ints_overflow STORED AS PARQUET
LOCATION 'test_files/scratch/parquet_statistics/cast_ints_overflow.parquet';

query error Cast error: Can't cast value -129 to type Int8
SELECT MIN(CAST(a AS TINYINT)), MAX(CAST(a AS TINYINT)) FROM cast_stats_ints_overflow;

query error Cast error: Can't cast value 128 to type Int8
SELECT MIN(CAST(b AS TINYINT)), MAX(CAST(b AS TINYINT)) FROM cast_stats_ints_overflow;

query TT
EXPLAIN SELECT MIN(CAST(a AS TINYINT)), MAX(CAST(a AS TINYINT)) FROM cast_stats_ints_overflow;
----
physical_plan
01)AggregateExec: mode=Single, gby=[], aggr=[min(cast_stats_ints_overflow.a), max(cast_stats_ints_overflow.a)]
02)--DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_statistics/cast_ints_overflow.parquet]]}, projection=[CAST(a@0 AS Int8) as __common_expr_1], file_type=parquet

statement ok
DROP TABLE cast_stats_ints_overflow;

statement ok
SET datafusion.execution.target_partitions = 4;

Expand Down
Loading