-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-35017][SQL] Transfer ANSI intervals via Hive Thrift server #32121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } | ||
| } | ||
|
|
||
| test(s"SPARK-35017: $version get day-time interval type") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested only day-time interval because constructing of year-month interval in SQL is not possible at the moment. I created the JIRA for that: SPARK-35018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR #32240 adds a test for year-month intervals.
|
Test build #137168 has finished for PR 32121 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status failure |
| timeFormatters) | ||
| case _: ArrayType | _: StructType | _: MapType | _: UserDefinedType[_] => | ||
| to += toHiveString((from.get(ordinal), dataTypes(ordinal)), false, timeFormatters) | ||
| case YearMonthIntervalType => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about nested types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean the array, map types, they are converted to strings and they don't have a structure that could be recognized by Hive lib. Don't think I can do something here in the PR. This is a restriction of current implementation, and it should be solved in general way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, after the PR #32120 is merged:
0: jdbc:hive2://localhost:10000/default> select array(timestamp'2021-01-01 01:02:03.000001' - date'2020-12-31');
+----------------------------------------------------+
| array(subtracttimestamps(TIMESTAMP '2021-01-01 01:02:03.000001', DATE '2020-12-31')) |
+----------------------------------------------------+
| [1 01:02:03.000001000] |
+----------------------------------------------------+There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the client-side get the plain YearMonthIntervalType/DayTimeIntervalType values via HiveIntervalYearMonth/DayTimeIntervalType.toString, but the ones that in nested types are handled in toHiveString. They look the same but these branches seem to be redundant and may cause inconsistency if the underlying hive changed
Is
case YearMonthIntervalType | DayTimeIntervalType | _: ArrayType | _: StructType | _: MapType | _: UserDefinedType[_] =>better as we handle them consistently at spark-side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do as you propose, I get the exception on my test:
[info] Cause: java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.hadoop.hive.common.type.HiveIntervalDayTime
[info] at org.apache.hive.service.cli.ColumnValue.toTColumnValue(ColumnValue.java:174)
[info] at org.apache.hive.service.cli.RowBasedSet.addRow(RowBasedSet.java:60)
[info] at org.apache.hive.service.cli.RowBasedSet.addRow(RowBasedSet.java:32)
at
case INTERVAL_YEAR_MONTH_TYPE:
return stringValue((HiveIntervalYearMonth) value);
case INTERVAL_DAY_TIME_TYPE:
return stringValue((HiveIntervalDayTime) value);Probably, I could just replace the casting by string casting. Let me try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| import scala.collection.mutable.ArrayBuffer | ||
| import scala.util.control.NonFatal | ||
|
|
||
| import org.apache.hadoop.hive.common.`type`.{HiveIntervalDayTime, HiveIntervalYearMonth} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add HiveIntervalDayTime and HiveIntervalYearMonth to
Lines 97 to 103 in d7dc42d
| val supportedType: Seq[Type] = { | |
| Seq(NULL_TYPE, BOOLEAN_TYPE, STRING_TYPE, BINARY_TYPE, | |
| TINYINT_TYPE, SMALLINT_TYPE, INT_TYPE, BIGINT_TYPE, | |
| FLOAT_TYPE, DOUBLE_TYPE, DECIMAL_TYPE, | |
| DATE_TYPE, TIMESTAMP_TYPE, | |
| ARRAY_TYPE, MAP_TYPE, STRUCT_TYPE, CHAR_TYPE, VARCHAR_TYPE) | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
Test build #137181 has finished for PR 32121 at commit
|
|
Kubernetes integration test unable to build dist. exiting with code: 1 |
yaooqinn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
HyukjinKwon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks making sense to me.
|
Merged to master. |
|
late LGTM |
What changes were proposed in this pull request?
interval_year_monthinterval_day_timeHiveResult.toHiveString()to convert external intervals typesjava.time.Period/java.time.Durationto strings.Why are the changes needed?
SQLQueryTestSuite/ThriftServerQueryTestSuite#32099 which enables*.sqltests inThriftServerQueryTestSuite.Does this PR introduce any user-facing change?
Yes. After the changes:
How was this patch tested?
By running new test:
Also checked an array of an interval: