spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] MaxGekk opened a new pull request #25708: [SPARK-28141][SQL] Support special date values
Date Fri, 06 Sep 2019 08:46:44 GMT
MaxGekk opened a new pull request #25708: [SPARK-28141][SQL] Support special date values
URL: https://github.com/apache/spark/pull/25708
 
 
   ### What changes were proposed in this pull request?
   
   Supported special string values for `DATE` type. They are simply notational shorthands
that will be converted to ordinary date values when read. The following string values are
supported:
   - `epoch` - `1970-01-01`
   - `now` - the date of running the current query
   - `today` - the current date. The same as `now`.
   - `yesterday` - the current date -1
   - `tomorrow` - the current date + 1
   
   For example:
   ```sql
   spark-sql> SELECT date 'tomorrow' - date 'yesterday';
   2
   ```
   
   ### Why are the changes needed?
   
   To maintain feature parity with PostgreSQL, see [8.5.1.4. Special Values](https://www.postgresql.org/docs/12/datatype-datetime.html)
   
   
   ### Does this PR introduce any user-facing change?
   
   Previously, the parser fails on the special values with the error:
   ```sql
   spark-sql> select date 'today';
   Error in query: 
   Cannot parse the DATE value: today(line 1, pos 7)
   ```
   After the changes, the special values are converted to appropriate dates:
   ```sql
   spark-sql> select date 'today';
   2019-09-06
   ```
   
   ### How was this patch tested?
   - Added tests to `DateFormatterSuite` to check parsing special values from regular strings.
   - Tests in `DateTimeUtilsSuite` check parsing those values from `UTF8String`
   - Uncommented tests in `date.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


Mime
View raw message