yaooqinn commented on a change in pull request #26410:
[SPARK-29387][SQL][FOLLOWUP] Fix issues of the multiply and divide for intervals
URL: https://github.com/apache/spark/pull/26410#discussion_r343050895
##########
File path: sql/core/src/test/resources/sql-tests/inputs/datetime.sql
##########
@@ -41,3 +41,21 @@ select timestamp'2019-10-06 10:11:12.345678' -
date'2020-01-01';
select 3 * (timestamp'2019-10-15 10:11:12.001002' - date'2019-10-15');
select interval 4 month 2 weeks 3 microseconds * 1.5;
select (timestamp'2019-10-15' - timestamp'2019-10-14') / 1.5;
+
+-- interval operation with null and zero case
+select interval '1 year 2 month' / null;
+select interval '1 year 2 month' / 0;
+select interval '4 months 2 weeks 6 days' * null;
+select null * interval '4 months 2 weeks 6 days';
Review comment:
We are not facing the either-or thing here, it's the conflicting results by
`a)` and `b)`
If the style here bothers you, we may change it like this, WDYT?
```sql
-- zero division
select interval '2 seconds' / 0;
select cast(k as interval) / v from VALUES ('2 seconds', 0) t(k, v);
-- null division
select interval '2 seconds' / null;
-- null multiplication
select interval '2 seconds' * null;
select null * interval '2 seconds';
```
----------------------------------------------------------------
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]