You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "haohuaijin (via GitHub)" <gi...@apache.org> on 2026/09/12 11:35:47 UTC

[I] CAST statistics can produce incorrect MIN/MAX results [datafusion]

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: github-unsubscribe@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] CAST statistics can produce incorrect MIN/MAX results [datafusion]

Posted by "haohuaijin (via GitHub)" <gi...@apache.org>.
haohuaijin commented on issue #25221:
URL: https://github.com/apache/datafusion/issues/25221#issuecomment-5645635576

   take


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] CAST statistics can produce incorrect MIN/MAX results [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #25221: CAST statistics can produce incorrect MIN/MAX results
URL: https://github.com/apache/datafusion/issues/25221


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org