haohuaijin commented on code in PR #25985: URL: https://github.com/apache/datafusion/pull/25985#discussion_r4171461111
########## datafusion/sqllogictest/test_files/parquet_statistics.slt: ########## @@ -222,6 +222,37 @@ physical_plan statement ok DROP TABLE mul_wrap; +###### +# Division with a zero numerator endpoint must not infer an empty filter +###### + +statement ok +COPY ( + SELECT * FROM (VALUES (-3, -1), (-2, -1), (0, -2)) AS t(a, b) +) +TO 'test_files/scratch/parquet_statistics/div_zero_endpoint.parquet' STORED AS PARQUET; + +statement ok +CREATE EXTERNAL TABLE div_zero_endpoint STORED AS PARQUET +LOCATION 'test_files/scratch/parquet_statistics/div_zero_endpoint.parquet'; + +# [-3,0] / [-2,-1] must include 2 and 3, rather than being narrowed to [0,1]. +query III +SELECT a, b, a / b AS q FROM div_zero_endpoint WHERE a / b > 1 ORDER BY a; +---- +-3 -1 3 +-2 -1 2 + +query TT +EXPLAIN SELECT a, b FROM div_zero_endpoint WHERE a / b > 1; +---- +physical_plan +01)FilterExec: a@0 / b@1 > 1, statistics=[Rows=Inexact(3), Bytes=Inexact(48), [(Col[0]: Min=Inexact(Int64(-3)) Max=Inexact(Int64(0)) Null=Inexact(0) ScanBytes=Inexact(24)),(Col[1]: Min=Inexact(Int64(-2)) Max=Inexact(Int64(-1)) Null=Inexact(0) ScanBytes=Inexact(24))]] Review Comment: On main before this fix, `FilterExec` reports `Rows=Inexact(0), with Min/Max=Exact(Int64(NULL))` and `Distinct=Exact(0)` for both columns, despite returning two matching rows. With this fix, the bounds remain conservative and the estimate becomes Inexact(3), rather than incorrectly indicating an empty result. -- 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]
