You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "ndrluis (via GitHub)" <gi...@apache.org> on 2025/09/08 23:21:49 UTC

[PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

ndrluis opened a new pull request, #14027:
URL: https://github.com/apache/iceberg/pull/14027

   I was working on this PyIceberg issue (https://github.com/apache/iceberg-python/issues/2372) and I wrote a new test where PyIceberg writes a parquet file and PySpark writes another one. I wanted to ensure that we are able to read from both parquet files, but then I started receiving this exception: java.util.UUID cannot be cast to class java.nio.ByteBuffer. So this PR focuses on solving this problem to maintain compatibility between both implementations.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

Posted by "ndrluis (via GitHub)" <gi...@apache.org>.
ndrluis commented on PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#issuecomment-3290263196

   @huaxingao @amogh-jahagirdar @Fokko with my latest commit, I was able to fix both cases. Since PyArrow (the version used by PyIceberg) does not add information about the logical type annotation, and since we are reverting back to using binary(16) in the visitor to represent the type on the PyIceberg side, we will only have this information when PyArrow has full support for UUID. Therefore, it's safer for us to verify the Iceberg type instead of the Parquet logical type annotation.
   
   I have already tested the scenario of writing with PyIceberg using binary(16) and reading with this branch.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2381725749


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -1063,6 +1077,18 @@ public void testVariantFieldAllNullsNotNull() throws IOException {
     }
   }
 
+  @TestTemplate
+  public void testUUIDEq() {
+    assumeThat(format).as("Only valid for Parquet").isEqualTo(FileFormat.PARQUET);
+
+    boolean shouldRead = shouldRead(equal("uuid_col", UUID_WITH_ZEROS));

Review Comment:
   what about testing other expressions?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

Posted by "huaxingao (via GitHub)" <gi...@apache.org>.
huaxingao commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2334231455


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -248,7 +253,9 @@ private void createParquetInputFile() throws IOException {
 
         Record structNotNull = new Record(structSchema);
         structNotNull.put("_int_field", INT_MIN_VALUE + i);
-        builder.set("_struct_not_null", structNotNull); // struct with int
+        builder.set("_struct_not_null", structNotNull);

Review Comment:
   nit: unnecessary change? Shall we keep the `// struct with int`



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2341382981


##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetConversions.java:
##########
@@ -90,6 +91,10 @@ static Function<Object, Object> converterFromParquet(
   }
 
   static Function<Object, Object> converterFromParquet(PrimitiveType type) {
+    if (type.getLogicalTypeAnnotation() instanceof UUIDLogicalTypeAnnotation) {

Review Comment:
   cc @Fokko may have some insights too here since I know he was working on some UUID related fixes in the past.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

Posted by "ndrluis (via GitHub)" <gi...@apache.org>.
ndrluis commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2342937427


##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetConversions.java:
##########
@@ -90,6 +91,10 @@ static Function<Object, Object> converterFromParquet(
   }
 
   static Function<Object, Object> converterFromParquet(PrimitiveType type) {
+    if (type.getLogicalTypeAnnotation() instanceof UUIDLogicalTypeAnnotation) {

Review Comment:
   This change does not solve all the problems. I'm doing some experiments here, playing around with pyiceberg and Spark, so I discovered some other things that I'm double-checking. I intend to add a more detailed analysis here over the weekend.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "shangxinli (via GitHub)" <gi...@apache.org>.
shangxinli commented on PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#issuecomment-3326196710

    The schema defines the column as optional. Can you  null UUID value tests?


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "shangxinli (via GitHub)" <gi...@apache.org>.
shangxinli commented on PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#issuecomment-3338729366

   LGTM


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "ndrluis (via GitHub)" <gi...@apache.org>.
ndrluis commented on PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#issuecomment-3329519047

   @Fokko @shangxinli I made the suggested changes


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

Posted by "huaxingao (via GitHub)" <gi...@apache.org>.
huaxingao commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2334236428


##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetConversions.java:
##########
@@ -90,6 +91,10 @@ static Function<Object, Object> converterFromParquet(
   }
 
   static Function<Object, Object> converterFromParquet(PrimitiveType type) {
+    if (type.getLogicalTypeAnnotation() instanceof UUIDLogicalTypeAnnotation) {

Review Comment:
   Since this method is also used by ` ParquetDictionaryRowGroupFilter`, should we add a uuid test too?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2341200100


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -988,6 +995,18 @@ public void testTransformFilter() {
         .isTrue();
   }
 
+  @TestTemplate
+  public void testUUIDClassCastExceptionBug() {

Review Comment:
   I think this should be called `testUUIDEq` for consistency with the other test names in this class



##########
parquet/src/test/java/org/apache/iceberg/parquet/TestDictionaryRowGroupFilter.java:
##########
@@ -1267,6 +1274,20 @@ public void testTransformFilter() {
         .isTrue();
   }
 
+  @TestTemplate
+  public void testUUIDDictionaryFilter() {
+    boolean shouldReadExisting =
+        new ParquetDictionaryRowGroupFilter(SCHEMA, equal("uuid_col", TARGET_UUID))
+            .shouldRead(parquetSchema, rowGroupMetadata, dictionaryStore);
+    assertThat(shouldReadExisting).as("Should not crash on UUID filtering").isTrue();

Review Comment:
   Can we have a better failure message than "Should not crash on UUID filtering"? For consistency with the other tests "Should read: Dictionary contains a matching entry", similar to below. 



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2419071391


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -1063,6 +1073,41 @@ public void testVariantFieldAllNullsNotNull() throws IOException {
     }
   }
 
+  @TestTemplate
+  public void testUUID() {
+    assumeThat(format).as("Only valid for Parquet").isEqualTo(FileFormat.PARQUET);
+
+    UUID nonExistentUuid = UUID.fromString("99999999-9999-9999-9999-999999999999");
+
+    boolean shouldRead = shouldRead(notEqual("uuid_col", UUID_WITH_ZEROS));

Review Comment:
   the test is still missing equal/greaterThan/lessThan



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2381705498


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -211,6 +218,9 @@ public void createOrcInputFile() throws IOException {
         structNotNull.setField("_int_field", INT_MIN_VALUE + i);
         record.setField("_struct_not_null", structNotNull); // struct with int
 
+        record.setField(
+            "_uuid_col", (i % 3 == 0) ? UUID_WITH_ZEROS : (i % 3 == 1) ? UUID_WITH_ONES : null);

Review Comment:
   minor: what's the reason for doing the modulo here? why not just write UUID_WITH_ZEROS?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2419074133


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -211,6 +216,8 @@ public void createOrcInputFile() throws IOException {
         structNotNull.setField("_int_field", INT_MIN_VALUE + i);
         record.setField("_struct_not_null", structNotNull); // struct with int
 
+        record.setField("_uuid_col", (i % 2 == 0) ? UUID_WITH_ZEROS : null);

Review Comment:
   nit: newline right above this line can be removed



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2373556081


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -151,6 +153,9 @@ public static List<Object> parameters() {
   private static final int INT_MIN_VALUE = 30;
   private static final int INT_MAX_VALUE = 79;
 
+  private static final UUID TARGET_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
+  private static final UUID OTHER_UUID = UUID.fromString("11111111-1111-1111-1111-111111111111");

Review Comment:
   Maybe a bit more descriptive :)
   
   ```suggestion
     private static final UUID UUID_WITH_ZEROS = UUID.fromString("00000000-0000-0000-0000-000000000000");
     private static final UUID UUID_WITH_ONES = UUID.fromString("11111111-1111-1111-1111-111111111111");
   ```
   
   



##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetConversions.java:
##########
@@ -83,6 +83,8 @@ static Function<Object, Object> converterFromParquet(
       } else if (icebergType.typeId() == Type.TypeID.DOUBLE
           && parquetType.getPrimitiveTypeName() == PrimitiveType.PrimitiveTypeName.FLOAT) {
         return value -> ((Float) fromParquet.apply(value)).doubleValue();
+      } else if (icebergType.typeId() == Type.TypeID.UUID) {
+        return binary -> UUIDUtil.convert(((Binary) binary).toByteBuffer());

Review Comment:
   This seems like an odd place to apply this conversion since the rows above are more about schema evolution. However, looking at it a bit closer, I think it makes sense. Other logical types, such as `TimestampLiteral` store the primitive type internally (`long`), while the `UUIDLiteral` keeps a `UUID` rather than `bytes`.
   
   This will just compare the bytes using an unsigned lexicographical binary comparator.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2341380971


##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetConversions.java:
##########
@@ -90,6 +91,10 @@ static Function<Object, Object> converterFromParquet(
   }
 
   static Function<Object, Object> converterFromParquet(PrimitiveType type) {
+    if (type.getLogicalTypeAnnotation() instanceof UUIDLogicalTypeAnnotation) {

Review Comment:
   This fix seems OK to me, but the part I don't quite understand yet (I haven't dug into it yet) is this issue PyIceberg specific? What's different about for instance the dictionaries with UUID produced by Spark and why doesn't that fail?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2409969863


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -157,6 +159,11 @@ public static List<Object> parameters() {
   private static final int INT_MIN_VALUE = 30;
   private static final int INT_MAX_VALUE = 79;
 
+  private static final UUID UUID_WITH_ZEROS =
+      UUID.fromString("00000000-0000-0000-0000-000000000000");
+  private static final UUID UUID_WITH_ONES =

Review Comment:
   when is this actually used?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2419072597


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -248,6 +255,9 @@ private void createParquetInputFile() throws IOException {
       GenericRecord structNotNull = GenericRecord.create(UNDERSCORE_STRUCT_FIELD_TYPE);
       structNotNull.setField("_int_field", INT_MIN_VALUE + i);
       builder.setField("_struct_not_null", structNotNull); // struct with int
+

Review Comment:
   ```suggestion
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#issuecomment-3406749749

   I'll leave this open for a bit in case @huaxingao wants to review this 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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "ndrluis (via GitHub)" <gi...@apache.org>.
ndrluis commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2382269816


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -211,6 +218,9 @@ public void createOrcInputFile() throws IOException {
         structNotNull.setField("_int_field", INT_MIN_VALUE + i);
         record.setField("_struct_not_null", structNotNull); // struct with int
 
+        record.setField(
+            "_uuid_col", (i % 3 == 0) ? UUID_WITH_ZEROS : (i % 3 == 1) ? UUID_WITH_ONES : null);

Review Comment:
   The idea was to use different values to make sure the filtering works, but now I think just with_zeros and null are enough. WDYT?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra merged PR #14027:
URL: https://github.com/apache/iceberg/pull/14027


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "ndrluis (via GitHub)" <gi...@apache.org>.
ndrluis commented on PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#issuecomment-3371456381

   @nastra I made the suggested changes


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

Posted by "ndrluis (via GitHub)" <gi...@apache.org>.
ndrluis commented on PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#issuecomment-3289655448

   Quick update on this issue - I'm going to focus on solving this problem on the Java side first. Once Iceberg Java has the correct behavior, I'll come back to PyIceberg and make the necessary adjustments. So here's the minimal test that I'm running using PySpark (since I have more familiarity with it than the Java environment).
   
   **Tested with the following Iceberg Runtimes**:
   org.apache.iceberg#iceberg-spark-runtime-3.5_2.12;1.9.0
   org.apache.iceberg#iceberg-spark-runtime-3.5_2.12;1.10.0
   
   **Test Case**
   ```python
   @pytest.mark.integration
   def test_uuid_write_read_with_pyspark(session_catalog: Catalog, spark: SparkSession) -> None:
       identifier = "default.test_uuid_write_and_read_with_pyspark"
   
       catalog = load_catalog("default", type="in-memory")
       catalog.create_namespace("ns")
   
       schema = Schema(NestedField(field_id=1, name="uuid_col", field_type=UUIDType(), required=False))
   
       try:
           session_catalog.drop_table(identifier=identifier)
       except NoSuchTableError:
           pass
   
       table = _create_table(session_catalog, identifier, {"format-version": "2"}, schema=schema)
   
       spark.sql(
           f"""
           INSERT INTO {identifier} VALUES ("22222222-2222-2222-2222-222222222222")
           """
       )
       df = spark.table(identifier)
   
       assert df.count() == 1
   
       result = df.where("uuid_col = '22222222-2222-2222-2222-222222222222'")
       assert result.count() == 1
   ```
   
   **Error**
   The test passes for df.count() but fails when applying the WHERE condition with the following error:
   
   ```
   25/09/14 12:45:49 ERROR BaseReader: Error reading file(s): s3://warehouse/default/test_uuid_write_and_read_with_pyspark/data/00000-0-c8b11c46-5ef7-426e-a1d5-de8aa720af6d-0-00001.parquet
   java.lang.ClassCastException: class java.util.UUID cannot be cast to class java.nio.ByteBuffer (java.util.UUID and java.nio.ByteBuffer are in module java.base of loader 'bootstrap')
           at java.base/java.nio.ByteBuffer.compareTo(ByteBuffer.java:267)
           at java.base/java.util.Comparators$NaturalOrderComparator.compare(Comparators.java:52)
           at java.base/java.util.Comparators$NaturalOrderComparator.compare(Comparators.java:47)
           at org.apache.iceberg.types.Comparators$NullSafeChainedComparator.compare(Comparators.java:253)
           at org.apache.iceberg.parquet.ParquetMetricsRowGroupFilter$MetricsEvalVisitor.eq(ParquetMetricsRowGroupFilter.java:352)
           at org.apache.iceberg.parquet.ParquetMetricsRowGroupFilter$MetricsEvalVisitor.eq(ParquetMetricsRowGroupFilter.java:79)
           at org.apache.iceberg.expressions.ExpressionVisitors$BoundExpressionVisitor.predicate(ExpressionVisitors.java:162)
           at org.apache.iceberg.expressions.ExpressionVisitors.visitEvaluator(ExpressionVisitors.java:390)
           at org.apache.iceberg.expressions.ExpressionVisitors.visitEvaluator(ExpressionVisitors.java:409)
           at org.apache.iceberg.parquet.ParquetMetricsRowGroupFilter$MetricsEvalVisitor.eval(ParquetMetricsRowGroupFilter.java:103)
           at org.apache.iceberg.parquet.ParquetMetricsRowGroupFilter.shouldRead(ParquetMetricsRowGroupFilter.java:73)
           at org.apache.iceberg.parquet.ReadConf.<init>(ReadConf.java:108)
           at org.apache.iceberg.parquet.VectorizedParquetReader.init(VectorizedParquetReader.java:90)
           at org.apache.iceberg.parquet.VectorizedParquetReader.iterator(VectorizedParquetReader.java:99)
           at org.apache.iceberg.spark.source.BatchDataReader.open(BatchDataReader.java:116)
           at org.apache.iceberg.spark.source.BatchDataReader.open(BatchDataReader.java:43)
           at org.apache.iceberg.spark.source.BaseReader.next(BaseReader.java:134)
           at org.apache.spark.sql.execution.datasources.v2.PartitionIterator.hasNext(DataSourceRDD.scala:120)
           at org.apache.spark.sql.execution.datasources.v2.MetricsIterator.hasNext(DataSourceRDD.scala:158)
           [... rest of stack trace ...]
   ```


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs written by PyIceberg [iceberg]

Posted by "ndrluis (via GitHub)" <gi...@apache.org>.
ndrluis commented on PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#issuecomment-3272599219

   Thank you @huaxingao for the review, I made the requested changes.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2397968951


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -211,6 +218,9 @@ public void createOrcInputFile() throws IOException {
         structNotNull.setField("_int_field", INT_MIN_VALUE + i);
         record.setField("_struct_not_null", structNotNull); // struct with int
 
+        record.setField(
+            "_uuid_col", (i % 3 == 0) ? UUID_WITH_ZEROS : (i % 3 == 1) ? UUID_WITH_ONES : null);

Review Comment:
   I think it comes down to also testing other expressions. See my other [comment](https://github.com/apache/iceberg/pull/14027#discussion_r2381725749) on this



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "ndrluis (via GitHub)" <gi...@apache.org>.
ndrluis commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2410704929


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -157,6 +159,11 @@ public static List<Object> parameters() {
   private static final int INT_MIN_VALUE = 30;
   private static final int INT_MAX_VALUE = 79;
 
+  private static final UUID UUID_WITH_ZEROS =
+      UUID.fromString("00000000-0000-0000-0000-000000000000");
+  private static final UUID UUID_WITH_ONES =

Review Comment:
   My bad, the b51a298 commit solves this.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Data, Parquet: Fix UUID ClassCastException when reading Parquet files with UUIDs [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #14027:
URL: https://github.com/apache/iceberg/pull/14027#discussion_r2419071391


##########
data/src/test/java/org/apache/iceberg/data/TestMetricsRowGroupFilter.java:
##########
@@ -1063,6 +1073,41 @@ public void testVariantFieldAllNullsNotNull() throws IOException {
     }
   }
 
+  @TestTemplate
+  public void testUUID() {
+    assumeThat(format).as("Only valid for Parquet").isEqualTo(FileFormat.PARQUET);
+
+    UUID nonExistentUuid = UUID.fromString("99999999-9999-9999-9999-999999999999");
+
+    boolean shouldRead = shouldRead(notEqual("uuid_col", UUID_WITH_ZEROS));

Review Comment:
   the test is still missing equal/greaterThan/lessThan. please also update the other test



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org