mbutrovich opened a new pull request, #1822:
URL: https://github.com/apache/iceberg-rust/pull/1822

   This fix enables proper interoperability with Iceberg implementations that 
include the type discriminator field in their JSON serialization (such as 
Apache Iceberg Java).
   
   ## Which issue does this PR close?
   
   Partially address #1749.
   
   ## What changes are included in this PR?
   
   Fixes a bug in the `StructType` deserializer that causes JSON 
deserialization to fail with the error `expected ',' or '}' at line 1 column 8`.
   
   **Root Cause:**
   The `StructType::Deserialize` implementation was not properly consuming the 
`"type"` field value when deserializing JSON like:
   ```json
   
{"type":"struct","fields":[{"id":1,"name":"foo","required":true,"type":"string"}]}
   ```
   In serde's visitor pattern, when you call `map.next_key()`, you must call 
`map.next_value()` to consume the corresponding value, even if you're 
discarding it. The deserializer was calling `next_key()` for the "type" field 
but not consuming its value, causing the parser to remain stuck at the value 
position and fail when encountering the next field.
   
   Changes:
   - Modified `StructTypeVisitor::visit_map` to properly consume the type field 
value
   - Added validation that the type field equals "struct"
   
    ## Are these changes tested?
   
   Yes, two new unit tests have been added to 
`crates/iceberg/src/spec/datatypes.rs`:
   
   1. **`struct_type_with_type_field`** - Verifies that `StructType` 
successfully deserializes from JSON containing the `"type":"struct"` field. 
This test would fail before the fix with the error `expected ',' or '}' at line 
1 column 8`
   
   2. **`struct_type_rejects_wrong_type`** - Validates that the deserializer 
properly rejects JSON with incorrect type values (e.g., `"type":"list"`)
   


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