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

   ### Describe the bug
   
   This crate can't write the rows of `CREATE TABLE … AS`, so `register_table` 
refuses input that has any (`ensure_table_is_empty` in `catalog/schema.rs`). 
DataFusion runs the query, keeps its output partitions, and passes the result 
to `register_table`. The check reads only partition 0. When partition 0 is 
empty and a later partition isn't, the statement succeeds and creates an empty 
table, so the query's rows are lost without an error.
   
   ### To Reproduce
   
   With a catalog built by `IcebergCatalogProvider::catalog_builder` registered 
as `c`, containing a namespace `ns`:
   
   ```sql
   CREATE TABLE c.ns.t AS
   SELECT id FROM (VALUES (1)) t(id) WHERE id > 1
   UNION ALL
   SELECT 2;
   -- succeeds
   
   SELECT count(*) FROM c.ns.t;
   -- 0
   ```
   
   `UNION ALL` keeps one output partition per input, and the filter leaves the 
first one empty. With the rows in partition 0, `CREATE TABLE c.ns.u AS VALUES 
(1), (2)` is refused as expected:
   
   ```
   Execution error: register_table does not support tables with data.
   ```
   
   Any query whose first output partition is empty while another one has rows 
does the same.
   
   ### Expected behavior
   
   The statement fails with the same error as when the rows are in partition 0, 
and no table is created.
   


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