ndrluis commented on issue #2372:
URL: 
https://github.com/apache/iceberg-python/issues/2372#issuecomment-3268370645

   @Fokko @kevinjqliu I made the changes, but during my tests I received an 
error from the Java implementation that I'm fixing with this PR 
https://github.com/apache/iceberg/pull/14027. So to maintain compatibility 
between PyIceberg and the Java implementation, we need this fix.
   
   The test that returns the error (before changing the visit_uuid to 
binary(16)):
   ```
   def test_write_uuid_in_pyiceberg_and_scan(session_catalog: Catalog, spark: 
SparkSession) -> None:
       identifier = "default.test_write_uuid_in_pyiceberg_and_scan"
   
       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)
       )
   
       test_data_with_null = {
           "uuid_col": [
               uuid.UUID("00000000-0000-0000-0000-000000000000").bytes,
               None,
               uuid.UUID("11111111-1111-1111-1111-111111111111").bytes,
           ]
       }
   
       try:
           session_catalog.drop_table(identifier=identifier)
       except NoSuchTableError:
           pass
   
       table = _create_table(session_catalog, identifier, {"format-version": 
"2"}, schema=schema)
   
       arrow_table = pa.table(test_data_with_null, schema=schema.as_arrow())
   
       # Write with pyarrow
       table.append(arrow_table)
   
       # Write with pyspark
       spark.sql(
           f"""
           INSERT INTO {identifier} VALUES 
("22222222-2222-2222-2222-222222222222")
           """
       )
       df = spark.table(identifier)
   
       table.refresh()
   
       assert df.count() == 4
       assert len(table.scan().to_arrow()) == 4
   
       result = df.where("uuid_col = '00000000-0000-0000-0000-000000000000'")
       assert result.count() == 1
   
       result = df.where("uuid_col = '22222222-2222-2222-2222-222222222222'")
       assert result.count() == 1
   
       result = table.scan(row_filter=EqualTo("uuid_col", 
uuid.UUID("00000000-0000-0000-0000-000000000000").bytes)).to_arrow()
       assert len(result) == 1
   
       result = table.scan(row_filter=EqualTo("uuid_col", 
uuid.UUID("22222222-2222-2222-2222-222222222222").bytes)).to_arrow()
       assert len(result) == 1 
   ```


-- 
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]

Reply via email to