0e761c7307
### What changes were proposed in this pull request? 1. Extend `IntervalUtils` methods: `toYearMonthIntervalString` and `toDayTimeIntervalString` to support formatting of year-month/day-time intervals in Hive style. The methods get new parameter style which can have to values; `HIVE_STYLE` and `ANSI_STYLE`. 2. Invoke `toYearMonthIntervalString` and `toDayTimeIntervalString` from the `Cast` expression with the `style` parameter is set to `ANSI_STYLE`. 3. Invoke `toYearMonthIntervalString` and `toDayTimeIntervalString` from `HiveResult` with `style` is set to `HIVE_STYLE`. ### Why are the changes needed? The `spark-sql` shell formats its output in Hive style by using `HiveResult.hiveResultString()`. The changes are needed to match Hive behavior. For instance, Hive: ```sql 0: jdbc:hive2://localhost:10000/default> select timestamp'2021-01-01 01:02:03.000001' - date'2020-12-31'; +-----------------------+ | _c0 | +-----------------------+ | 1 01:02:03.000001000 | +-----------------------+ ``` Spark before the changes: ```sql spark-sql> select timestamp'2021-01-01 01:02:03.000001' - date'2020-12-31'; INTERVAL '1 01:02:03.000001' DAY TO SECOND ``` Also this should unblock #32099 which enables *.sql tests in `SQLQueryTestSuite`. ### Does this PR introduce _any_ user-facing change? Yes. After the changes: ```sql spark-sql> select timestamp'2021-01-01 01:02:03.000001' - date'2020-12-31'; 1 01:02:03.000001000 ``` ### How was this patch tested? 1. Added new tests to `IntervalUtilsSuite`: ``` $ build/sbt "test:testOnly *IntervalUtilsSuite" ``` 2. Modified existing tests in `HiveResultSuite`: ``` $ build/sbt -Phive-2.3 -Phive-thriftserver "testOnly *HiveResultSuite" ``` 3. By running cast tests: ``` $ build/sbt "testOnly *CastSuite*" ``` Closes #32120 from MaxGekk/ansi-intervals-hive-thrift-server. Authored-by: Max Gekk <max.gekk@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com> |
||
---|---|---|
.. | ||
benchmarks | ||
src | ||
pom.xml |