You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "ZENOTME (via GitHub)" <gi...@apache.org> on 2025/02/23 17:26:25 UTC

[PR] fix: refine doc for write support [iceberg-rust]

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

   Part of #986. This PR adds more examples to refine the doc of writer.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1987508957


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   > You mean the whole example? I'm not a big fan of that way. For writer doc, it should only focus on how to use a writer. The whole story of using different picecs in a compute engine is an advanced topic, and deserves a single chapter for that. It involves not only code, but also explaination the design in it.
   
   Sounds reasonable for me. 



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1967323466


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run
+//! use std::sync::Arc;
+//!
+//! use arrow_array::{ArrayRef, BooleanArray, Int32Array, RecordBatch, StringArray};
+//! use async_trait::async_trait;
+//! use iceberg::io::{FileIO, FileIOBuilder};
+//! use iceberg::spec::DataFile;
+//! use iceberg::transaction::Transaction;
+//! use iceberg::writer::base_writer::data_file_writer::DataFileWriterBuilder;
+//! use iceberg::writer::file_writer::location_generator::{
+//!     DefaultFileNameGenerator, DefaultLocationGenerator,
+//! };
+//! use iceberg::writer::file_writer::ParquetWriterBuilder;
+//! use iceberg::writer::{IcebergWriter, IcebergWriterBuilder};
+//! use iceberg::{Catalog, Result, TableIdent};
+//! use iceberg_catalog_memory::MemoryCatalog;
+//! use parquet::file::properties::WriterProperties;
+//! #[tokio::main]
+//! async fn main() -> Result<()> {
+//!     // Build your file IO.
+//!     let file_io = FileIOBuilder::new("memory").build()?;
+//!     // Connect to a catalog.
+//!     let catalog = MemoryCatalog::new(file_io, None);
+//!     // Load table from catalog.
+//!     let table = catalog
+//!         .load_table(&TableIdent::from_strs(["hello", "world"])?)
+//!         .await?;
+//!
+//!     // Create the data file writer.
+//!     let schema: Arc<arrow_schema::Schema> = Arc::new(
+//!         table
+//!             .metadata()
+//!             .current_schema()
+//!             .as_ref()
+//!             .try_into()
+//!             .unwrap(),
+//!     );
+//!     let location_generator = DefaultLocationGenerator::new(table.metadata().clone()).unwrap();
+//!     let file_name_generator = DefaultFileNameGenerator::new(
+//!         "test".to_string(),
+//!         None,
+//!         iceberg::spec::DataFileFormat::Parquet,
+//!     );
+//!     let parquet_writer_builder = ParquetWriterBuilder::new(
+//!         WriterProperties::default(),
+//!         table.metadata().current_schema().clone(),
+//!         table.file_io().clone(),
+//!         location_generator.clone(),
+//!         file_name_generator.clone(),
+//!     );
+//!     let data_file_writer_builder = DataFileWriterBuilder::new(parquet_writer_builder, None);
+//!     let mut data_file_writer = data_file_writer_builder.build().await.unwrap();
+//!
+//!     // Write new data.
+//!     let col1 = StringArray::from(vec![Some("foo"), Some("bar"), None, Some("baz")]);
+//!     let col2 = Int32Array::from(vec![Some(1), Some(2), Some(3), Some(4)]);
+//!     let col3 = BooleanArray::from(vec![Some(true), Some(false), None, Some(false)]);
+//!     let batch = RecordBatch::try_new(schema.clone(), vec![
+//!         Arc::new(col1) as ArrayRef,
+//!         Arc::new(col2) as ArrayRef,
+//!         Arc::new(col3) as ArrayRef,
+//!     ])
+//!     .unwrap();
+//!     data_file_writer.write(batch.clone()).await.unwrap();
+//!
+//!     // Close writer and get the DataFile.
+//!     let data_file = data_file_writer.close().await.unwrap();
+//!
+//!     // Append the DataFile.
+//!     let tx = Transaction::new(&table);
+//!     let mut fast_append = tx.fast_append(None, vec![]).unwrap();

Review Comment:
   I'm a bit confused about the API: `fast_append`. Why does it exist? And is there a `slow_append`?



##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run
+//! use std::sync::Arc;
+//!
+//! use arrow_array::{ArrayRef, BooleanArray, Int32Array, RecordBatch, StringArray};
+//! use async_trait::async_trait;
+//! use iceberg::io::{FileIO, FileIOBuilder};
+//! use iceberg::spec::DataFile;
+//! use iceberg::transaction::Transaction;
+//! use iceberg::writer::base_writer::data_file_writer::DataFileWriterBuilder;
+//! use iceberg::writer::file_writer::location_generator::{
+//!     DefaultFileNameGenerator, DefaultLocationGenerator,
+//! };
+//! use iceberg::writer::file_writer::ParquetWriterBuilder;
+//! use iceberg::writer::{IcebergWriter, IcebergWriterBuilder};
+//! use iceberg::{Catalog, Result, TableIdent};
+//! use iceberg_catalog_memory::MemoryCatalog;
+//! use parquet::file::properties::WriterProperties;
+//! #[tokio::main]
+//! async fn main() -> Result<()> {
+//!     // Build your file IO.
+//!     let file_io = FileIOBuilder::new("memory").build()?;
+//!     // Connect to a catalog.
+//!     let catalog = MemoryCatalog::new(file_io, None);
+//!     // Load table from catalog.
+//!     let table = catalog
+//!         .load_table(&TableIdent::from_strs(["hello", "world"])?)
+//!         .await?;
+//!
+//!     // Create the data file writer.
+//!     let schema: Arc<arrow_schema::Schema> = Arc::new(
+//!         table
+//!             .metadata()
+//!             .current_schema()
+//!             .as_ref()
+//!             .try_into()
+//!             .unwrap(),
+//!     );
+//!     let location_generator = DefaultLocationGenerator::new(table.metadata().clone()).unwrap();

Review Comment:
   We are returning `Result<()>` here, how about using `?` here for clean code?



##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   This test only use `memory` file io and `memory` catalog, it should be able to run?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 merged PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1967387885


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   We should create table here to make it run.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1967393803


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run
+//! use std::sync::Arc;
+//!
+//! use arrow_array::{ArrayRef, BooleanArray, Int32Array, RecordBatch, StringArray};
+//! use async_trait::async_trait;
+//! use iceberg::io::{FileIO, FileIOBuilder};
+//! use iceberg::spec::DataFile;
+//! use iceberg::transaction::Transaction;
+//! use iceberg::writer::base_writer::data_file_writer::DataFileWriterBuilder;
+//! use iceberg::writer::file_writer::location_generator::{
+//!     DefaultFileNameGenerator, DefaultLocationGenerator,
+//! };
+//! use iceberg::writer::file_writer::ParquetWriterBuilder;
+//! use iceberg::writer::{IcebergWriter, IcebergWriterBuilder};
+//! use iceberg::{Catalog, Result, TableIdent};
+//! use iceberg_catalog_memory::MemoryCatalog;
+//! use parquet::file::properties::WriterProperties;
+//! #[tokio::main]
+//! async fn main() -> Result<()> {
+//!     // Build your file IO.
+//!     let file_io = FileIOBuilder::new("memory").build()?;
+//!     // Connect to a catalog.
+//!     let catalog = MemoryCatalog::new(file_io, None);
+//!     // Load table from catalog.
+//!     let table = catalog
+//!         .load_table(&TableIdent::from_strs(["hello", "world"])?)
+//!         .await?;
+//!
+//!     // Create the data file writer.
+//!     let schema: Arc<arrow_schema::Schema> = Arc::new(
+//!         table
+//!             .metadata()
+//!             .current_schema()
+//!             .as_ref()
+//!             .try_into()
+//!             .unwrap(),
+//!     );
+//!     let location_generator = DefaultLocationGenerator::new(table.metadata().clone()).unwrap();
+//!     let file_name_generator = DefaultFileNameGenerator::new(
+//!         "test".to_string(),
+//!         None,
+//!         iceberg::spec::DataFileFormat::Parquet,
+//!     );
+//!     let parquet_writer_builder = ParquetWriterBuilder::new(
+//!         WriterProperties::default(),
+//!         table.metadata().current_schema().clone(),
+//!         table.file_io().clone(),
+//!         location_generator.clone(),
+//!         file_name_generator.clone(),
+//!     );
+//!     let data_file_writer_builder = DataFileWriterBuilder::new(parquet_writer_builder, None);
+//!     let mut data_file_writer = data_file_writer_builder.build().await.unwrap();
+//!
+//!     // Write new data.
+//!     let col1 = StringArray::from(vec![Some("foo"), Some("bar"), None, Some("baz")]);
+//!     let col2 = Int32Array::from(vec![Some(1), Some(2), Some(3), Some(4)]);
+//!     let col3 = BooleanArray::from(vec![Some(true), Some(false), None, Some(false)]);
+//!     let batch = RecordBatch::try_new(schema.clone(), vec![
+//!         Arc::new(col1) as ArrayRef,
+//!         Arc::new(col2) as ArrayRef,
+//!         Arc::new(col3) as ArrayRef,
+//!     ])
+//!     .unwrap();
+//!     data_file_writer.write(batch.clone()).await.unwrap();
+//!
+//!     // Close writer and get the DataFile.
+//!     let data_file = data_file_writer.close().await.unwrap();
+//!
+//!     // Append the DataFile.
+//!     let tx = Transaction::new(&table);
+//!     let mut fast_append = tx.fast_append(None, vec![]).unwrap();

Review Comment:
   Looks like a convention of iceberg😄 There is another action called merge_append which will merge the manifest when append, and I guess this fast append means that just append and do nothing else so it's "fast".
   - https://github.com/apache/iceberg-python/blob/06404a51ea9fac8c8c1c0ee6d219c06228d84baa/pyiceberg/table/update/snapshot.py#L616
   - https://github.com/apache/iceberg/blob/e4833dd0d516e76ff95054740e7d2b4f6cb40d18/core/src/main/java/org/apache/iceberg/BaseTable.java#L185



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1968914615


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   Yes, I hope we can have more high-level api examples. I think this is an example of low-level api which may be useful for computing engines integrated with iceberg-rust.🤔 



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1968783422


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   Hi, @ZENOTME Thanks for this, but I don't think this is a good example of writing data since it involves too many low level api invocation. We should have a high level api to accept a stream of arrow record batches, and have the transaction, file writer hidden under the hood, just like what we did in table scan to convert table to an arrow batch stream. Or we could integrate with datafusion do this.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1967392854


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   I personally believe it's more valuable. Is the blocker here that we don't support creating tables yet?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1972682553


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   You mean the whole example? I'm not a big fan of that way. For writer doc, it should only focus on how to use a writer. The whole story of using different picecs in a compute engine is an advanced topic, and deserves a single chapter for that. It involves not only code, but also explaination the design in it.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1967394613


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   No, I will add it later.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1971357633


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   > This is an example showing in crate front page, which I don't think is appropriate.
   
   Looks reasonable to me. What about also place it at https://github.com/apache/iceberg-rust/blob/main/crates/iceberg/src/writer/mod.rs



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1971332628


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   This is an example showing in crate front page, which I don't think is appropriate. If we actually want to tell compute engine how to integrate it, a better place would be to place it in [website](https://github.com/apache/iceberg-rust/blob/0e5a3c30fdf3cd957a58875dfe9ecf3c4ad6858c/website), which appears as an advanced tutorial.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1971332628


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   This is an example showing in crate front page, which I don't think is appropriate. If we actually want to tell compute engine, a better place would be to place it in [website](https://github.com/apache/iceberg-rust/blob/0e5a3c30fdf3cd957a58875dfe9ecf3c4ad6858c/website), which appears as an advanced tutorial.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#issuecomment-2677720315

   Feel free for any suggestion to make example better. cc @Xuanwo @liurenjie1024 @Fokko @kevinjqliu @xxchan @jonathanc-n 


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1967396741


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run
+//! use std::sync::Arc;
+//!
+//! use arrow_array::{ArrayRef, BooleanArray, Int32Array, RecordBatch, StringArray};
+//! use async_trait::async_trait;
+//! use iceberg::io::{FileIO, FileIOBuilder};
+//! use iceberg::spec::DataFile;
+//! use iceberg::transaction::Transaction;
+//! use iceberg::writer::base_writer::data_file_writer::DataFileWriterBuilder;
+//! use iceberg::writer::file_writer::location_generator::{
+//!     DefaultFileNameGenerator, DefaultLocationGenerator,
+//! };
+//! use iceberg::writer::file_writer::ParquetWriterBuilder;
+//! use iceberg::writer::{IcebergWriter, IcebergWriterBuilder};
+//! use iceberg::{Catalog, Result, TableIdent};
+//! use iceberg_catalog_memory::MemoryCatalog;
+//! use parquet::file::properties::WriterProperties;
+//! #[tokio::main]
+//! async fn main() -> Result<()> {
+//!     // Build your file IO.
+//!     let file_io = FileIOBuilder::new("memory").build()?;
+//!     // Connect to a catalog.
+//!     let catalog = MemoryCatalog::new(file_io, None);
+//!     // Load table from catalog.
+//!     let table = catalog
+//!         .load_table(&TableIdent::from_strs(["hello", "world"])?)
+//!         .await?;
+//!
+//!     // Create the data file writer.
+//!     let schema: Arc<arrow_schema::Schema> = Arc::new(
+//!         table
+//!             .metadata()
+//!             .current_schema()
+//!             .as_ref()
+//!             .try_into()
+//!             .unwrap(),
+//!     );
+//!     let location_generator = DefaultLocationGenerator::new(table.metadata().clone()).unwrap();
+//!     let file_name_generator = DefaultFileNameGenerator::new(
+//!         "test".to_string(),
+//!         None,
+//!         iceberg::spec::DataFileFormat::Parquet,
+//!     );
+//!     let parquet_writer_builder = ParquetWriterBuilder::new(
+//!         WriterProperties::default(),
+//!         table.metadata().current_schema().clone(),
+//!         table.file_io().clone(),
+//!         location_generator.clone(),
+//!         file_name_generator.clone(),
+//!     );
+//!     let data_file_writer_builder = DataFileWriterBuilder::new(parquet_writer_builder, None);
+//!     let mut data_file_writer = data_file_writer_builder.build().await.unwrap();
+//!
+//!     // Write new data.
+//!     let col1 = StringArray::from(vec![Some("foo"), Some("bar"), None, Some("baz")]);
+//!     let col2 = Int32Array::from(vec![Some(1), Some(2), Some(3), Some(4)]);
+//!     let col3 = BooleanArray::from(vec![Some(true), Some(false), None, Some(false)]);
+//!     let batch = RecordBatch::try_new(schema.clone(), vec![
+//!         Arc::new(col1) as ArrayRef,
+//!         Arc::new(col2) as ArrayRef,
+//!         Arc::new(col3) as ArrayRef,
+//!     ])
+//!     .unwrap();
+//!     data_file_writer.write(batch.clone()).await.unwrap();
+//!
+//!     // Close writer and get the DataFile.
+//!     let data_file = data_file_writer.close().await.unwrap();
+//!
+//!     // Append the DataFile.
+//!     let tx = Transaction::new(&table);
+//!     let mut fast_append = tx.fast_append(None, vec![]).unwrap();

Review Comment:
   Oh, nice. Thank you for the explanation.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: refine doc for write support [iceberg-rust]

Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #999:
URL: https://github.com/apache/iceberg-rust/pull/999#discussion_r1967530293


##########
crates/iceberg/src/lib.rs:
##########
@@ -50,6 +50,87 @@
 //!     Ok(())
 //! }
 //! ```
+//!
+//! ## Fast append data to table
+//!
+//! ```rust, no_run

Review Comment:
   I find that the memory catalog can't update now. So we should merge #1002 first.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org