spark-instrumented-optimizer/common
Maxim Gekk b10344956d [SPARK-29342][SQL] Make casting of string values to intervals case insensitive
### 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>
2019-10-07 09:33:01 -07:00
..
kvstore [MINOR][BUILD] Fix about 15 misc build warnings 2019-09-19 11:37:42 -07:00
network-common [SPARK-25341][CORE] Support rolling back a shuffle map stage and re-generate the shuffle files 2019-09-23 16:16:52 +08:00
network-shuffle [SPARK-25341][CORE] Support rolling back a shuffle map stage and re-generate the shuffle files 2019-09-23 16:16:52 +08:00
network-yarn [SPARK-28593][CORE] Rename ShuffleClient to BlockStoreClient which more close to its usage 2019-08-05 14:54:45 +08:00
sketch [SPARK-28604][ML] Use log1p(x) over log(1+x) and expm1(x) over exp(x)-1 for accuracy 2019-08-04 17:04:01 -05:00
tags [SPARK-29191][TESTS][SQL] Add tag ExtendedSQLTest for SQLQueryTestSuite 2019-09-22 13:53:21 -07:00
unsafe [SPARK-29342][SQL] Make casting of string values to intervals case insensitive 2019-10-07 09:33:01 -07:00