mkroll-db opened a new issue, #3462:
URL: https://github.com/apache/iceberg-rust/issues/3462

   ### Apache Iceberg Rust version
   
   v0.10.1
   
   ### Describe the bug
   
   Tables obtained via `StaticTable::into_table` can be written to, even though 
they should be read-only.
   The internal code marks them as such but the write path has no check.
   
   ### To Reproduce
   
   The following example program succeeds, but should fail.
   ```rust
   use std::collections::HashMap;
   
   use iceberg::memory::{MEMORY_CATALOG_WAREHOUSE, MemoryCatalogBuilder};
   use iceberg::spec::Schema;
   use iceberg::table::StaticTable;
   use iceberg::transaction::{ApplyTransactionAction, Transaction};
   use iceberg::{Catalog, CatalogBuilder, NamespaceIdent, Result, 
TableCreation};
   
   #[tokio::main]
   async fn main() -> Result<()> {
       let catalog = MemoryCatalogBuilder::default()
           .load(
               "memory",
               HashMap::from([(
                   MEMORY_CATALOG_WAREHOUSE.to_string(),
                   "memory:///warehouse".to_string(),
               )]),
           )
           .await?;
   
       let ns = NamespaceIdent::new("ns".to_string());
       catalog.create_namespace(&ns, HashMap::new()).await?;
       let table = catalog
           .create_table(
               &ns,
               TableCreation::builder()
                   .name("t".to_string())
                   .schema(Schema::builder().build()?)
                   .build(),
           )
           .await?;
   
       let readonly = StaticTable::from_metadata_file(
           table.metadata_location_result()?,
           table.identifier().clone(),
           table.file_io().clone(),
       )
       .await?
       .into_table();
   
       let tx = Transaction::new(&readonly);
       let tx = tx
           .update_table_properties()
           .set("written".to_string(), "yes".to_string())
           .apply(tx)?;
   
       tx.commit(&catalog).await?;
       println!("success writing to a read-only table");
   
       Ok(())
   }
   ```
   
   ### Expected behavior
   
   Any commit to the table should be denied as it's clearly marked as 
**read-only**.
   
   ### Willingness to contribute
   
   I can contribute a fix for this bug independently


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