You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by "homatthew (via GitHub)" <gi...@apache.org> on 2023/01/31 22:32:50 UTC
[GitHub] [gobblin] homatthew opened a new pull request, #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
homatthew opened a new pull request, #3632:
URL: https://github.com/apache/gobblin/pull/3632
- This util will be used across GMIP and compaction to handle non optional unions Non optional unions are compatible with Avro / Orc but not in Iceberg, so special workarounds are necessary to have tables with both types of data
Dear Gobblin maintainers,
Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
### JIRA
- [ ] My PR addresses the following [Gobblin JIRA](https://issues.apache.org/jira/browse/GOBBLIN/) issues and references them in the PR title. For example, "[GOBBLIN-XXX] My Gobblin PR"
- https://issues.apache.org/jira/browse/GOBBLIN-XXX
### Description
- [ ] Here are some details about my PR, including screenshots (if applicable):
### Tests
- [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
### Commits
- [ ] My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
1. Subject is separated from body by a blank line
2. Subject is limited to 50 characters
3. Subject does not end with a period
4. Subject uses the imperative mood ("add", not "adding")
5. Body wraps at 72 characters
6. Body explains "what" and "why", not "how"
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] vikrambohra commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "vikrambohra (via GitHub)" <gi...@apache.org>.
vikrambohra commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1097936139
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +256,23 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ /**
+ * Util for detecting if a table has a complex union (aka non-optional unions) column types. Iceberg currently does
+ * not natively support uniontype because types differently as structs. Until this feature is added in iceberg, this
+ * function can be used to detect these types of tables for gobblin specific workarounds
+ *
+ * See https://github.com/apache/iceberg/issues/189
+ *
+ * @param t
+ * @return if hive table contains complex uniontype columns
+ */
+ public static boolean containsUnionTypeColumn(HiveTable t) {
Review Comment:
Can we have another method that takes Hive native table object instead of Gobblin Hive Table wrapper object and one calling the other?
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +256,23 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ /**
+ * Util for detecting if a table has a complex union (aka non-optional unions) column types. Iceberg currently does
Review Comment:
This is a simple utility method to tell if a hive table contains a complex union. Lets not complicate my mentioning iceberg.
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] homatthew commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1102036987
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +261,29 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ /**
+ * 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
+ *
+ * @param hiveTable
+ * @return if hive table contains complex uniontype columns
+ */
+ public static boolean containsNonOptionalUnionTypeColumn(HiveTable hiveTable) {
+ if (!isAvroFormat(hiveTable)) {
+ // All values in ORC are optional / nullable
+ return false;
+ }
+
+ return hiveTable.getColumns().stream()
+ .map(HiveRegistrationUnit.Column::getType)
+ .map(Object::toString)
+ .anyMatch(columnType -> columnType.contains("uniontype") && !columnType.contains("void"));
Review Comment:
You are correct. Upon verifying the definition in https://docs.google.com/document/d/1Go2NrOoeCKfrDJw8MAZnsMYbE2KZbso1zkSY8cpLzaQ/edit#heading=h.gd2qof50gbzs, it seems like there was some confusion on what is "non-optional" / complex.
The correct definition as described in the document is:
>Non-optional union: A union type with more than one non-null option type
e.g. [“int”, “string”] or [“null”, “int”, “string”]
Alternate phrasing:
> A schema where there 's a union type of >= 2 branches which are non null.
>[int, null] - no
[int, string] - yes
[int, string, null] yes
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] homatthew commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1102036987
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +261,29 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ /**
+ * 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
+ *
+ * @param hiveTable
+ * @return if hive table contains complex uniontype columns
+ */
+ public static boolean containsNonOptionalUnionTypeColumn(HiveTable hiveTable) {
+ if (!isAvroFormat(hiveTable)) {
+ // All values in ORC are optional / nullable
+ return false;
+ }
+
+ return hiveTable.getColumns().stream()
+ .map(HiveRegistrationUnit.Column::getType)
+ .map(Object::toString)
+ .anyMatch(columnType -> columnType.contains("uniontype") && !columnType.contains("void"));
Review Comment:
You are correct. Upon verifying the definition in [this iceberg doc](https://docs.google.com/document/d/1Go2NrOoeCKfrDJw8MAZnsMYbE2KZbso1zkSY8cpLzaQ/edit#heading=h.gd2qof50gbzs), it seems like there was some confusion on what is "non-optional" / complex.
- Source: https://github.com/apache/iceberg/issues/189
The correct definition as described in the document is:
>Non-optional union: A union type with more than one non-null option type
e.g. [“int”, “string”] or [“null”, “int”, “string”]
Alternate phrasing:
> A schema where there 's a union type of >= 2 branches which are non null.
>[int, null] - no
[int, string] - yes
[int, string, null] yes
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] homatthew commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1093863646
##########
gobblin-hive-registration/src/test/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtilsTest.java:
##########
@@ -212,4 +217,84 @@ public void testGetHiveTable() throws Exception {
Assert.assertEquals(fieldA.getType(), "int");
}
+
+ @Test
+ public void testContainsUnionType_AvroSucceeds() {
+ final String databaseName = "db";
+ final String tableName = "tbl";
+ final State serdeProps = new State();
+
+ serdeProps.setProp("avro.schema.literal", "{\"type\": \"record\", \"name\": \"TestEvent\","
+ + " \"namespace\": \"test.namespace\", \"fields\": [{\"name\":\"aUnionField\", \"type\": [\"string\", \"int\"]}]}");
+ HiveTable hiveTable = createTestHiveTable_Avro(databaseName, tableName, serdeProps);
+
+ Assert.assertTrue(HiveMetaStoreUtils.containsUnionTypeColumn(hiveTable));
Review Comment:
And so when we register a table with this schema to hive, the column type will contain "uniontype". Hence why this test passes.
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] umustafi commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "umustafi (via GitHub)" <gi...@apache.org>.
umustafi commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1093855867
##########
gobblin-hive-registration/src/test/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtilsTest.java:
##########
@@ -212,4 +217,84 @@ public void testGetHiveTable() throws Exception {
Assert.assertEquals(fieldA.getType(), "int");
}
+
+ @Test
+ public void testContainsUnionType_AvroSucceeds() {
+ final String databaseName = "db";
+ final String tableName = "tbl";
+ final State serdeProps = new State();
+
+ serdeProps.setProp("avro.schema.literal", "{\"type\": \"record\", \"name\": \"TestEvent\","
+ + " \"namespace\": \"test.namespace\", \"fields\": [{\"name\":\"aUnionField\", \"type\": [\"string\", \"int\"]}]}");
+ HiveTable hiveTable = createTestHiveTable_Avro(databaseName, tableName, serdeProps);
+
+ Assert.assertTrue(HiveMetaStoreUtils.containsUnionTypeColumn(hiveTable));
Review Comment:
in the function above it looks like its looking for a `uniontype` column name and that's not here although i do see `aUnionField` has multiple options for type.
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] vikrambohra commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional uniontype columns based on Hive Table metadata
Posted by "vikrambohra (via GitHub)" <gi...@apache.org>.
vikrambohra commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1103195419
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +262,71 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ public static boolean containsNonOptionalUnionTypeColumn(Table t) {
+ return containsNonOptionalUnionTypeColumn(getHiveTable(t));
+ }
+
+ /**
+ * 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 Hive table
+ * @return if hive table contains non-optional uniontype columns
+ */
+ public static boolean containsNonOptionalUnionTypeColumn(HiveTable hiveTable) {
+ if (hiveTable.getProps().contains("avro.schema.literal")) {
Review Comment:
use AvroSerdeUtils.SCHEMA_LITERAL
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +262,71 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ public static boolean containsNonOptionalUnionTypeColumn(Table t) {
+ return containsNonOptionalUnionTypeColumn(getHiveTable(t));
+ }
+
+ /**
+ * 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 Hive table
+ * @return if hive table contains non-optional uniontype columns
+ */
+ public static boolean containsNonOptionalUnionTypeColumn(HiveTable hiveTable) {
+ if (hiveTable.getProps().contains("avro.schema.literal")) {
+ Schema.Parser parser = new Schema.Parser();
+ Schema schema = parser.parse(hiveTable.getProps().getProp("avro.schema.literal"));
Review Comment:
use AvroSerdeUtils.SCHEMA_LITERAL
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +262,71 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ public static boolean containsNonOptionalUnionTypeColumn(Table t) {
+ return containsNonOptionalUnionTypeColumn(getHiveTable(t));
+ }
+
+ /**
+ * 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 Hive table
+ * @return if hive table contains non-optional uniontype columns
+ */
+ public static boolean containsNonOptionalUnionTypeColumn(HiveTable hiveTable) {
+ 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);
+ }
+
+ if (isNonAvroFormat(hiveTable)) {
+ return hiveTable.getColumns().stream()
+ .map(HiveRegistrationUnit.Column::getType)
+ .filter(type -> type.contains("uniontype"))
+ .map(type -> TypeDescription.fromString(type))
+ .anyMatch(type -> isNonOptionalUnion(type));
+ }
+
+ throw new RuntimeException("Avro based Hive tables without \"avro.schema.literal\" are not supported");
+ }
+
+ private static boolean isNonOptionalUnion(Schema schema) {
+ switch (schema.getType()) {
+ case UNION:
+ Stream<Schema.Type> nonNullSubTypes = schema.getTypes().stream()
+ .map(Schema::getType).filter(t -> !t.equals(Schema.Type.NULL));
+ if (nonNullSubTypes.count() >= 2) {
+ return true;
+ }
+ return schema.getTypes().stream().anyMatch(s -> isNonOptionalUnion(s));
+ case MAP: // key is a string and doesn't need to be checked
+ return isNonOptionalUnion(schema.getValueType());
+ case ARRAY:
+ return isNonOptionalUnion(schema.getElementType());
+ case RECORD:
+ return schema.getFields().stream().map(Schema.Field::schema).anyMatch(s -> isNonOptionalUnion(s));
+ default:
+ return false;
+ }
+ }
+
+ private static boolean isNonOptionalUnion(TypeDescription description) {
Review Comment:
Useful method. can be made public
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +262,71 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ public static boolean containsNonOptionalUnionTypeColumn(Table t) {
+ return containsNonOptionalUnionTypeColumn(getHiveTable(t));
+ }
+
+ /**
+ * 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 Hive table
+ * @return if hive table contains non-optional uniontype columns
+ */
+ public static boolean containsNonOptionalUnionTypeColumn(HiveTable hiveTable) {
+ 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);
+ }
+
+ if (isNonAvroFormat(hiveTable)) {
+ return hiveTable.getColumns().stream()
+ .map(HiveRegistrationUnit.Column::getType)
+ .filter(type -> type.contains("uniontype"))
+ .map(type -> TypeDescription.fromString(type))
+ .anyMatch(type -> isNonOptionalUnion(type));
+ }
+
+ throw new RuntimeException("Avro based Hive tables without \"avro.schema.literal\" are not supported");
+ }
+
+ private static boolean isNonOptionalUnion(Schema schema) {
Review Comment:
Useful method. can be made public
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] codecov-commenter commented on pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#issuecomment-1411179669
# [Codecov](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#3632](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bd2f2fc) into [master](https://codecov.io/gh/apache/gobblin/commit/240aee21178b02f1d59a6401cfb27df7912f9cb9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (240aee2) will **increase** coverage by `2.43%`.
> The diff coverage is `100.00%`.
```diff
@@ Coverage Diff @@
## master #3632 +/- ##
============================================
+ Coverage 46.57% 49.01% +2.43%
+ Complexity 10667 9200 -1467
============================================
Files 2133 1751 -382
Lines 83539 67899 -15640
Branches 9286 7741 -1545
============================================
- Hits 38910 33282 -5628
+ Misses 41064 31522 -9542
+ Partials 3565 3095 -470
```
| [Impacted Files](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...che/gobblin/hive/metastore/HiveMetaStoreUtils.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi1oaXZlLXJlZ2lzdHJhdGlvbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ29iYmxpbi9oaXZlL21ldGFzdG9yZS9IaXZlTWV0YVN0b3JlVXRpbHMuamF2YQ==) | `52.32% <100.00%> (+5.96%)` | :arrow_up: |
| [...g/apache/gobblin/hive/orc/HiveOrcSerDeManager.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi1oaXZlLXJlZ2lzdHJhdGlvbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ29iYmxpbi9oaXZlL29yYy9IaXZlT3JjU2VyRGVNYW5hZ2VyLmphdmE=) | `57.29% <0.00%> (-3.13%)` | :arrow_down: |
| [.../modules/scheduler/GobblinServiceJobScheduler.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi1zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9nb2JibGluL3NlcnZpY2UvbW9kdWxlcy9zY2hlZHVsZXIvR29iYmxpblNlcnZpY2VKb2JTY2hlZHVsZXIuamF2YQ==) | `63.03% <0.00%> (-1.43%)` | :arrow_down: |
| [...main/java/org/apache/gobblin/yarn/YarnService.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi15YXJuL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9nb2JibGluL3lhcm4vWWFyblNlcnZpY2UuamF2YQ==) | `15.03% <0.00%> (-0.66%)` | :arrow_down: |
| [...a/org/apache/gobblin/azkaban/AzkabanJobRunner.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi1tb2R1bGVzL2dvYmJsaW4tYXprYWJhbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ29iYmxpbi9hemthYmFuL0F6a2FiYW5Kb2JSdW5uZXIuamF2YQ==) | | |
| [...obblin/metrics/influxdb/InfluxDBEventReporter.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi1tb2R1bGVzL2dvYmJsaW4tbWV0cmljcy1pbmZsdXhkYi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ29iYmxpbi9tZXRyaWNzL2luZmx1eGRiL0luZmx1eERCRXZlbnRSZXBvcnRlci5qYXZh) | | |
| [.../extractor/extract/google/GoogleDriveFsHelper.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi1tb2R1bGVzL2dvb2dsZS1pbmdlc3Rpb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dvYmJsaW4vc291cmNlL2V4dHJhY3Rvci9leHRyYWN0L2dvb2dsZS9Hb29nbGVEcml2ZUZzSGVscGVyLmphdmE=) | | |
| [...bblin/compliance/restore/ComplianceRestoreJob.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi1tb2R1bGVzL2dvYmJsaW4tY29tcGxpYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ29iYmxpbi9jb21wbGlhbmNlL3Jlc3RvcmUvQ29tcGxpYW5jZVJlc3RvcmVKb2IuamF2YQ==) | | |
| [...org/apache/gobblin/kafka/tool/KafkaCheckpoint.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi1tb2R1bGVzL2dvYmJsaW4ta2Fma2EtMDgvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dvYmJsaW4va2Fma2EvdG9vbC9LYWZrYUNoZWNrcG9pbnQuamF2YQ==) | | |
| [...bblin/metrics/graphite/GraphiteConnectionType.java](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z29iYmxpbi1tb2R1bGVzL2dvYmJsaW4tbWV0cmljcy1ncmFwaGl0ZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ29iYmxpbi9tZXRyaWNzL2dyYXBoaXRlL0dyYXBoaXRlQ29ubmVjdGlvblR5cGUuamF2YQ==) | | |
| ... and [382 more](https://codecov.io/gh/apache/gobblin/pull/3632?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] Will-Lo merged pull request #3632: [GOBBLIN-1774] Util for detecting non optional uniontype columns based on Hive Table metadata
Posted by "Will-Lo (via GitHub)" <gi...@apache.org>.
Will-Lo merged PR #3632:
URL: https://github.com/apache/gobblin/pull/3632
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] ZihanLi58 commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "ZihanLi58 (via GitHub)" <gi...@apache.org>.
ZihanLi58 commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1102024973
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +261,29 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ /**
+ * 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
+ *
+ * @param hiveTable
+ * @return if hive table contains complex uniontype columns
+ */
+ public static boolean containsNonOptionalUnionTypeColumn(HiveTable hiveTable) {
+ if (!isAvroFormat(hiveTable)) {
+ // All values in ORC are optional / nullable
+ return false;
+ }
+
+ return hiveTable.getColumns().stream()
+ .map(HiveRegistrationUnit.Column::getType)
+ .map(Object::toString)
+ .anyMatch(columnType -> columnType.contains("uniontype") && !columnType.contains("void"));
Review Comment:
I believe this is not a correct definition of the complex union. <null, int, string> is a complex union, but you will not detect that in this case
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] homatthew commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional uniontype columns based on Hive Table metadata
Posted by "homatthew (via GitHub)" <gi...@apache.org>.
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
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] homatthew commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1093863228
##########
gobblin-hive-registration/src/test/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtilsTest.java:
##########
@@ -212,4 +217,84 @@ public void testGetHiveTable() throws Exception {
Assert.assertEquals(fieldA.getType(), "int");
}
+
+ @Test
+ public void testContainsUnionType_AvroSucceeds() {
+ final String databaseName = "db";
+ final String tableName = "tbl";
+ final State serdeProps = new State();
+
+ serdeProps.setProp("avro.schema.literal", "{\"type\": \"record\", \"name\": \"TestEvent\","
+ + " \"namespace\": \"test.namespace\", \"fields\": [{\"name\":\"aUnionField\", \"type\": [\"string\", \"int\"]}]}");
+ HiveTable hiveTable = createTestHiveTable_Avro(databaseName, tableName, serdeProps);
+
+ Assert.assertTrue(HiveMetaStoreUtils.containsUnionTypeColumn(hiveTable));
Review Comment:
non optional uniontypes in avro are represented as a ["type1", "type2", ...] where the first type is the default. See https://avro.apache.org/docs/1.10.2/spec.html#Unions
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] homatthew commented on pull request #3632: [GOBBLIN-1774] Util for detecting non optional uniontype columns based on Hive Table metadata
Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#issuecomment-1426566497
Squashed
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] homatthew commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional uniontype columns based on Hive Table metadata
Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1103107304
##########
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")) {
Review Comment:
This case is true for all tables written and managed by Gobblin
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] ZihanLi58 commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "ZihanLi58 (via GitHub)" <gi...@apache.org>.
ZihanLi58 commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1100717050
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +255,23 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ /**
+ * Util for detecting if a table has a complex union (aka non-optional unions) column types.
+ *
+ * @param t
+ * @return if hive table contains complex uniontype columns
+ */
+ public static boolean containsUnionTypeColumn(HiveTable t) {
+ return t.getColumns().stream()
+ .map(HiveRegistrationUnit.Column::getType)
+ .map(Object::toString)
+ .anyMatch(columnType -> columnType.contains("uniontype"));
Review Comment:
Seems to me we only check union type but not non-optional union type. Is this intentional? If so, please update the description to reflect that as well.
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] vikrambohra commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional unions Hive tables
Posted by "vikrambohra (via GitHub)" <gi...@apache.org>.
vikrambohra commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1099258661
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -257,11 +256,7 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
}
/**
- * Util for detecting if a table has a complex union (aka non-optional unions) column types. Iceberg currently does
- * not natively support uniontype because types differently as structs. Until this feature is added in iceberg, this
- * function can be used to detect these types of tables for gobblin specific workarounds
- *
- * See https://github.com/apache/iceberg/issues/189
+ * Util for detecting if a table has a complex union (aka non-optional unions) column types.
*
* @param t
Review Comment:
Nit: Hive table t
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gobblin] homatthew commented on a diff in pull request #3632: [GOBBLIN-1774] Util for detecting non optional uniontype columns based on Hive Table metadata
Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3632:
URL: https://github.com/apache/gobblin/pull/3632#discussion_r1103260869
##########
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java:
##########
@@ -256,6 +262,71 @@ public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) {
return si;
}
+ public static boolean containsNonOptionalUnionTypeColumn(Table t) {
+ return containsNonOptionalUnionTypeColumn(getHiveTable(t));
+ }
+
+ /**
+ * 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 Hive table
+ * @return if hive table contains non-optional uniontype columns
+ */
+ public static boolean containsNonOptionalUnionTypeColumn(HiveTable hiveTable) {
+ if (hiveTable.getProps().contains("avro.schema.literal")) {
Review Comment:
Used HiveAvroSerDeManager. Same effect but this one is not deprecated and is Gobblin managed
--
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.
To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org