8000 chore: round earlier in TPC-H q15 to try and reduce non-determinism due to aggregating twice by tswast · Pull Request #1877 · googleapis/python-bigquery-dataframes · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions third_party/bigframes_vendored/tpch/queries/q15.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def q(project_id: str, dataset_id: str, session: bigframes.Session):
.agg(TOTAL_REVENUE=bpd.NamedAgg(column="REVENUE", aggfunc="sum"))
.rename(columns={"L_SUPPKEY": "SUPPLIER_NO"})
)
# Round earlier to prevent non-determinism in the later join due to
# differences in distributed floating point operation sort order.
grouped_revenue = grouped_revenue.assign(
TOTAL_REVENUE=grouped_revenue["TOTAL_REVENUE"].round(2)
)

joined_data = bpd.merge(
supplier, grouped_revenue, left_on="S_SUPPKEY", right_on="SUPPLIER_NO"
Expand All @@ -43,10 +48,6 @@ def q(project_id: str, dataset_id: str, session: bigframes.Session):
max_revenue_suppliers = joined_data[
joined_data["TOTAL_REVENUE"] == joined_data["MAX_REVENUE"]
]

max_revenue_suppliers["TOTAL_REVENUE"] = max_revenue_suppliers[
"TOTAL_REVENUE"
].round(2)
q_final = max_revenue_suppliers[
["S_SUPPKEY", "S_NAME", "S_ADDRESS", "S_PHONE", "TOTAL_REVENUE"]
].sort_values("S_SUPPKEY")
Expand Down
0