Skip to content

Commit 4a25fff

Browse files
author
Shiv Bhatia
committed
Add comment explaining difference between spark and datafusion in slt test
1 parent aa3f06b commit 4a25fff

2 files changed

Lines changed: 45 additions & 34 deletions

File tree

Cargo.lock

Lines changed: 34 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion/sqllogictest/test_files/spark/math/round.slt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@
2121
# For more information, please see:
2222
# https://github.com/apache/datafusion/issues/15914
2323

24+
# Tests for Spark-compatible round function.
25+
# Spark semantics differ from DataFusion's built-in round in two ways:
26+
# 1. Integer rounding: Spark rounds integer types in-place (preserving the type) when d < 0,
27+
# with overflow checking in ANSI mode; DataFusion coerces integers to Float64
28+
# 2. Decimal precision: Spark adjusts Decimal128 precision/scale based on d;
29+
# DataFusion preserves the original precision and scale
30+
#
31+
# Example: SELECT round(1250::BIGINT, -2)
32+
# Spark: returns BIGINT value 1300
33+
# DataFusion: returns DOUBLE value 1300.0
34+
2435
## Original Query: SELECT round(2.5, 0);
2536
## PySpark 3.5.5 Result: {'round(2.5, 0)': Decimal('3'), 'typeof(round(2.5, 0))': 'decimal(2,0)', 'typeof(2.5)': 'decimal(2,1)', 'typeof(0)': 'int'}
2637
query R

0 commit comments

Comments
 (0)