b10344956d
### What changes were proposed in this pull request? In the PR, I propose to pass the `Pattern.CASE_INSENSITIVE` flag while compiling interval patterns in `CalendarInterval`. This makes casting string values to intervals case insensitive and tolerant to case of the `interval`, `year(s)`, `month(s)`, `week(s)`, `day(s)`, `hour(s)`, `minute(s)`, `second(s)`, `millisecond(s)` and `microsecond(s)`. ### Why are the changes needed? There are at least 2 reasons: - To maintain feature parity with PostgreSQL which is not sensitive to case: ```sql # select cast('10 Days' as INTERVAL); interval ---------- 10 days (1 row) ``` - Spark is tolerant to case of interval literals. Case insensitivity in casting should be convenient for Spark users. ```sql spark-sql> SELECT INTERVAL 1 YEAR 1 WEEK; interval 1 years 1 weeks ``` ### Does this PR introduce any user-facing change? Yes, current implementation produces `NULL` for `interval`, `year`, ... `microsecond` that are not in lower case. Before: ```sql spark-sql> SELECT CAST('INTERVAL 10 DAYS' as INTERVAL); NULL ``` After: ```sql spark-sql> SELECT CAST('INTERVAL 10 DAYS' as INTERVAL); interval 1 weeks 3 days ``` ### How was this patch tested? - by new tests in `CalendarIntervalSuite.java` - new test in `CastSuite` Closes #26010 from MaxGekk/interval-case-insensitive. Authored-by: Maxim Gekk <max.gekk@gmail.com> Signed-off-by: Dongjoon Hyun <dhyun@apple.com> |
||
---|---|---|
.. | ||
benchmarks | ||
src | ||
pom.xml |