andygrove commented on code in PR #14273:
URL: https://github.com/apache/datafusion/pull/14273#discussion_r1949798289
##########
datafusion/sqllogictest/test_files/tpch/plans/q6.slt.part:
##########
@@ -31,13 +31,13 @@ logical_plan
01)Projection: sum(lineitem.l_extendedprice * lineitem.l_discount) AS revenue
02)--Aggregate: groupBy=[[]], aggr=[[sum(lineitem.l_extendedprice *
lineitem.l_discount)]]
03)----Projection: lineitem.l_extendedprice, lineitem.l_discount
-04)------Filter: lineitem.l_shipdate >= Date32("1994-01-01") AND
lineitem.l_shipdate < Date32("1995-01-01") AND lineitem.l_discount >=
Decimal128(Some(5),15,2) AND lineitem.l_discount <= Decimal128(Some(7),15,2)
AND lineitem.l_quantity < Decimal128(Some(2400),15,2)
-05)--------TableScan: lineitem projection=[l_quantity, l_extendedprice,
l_discount, l_shipdate], partial_filters=[lineitem.l_shipdate >=
Date32("1994-01-01"), lineitem.l_shipdate < Date32("1995-01-01"),
lineitem.l_discount >= Decimal128(Some(5),15,2), lineitem.l_discount <=
Decimal128(Some(7),15,2), lineitem.l_quantity < Decimal128(Some(2400),15,2)]
+04)------Filter: lineitem.l_shipdate >= Date32("1994-01-01") AND
lineitem.l_shipdate < Date32("1995-01-01") AND CAST(lineitem.l_discount AS
Float64) >= Float64(0.049999999999999996) AND CAST(lineitem.l_discount AS
Float64) <= Float64(0.06999999999999999) AND lineitem.l_quantity <
Decimal128(Some(2400),15,2)
+05)--------TableScan: lineitem projection=[l_quantity, l_extendedprice,
l_discount, l_shipdate], partial_filters=[lineitem.l_shipdate >=
Date32("1994-01-01"), lineitem.l_shipdate < Date32("1995-01-01"),
CAST(lineitem.l_discount AS Float64) >= Float64(0.049999999999999996),
CAST(lineitem.l_discount AS Float64) <= Float64(0.06999999999999999),
lineitem.l_quantity < Decimal128(Some(2400),15,2)]
physical_plan
01)ProjectionExec: expr=[sum(lineitem.l_extendedprice * lineitem.l_discount)@0
as revenue]
02)--AggregateExec: mode=Final, gby=[], aggr=[sum(lineitem.l_extendedprice *
lineitem.l_discount)]
03)----CoalescePartitionsExec
04)------AggregateExec: mode=Partial, gby=[],
aggr=[sum(lineitem.l_extendedprice * lineitem.l_discount)]
05)--------CoalesceBatchesExec: target_batch_size=8192
-06)----------FilterExec: l_shipdate@3 >= 1994-01-01 AND l_shipdate@3 <
1995-01-01 AND l_discount@2 >= Some(5),15,2 AND l_discount@2 <= Some(7),15,2
AND l_quantity@0 < Some(2400),15,2, projection=[l_extendedprice@1, l_discount@2]
+06)----------FilterExec: l_shipdate@3 >= 1994-01-01 AND l_shipdate@3 <
1995-01-01 AND CAST(l_discount@2 AS Float64) >= 0.049999999999999996 AND
CAST(l_discount@2 AS Float64) <= 0.06999999999999999 AND l_quantity@0 <
Some(2400),15,2, projection=[l_extendedprice@1, l_discount@2]
Review Comment:
q6 should be comparing decimals in the table and decimal literals in the
query. I agree that the way that DataFusion is currently implementing this is
not ideal, but the query result is correct. This PR currently makes the query
return an incorrect result because it is casting the decimals to an approximate
floating point and then comparing those values to an approximate floating point
representation of the decimal literals in the query.
--
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]