kosiew commented on PR #19674:
URL: https://github.com/apache/datafusion/pull/19674#issuecomment-3762591633

   @comphead 
   
   > About overlap this is what Spark does when no overlap and field count is 
different
   ....
   scala> spark.read.schema("str struct<col3 int, col4 int, col5 
int>").parquet("/tmp/test_struct").show(false)
   +----+
   |str |
   +----+
   |NULL|
   +----+
   
   
   In other words,  when there is **no field name overlap** AND **field counts 
differ**, Spark treats the entire struct as incompatible and returns NULL 
rather than attempting positional or partial casting.
   
   
   In this PR, we return an error.
   
   ---
   
   > With Overlap (Partial Field Match)
   ...
   **Spark Behavior:**
   ```scala
   // Source in Parquet: {col1: int, col2: int}
   // Target Schema: {col3: int, col4: int, col5: int, col1: int}
   // Result: {NULL, NULL, NULL, 1}
   
   spark.read.schema("str struct<col3 int, col4 int, col5 int, col1: 
int>").parquet("/tmp/test_struct").show(false)
   // Output: {NULL, NULL, NULL, 1}
   
   When **at least one field name matches** (in this case, `col1`), Spark:
   - Locates the matching source field by name
   - Fills non-matching target fields with NULL
   - Preserves the matched field value in the correct position
   
   
   This PR has the same behaviour.
   ---
   


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