MaxGekk commented on code in PR #36857:
URL: https://github.com/apache/spark/pull/36857#discussion_r898176537
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuiteBase.scala:
##########
@@ -1272,4 +1272,37 @@ abstract class CastSuiteBase extends SparkFunSuite with
ExpressionEvalHelper {
"to restore the behavior before Spark 3.0."))
}
}
+
+ test("cast ANSI intervals to decimals") {
+ Seq(
Review Comment:
No, we don't round and don't loose info. See the last check that I added:
```
select cast(interval '10.123' second as decimal(1, 0))
-- !query schema
struct<>
-- !query output
org.apache.spark.SparkArithmeticException
[CANNOT_CHANGE_DECIMAL_PRECISION] Decimal(compact, 10, 18, 6) cannot be
represented as Decimal(1, 0). If necessary set "spark.sql.ansi.enabled" to
"false" to bypass this error.
== SQL(line 1, position 8) ==
select cast(interval '10.123' second as decimal(1, 0))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Both of your cases are the same, actually - total number of digits is
greater than 3 or 4.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]