yaooqinn commented on issue #26410: [SPARK-29387][SQL][FOLLOWUP] Fix issues of 
the multiply and divide for intervals
URL: https://github.com/apache/spark/pull/26410#issuecomment-550222012
 
 
   Postgres will error by division of zero whether with literal or columns, 
which is NULL in Spark(Should be fine).
   ```sql
   postgres=# select interval '1 year' / null;
    ?column?
   ----------
   
   (1 row)
   
   postgres=# select interval '1 year' * null;
    ?column?
   ----------
   
   (1 row)
   
   postgres=# select interval '1 year' / null;
    ?column?
   ----------
   
   (1 row)
   
   postgres=# select interval '1 year' / 0;
   ERROR:  division by zero
   postgres=# select interval '1 year' / 0;
   ERROR:  division by zero
   postgres=# select k, v, cast(k as interval) / v, cast(k as interval) * v 
from (VALUES ('1 seconds', 1),('2 seconds', 0),('3 seconds', null),(null, 
null),(null, 0)) t(k, v)
   postgres-# ;
   ERROR:  division by zero
   postgres=# select k, v, cast(k as interval) / v, cast(k as interval) * v 
from (VALUES ('1 seconds', 1),('2 seconds', 0.0),('3 seconds', null),(null, 
null),(null, 0.0)) t(k, v)
   ```

----------------------------------------------------------------
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]

Reply via email to