Skip to content

Commit 03644fe

Browse files
committed
address comments
1 parent cf3b372 commit 03644fe

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/sql-programming-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@ options.
17951795

17961796
- Since Spark 2.3, when all inputs are binary, SQL `elt()` returns an output as binary. Otherwise, it returns as a string. Until Spark 2.3, it always returns as a string despite of input types. To keep the old behavior, set `spark.sql.function.eltOutputAsString` to `true`.
17971797

1798-
- Since Spark 2.3, by default arithmetic operations return a rounded value if an exact representation is not possible. This is compliant to SQL standards and Hive's behavior introduced in HIVE-15331. This involves the following changes
1798+
- Since Spark 2.3, by default arithmetic operations between decimals return a rounded value if an exact representation is not possible. This is compliant to SQL standards and Hive's behavior introduced in HIVE-15331. This involves the following changes
17991799
- The rules to determine the result type of an arithmetic operation have been updated. In particular, if the precision / scale needed are out of the range of available values, the scale is reduced up to 6, in order to prevent the truncation of the integer part of the decimals.
18001800
- Literal values used in SQL operations are converted to DECIMAL with the exact precision and scale needed by them.
18011801
- The configuration `spark.sql.decimalOperations.allowPrecisionLoss` has been introduced. It defaults to `true`, which means the new behavior described here; if set to `false`, Spark will use the previous rules and behavior.

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DecimalPrecision.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ object DecimalPrecision extends TypeCoercionRule {
278278
private val nondecimalAndDecimal: PartialFunction[Expression, Expression] = {
279279
// Promote integers inside a binary expression with fixed-precision decimals to decimals,
280280
// and fixed-precision decimals in an expression with floats / doubles to doubles
281-
case b@BinaryOperator(left, right) if left.dataType != right.dataType =>
281+
case b @ BinaryOperator(left, right) if left.dataType != right.dataType =>
282282
(left, right) match {
283283
// Promote literal integers inside a binary expression with fixed-precision decimals to
284284
// decimals. The precision and scale are the ones strictly needed by the integer value.

0 commit comments

Comments
 (0)