haohuaijin opened a new issue, #25221:
URL: https://github.com/apache/datafusion/issues/25221
### Describe the bug
Casting string min/max statistics to integers does not preserve their
ordering. Aggregate optimization can therefore return incorrect results.
### To Reproduce
```sql
SET datafusion.execution.target_partitions = 1;
SET datafusion.execution.collect_statistics = true;
COPY (SELECT * FROM (VALUES ('1'), ('100'), ('2')) AS t(a))
TO '/tmp/cast_statistics.parquet' STORED AS PARQUET;
CREATE EXTERNAL TABLE t STORED AS PARQUET
LOCATION '/tmp/cast_statistics.parquet';
SELECT MIN(CAST(a AS INT)), MAX(CAST(a AS INT)) FROM t;
```
Actual: `1, 2`. Expected: `1, 100`. The same issue occurs with BIGINT.
### Expected behavior
Only propagate CAST statistics when the conversion is proven safe for the
supplied bounds.
### Additional context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]