[
https://issues.apache.org/jira/browse/GOBBLIN-1774?focusedWorklogId=844864&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-844864
]
ASF GitHub Bot logged work on GOBBLIN-1774:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 10/Feb/23 18:47
Start Date: 10/Feb/23 18:47
Worklog Time Spent: 10m
Work Description: homatthew commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1103108455
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -261,27 +259,69 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit
unit) {
return si;
}
+ public static boolean containsNonOptionalUnionTypeColumn(Table t) {
+ return containsNonOptionalUnionTypeColumn(getHiveTable(t));
+ }
+
/**
- * Util for detecting if {@param hiveTable} has a non-optional union (aka
complex unions) column types. A non optional
- * union is defined as a uniontype with multiple possible types and none of
them are null
+ * Util for detecting if a hive table has a non-optional union (aka complex
unions) column types. A non optional
+ * union is defined as a uniontype with n >= 2 non-null subtypes
*
- * @param hiveTable
- * @return if hive table contains complex uniontype columns
+ * @param hiveTable Hive table
+ * @return if hive table contains non-optional uniontype columns
*/
public static boolean containsNonOptionalUnionTypeColumn(HiveTable
hiveTable) {
- if (!isAvroFormat(hiveTable)) {
- // All values in ORC are optional / nullable
- return false;
+ if (hiveTable.getProps().contains("avro.schema.literal")) {
+ Schema.Parser parser = new Schema.Parser();
+ Schema schema =
parser.parse(hiveTable.getProps().getProp("avro.schema.literal"));
+ return isNonOptionalUnion(schema);
}
- return hiveTable.getColumns().stream()
- .map(HiveRegistrationUnit.Column::getType)
- .map(Object::toString)
- .anyMatch(columnType -> columnType.contains("uniontype") &&
!columnType.contains("void"));
+ if (isNonAvroFormat(hiveTable)) {
Review Comment:
This is a fallback case if schema literal is not set. Where we can use the
ORC type parser to determine if the column is a non-optional union.
This does not work if the underlying table is not ORC based
Issue Time Tracking
-------------------
Worklog Id: (was: 844864)
Time Spent: 2h 10m (was: 2h)
> Add utility method for GMIP, MR compaction, and Incremental to skip override
> hive schema on topics with complex union
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: GOBBLIN-1774
> URL: https://issues.apache.org/jira/browse/GOBBLIN-1774
> Project: Apache Gobblin
> Issue Type: Improvement
> Reporter: Matthew Ho
> Priority: Major
> Time Spent: 2h 10m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)