You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/10/18 13:37:59 UTC

[GitHub] [spark] MaxGekk opened a new pull request #26165: [SPARK-29508][SQL] Implicitly cast strings in datetime arithmetic operations

MaxGekk opened a new pull request #26165: [SPARK-29508][SQL] Implicitly cast strings in datetime arithmetic operations
URL: https://github.com/apache/spark/pull/26165
 
 
   ### What changes were proposed in this pull request?
   - Cast strings to intervals in `interval - string`. For example:
   ```sql
   spark-sql> select interval '1 month' - '1 day 2 hours';
   interval 1 months -1 days -2 hours
   ```
   - Cast strings to intervals in `datetime + string` or `string + datetime`. For example:
   ```sql
   spark-sql> select timestamp'today' + '1 month';
   2019-11-18 00:00:00
   ```
   - Cast strings to timestamps in `datetime - string` or `string - datetime`. For example:
   ```sql
   spark-sql> select date'today' - '2019-10-01';
   interval 2 weeks 3 days
   ```
   
   ### Why are the changes needed?
   To improve user experience with Spark SQL
   
   ### Does this PR introduce any user-facing change?
   Yes, previously the operations fails with the errors:
   ```
   spark-sql> select timestamp'today' + '1 month';
   Error in query: cannot resolve '(TIMESTAMP('2019-10-18 00:00:00') + CAST('1 month' AS DOUBLE))' due to data type mismatch: differing types in '(TIMESTAMP('2019-10-18 00:00:00') + CAST('1 month' AS DOUBLE))' (timestamp and double).; line 1 pos 7;
   'Project [unresolvedalias((1571346000000000 + cast(1 month as double)), None)]
   +- OneRowRelation
   ```
   
   ### How was this patch tested?
   - Add tests to `TypeCoercionSuite` to check rules
   - End-to-end tests in `dateTimeOperations.sql`
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org