nssalian commented on code in PR #17424:
URL: https://github.com/apache/iceberg/pull/17424#discussion_r3679345591
##########
parquet/src/main/java/org/apache/iceberg/parquet/VariantShreddingAnalyzer.java:
##########
@@ -483,62 +459,56 @@ void observe(VariantValue value) {
}
}
- PhysicalType getMostCommonType() {
- if (mostCommonComputed) {
- return mostCommonCached;
+ PhysicalType admittedType() {
+ if (admittedTypeComputed) {
+ return admittedTypeCached;
}
- Map<PhysicalType, Integer> combinedCounts = Maps.newHashMap();
-
- int integerTotalCount = 0;
- PhysicalType mostCapableInteger = null;
-
- int decimalTotalCount = 0;
- PhysicalType mostCapableDecimal = null;
+ Set<PhysicalType> families = Sets.newHashSet();
Review Comment:
Yeah let me see if this is complete. I'll noodle on this more and update.
##########
parquet/src/test/java/org/apache/iceberg/parquet/TestVariantShreddingAnalyzer.java:
##########
@@ -471,6 +469,112 @@ public void testUuidFieldIsTrackedAndShredded() {
.isInstanceOf(LogicalTypeAnnotation.UUIDLogicalTypeAnnotation.class);
}
+ @Test
+ public void testMixedPrimitiveTypesFieldNotShredded() {
+ VariantMetadata meta = Variants.metadata("mixed", "keep");
+ ShreddedObject row1 = Variants.object(meta);
+ row1.put("mixed", Variants.of(42));
+ row1.put("keep", Variants.of(1));
+ ShreddedObject row2 = Variants.object(meta);
+ row2.put("mixed", Variants.of("text"));
+ row2.put("keep", Variants.of(2));
+
+ DirectAnalyzer analyzer = new DirectAnalyzer();
+ Type schema = analyzer.analyzeAndCreateSchema(List.of(row1, row2), 0);
+
+ assertThat(schema).isNotNull().isInstanceOf(GroupType.class);
+ GroupType typedValue = (GroupType) schema;
+ assertThat(typedValue.containsField("mixed")).isFalse();
+ assertThat(typedValue.containsField("keep")).isTrue();
+ }
+
+ @Test
+ public void testIntegerWideningAdmitsField() {
Review Comment:
Will add
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]