MaxGekk opened a new pull request #32121:
URL: https://github.com/apache/spark/pull/32121


   ### What changes were proposed in this pull request?
   1. Map Catalyst's interval types to Hive's types:
       - YearMonthIntervalType -> `interval_year_month`
       - DayTimeIntervalType -> `interval_day_time`
   2. Convert external interval types collected from Spark to Hive's types:
       - java.time.Period -> HiveIntervalYearMonth
       - java.time.Duration -> HiveIntervalDayTime
   
   ### Why are the changes needed?
   1. To be able to retrieve ANSI intervals via Hive Thrift server.
   2. This fixes the issue:
   ```sql
    $ ./sbin/start-thriftserver.sh
    $ ./bin/beeline
   Beeline version 2.3.8 by Apache Hive
   beeline> !connect jdbc:hive2://localhost:10000/default "" "" ""
   Connecting to jdbc:hive2://localhost:10000/default
   Connected to: Spark SQL (version 3.2.0-SNAPSHOT)
   0: jdbc:hive2://localhost:10000/default> select timestamp'2021-01-01 
01:02:03.000001' - date'2020-12-31';
   Error: java.lang.IllegalArgumentException: Unrecognized type name: day-time 
interval (state=,code=0)
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. After the changes:
   ```sql
   0: jdbc:hive2://localhost:10000/default> select timestamp'2021-01-01 
01:02:03.000001' - date'2020-12-31';
   +----------------------------------------------------+
   | subtracttimestamps(TIMESTAMP '2021-01-01 01:02:03.000001', DATE 
'2020-12-31') |
   +----------------------------------------------------+
   | 1 01:02:03.000001000                               |
   +----------------------------------------------------+
   1 row selected (1.637 seconds)
   ```
   
   ### How was this patch tested?
   By running new test:
   ```
   $ ./build/sbt -Phive -Phive-thriftserver "test:testOnly 
*SparkThriftServerProtocolVersionsSuite"
   ```


-- 
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to