You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having some trouble understanding the behavior of a query against tpch.tiny. The query is simplified from a part of TPC-H query 15:
WITH t0 AS (
SELECT
suppkey,
SUM(extendedprice * (1- discount)) AS total_revenue
FROMtpch.tiny.lineitem
WHERE
shipdate >= CAST('1996-01-01'ASdate)
AND shipdate < CAST('1996-04-01'ASdate)
GROUP BY1
)
SELECT*FROM t0
WHEREt0.total_revenue= (
SELECTMAX(total_revenue) FROM t0
)
When I put this query into a file (e.g., /data/query.sql) and then run that file I sometimes get an empty table and I sometimes get one row. I would expect there to always be one row, since there should always be at least one value equal to the max and there are no NULL values of total_revenue.
Even without floating point associativity, I would still expect there to always be at least one value of total_revenue equal to the max given that there are no NULLs in the column.
The text was updated successfully, but these errors were encountered:
The WITH clause t0 is evaluated twice, once in the SELECT * FROM t0 clause and once in the SELECT MAX(total_revenue) FROM t0 clause. If they produce different results due to floating point behavior, the WHERE clause will evaluate to false.
I'm having some trouble understanding the behavior of a query against
tpch.tiny
. The query is simplified from a part of TPC-H query 15:When I put this query into a file (e.g.,
/data/query.sql
) and then run that file I sometimes get an empty table and I sometimes get one row. I would expect there to always be one row, since there should always be at least one value equal to the max and there are noNULL
values oftotal_revenue
.I see that when I compute only
I get slightly different results due to what looks like floating point arithmetic not being associative:
Even without floating point associativity, I would still expect there to always be at least one value of
total_revenue
equal to the max given that there are noNULL
s in the column.The text was updated successfully, but these errors were encountered: