NoahKusaba opened a new issue, #27:
URL: https://github.com/apache/datafusion-iceberg/issues/27

   ### Describe the bug
   
   An `INSERT` into a **partitioned** table fails at planning time when a 
source column is `NOT NULL` and the table's column is optional:
   
   ```
   Error: Plan("Input schema does not match Iceberg table schema.
   Expected schema: Field { "id": nullable Int32 }, Field { "category": 
nullable Utf8 }
   Input schema: Field { "id": Int32 }, Field { "category": Utf8 }")
   ```
   
   Every value of a non-nullable column is valid in an optional one, so the 
write is safe. `project_with_partition` compares the input and table schemas 
with `==`, which also requires equal nullability. It only runs for partitioned 
tables, so the same `INSERT` into an unpartitioned table succeeds.
   
   ### To Reproduce
   
   1. Create a table with optional columns `id: int` and `category: string`, 
partitioned by identity on `category`.
   2. Register a `MemTable` source whose `id` and `category` columns are 
non-nullable.
   3. `INSERT INTO t SELECT * FROM source` fails with the error above.
   
   A `VALUES` list with no NULLs fails the same way, since DataFusion infers 
its columns as non-nullable.
   
   ### Expected behavior
   
   The `INSERT` succeeds. Only a nullable input column into a required table 
column should be rejected.
   
   Related: #22 covers the opposite direction. Part of #23.
   


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