maropu commented on a change in pull request #26497: [SPARK-29873][SQL][TESTS]
Support `--import` directive to load queries from another test case in
SQLQueryTestSuite
URL: https://github.com/apache/spark/pull/26497#discussion_r346133289
##########
File path:
sql/core/src/test/resources/sql-tests/inputs/ansi/decimalArithmeticOperations.sql
##########
@@ -0,0 +1,32 @@
+-- SPARK-23179: SQL ANSI 2011 states that in case of overflow during
arithmetic operations,
+-- an exception should be thrown instead of returning NULL.
+-- This is what most of the SQL DBs do (eg. SQLServer, DB2).
+
Review comment:
For example, the queries below in `inputs/decimalArithmeticOperations.sql`
throws multiple exceptions with a different error message in executors with
ansi=true;
```
sql("SET spark.sql.decimalOperations.allowPrecisionLoss=false")
sql("SET spark.sql.ansi.enabled=true")
sql("create table decimals_test(id int, a decimal(38,18), b decimal(38,18))
using parquet")
sql("insert into decimals_test values(1, 100.0, 999.0), (2, 12345.123,
12345.123), (3, 0.1234567891011, 1234.1), (4, 123456789123456789.0,
1.123456789123456789)")
sql("select id, a+b, a-b, a*b, a/b from decimals_test order by id").show()
java.lang.ArithmeticException:
Decimal(expanded,138698367904130467.51562262075019052100,38,20}) cannot be
represented as Decimal(38, 36).
at org.apache.spark.sql.types.Decimal.toPrecision(Decimal.scala:357)
at
org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown
Source)
...
java.lang.ArithmeticException:
Decimal(expanded,99900.000000000000000000000000000000000,38,33}) cannot be
represented as Decimal(38, 36).
at org.apache.spark.sql.types.Decimal.toPrecision(Decimal.scala:357)
at
org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown
Source)
at
org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43)
...
java.lang.ArithmeticException:
Decimal(expanded,152.35802342966751000000000000000000000,38,35}) cannot be
represented as Decimal(38, 36).
at org.apache.spark.sql.types.Decimal.toPrecision(Decimal.scala:357)
at
org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown
Source)
at
org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43)
...
<more exceptions below>
```
So, the output string printed in `decimalArithmeticOperations.sql.out`
depends on timing.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]