ZENOTME commented on code in PR #902:
URL: https://github.com/apache/iceberg-rust/pull/902#discussion_r2273983104


##########
crates/integration_tests/tests/shared_tests/merge_append_test.rs:
##########
@@ -0,0 +1,207 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Integration tests for rest catalog.
+
+use std::sync::{Arc, OnceLock};
+
+use arrow_array::{ArrayRef, BooleanArray, Int32Array, RecordBatch, 
StringArray};
+use iceberg::spec::{
+    DataFile, ManifestEntry, ManifestStatus, NestedField, PrimitiveType, 
Schema, Type,
+};
+use iceberg::table::Table;
+use iceberg::transaction::{
+    ApplyTransactionAction, MANIFEST_MERGE_ENABLED, MANIFEST_MIN_MERGE_COUNT,
+    MANIFEST_TARGET_SIZE_BYTES, Transaction,
+};
+use iceberg::writer::base_writer::data_file_writer::DataFileWriterBuilder;
+use iceberg::writer::file_writer::ParquetWriterBuilder;
+use iceberg::writer::file_writer::location_generator::{
+    DefaultFileNameGenerator, DefaultLocationGenerator,
+};
+use iceberg::writer::{IcebergWriter, IcebergWriterBuilder};
+use iceberg::{Catalog, TableCreation};
+use iceberg_catalog_rest::RestCatalog;
+use parquet::file::properties::WriterProperties;
+
+use crate::get_shared_containers;
+use crate::shared_tests::random_ns;
+
+static FILE_NAME_GENERATOR: OnceLock<DefaultFileNameGenerator> = 
OnceLock::new();
+
+async fn write_new_data_file(table: &Table) -> Vec<DataFile> {
+    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 = FILE_NAME_GENERATOR.get_or_init(|| {
+        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,
+        table.metadata().default_partition_spec_id(),
+    );
+    let mut data_file_writer = data_file_writer_builder.build().await.unwrap();
+    let col1 = StringArray::from(vec![Some("foo"); 100]);
+    let col2 = Int32Array::from(vec![Some(1); 100]);
+    let col3 = BooleanArray::from(vec![Some(true); 100]);
+    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();
+    data_file_writer.close().await.unwrap()
+}
+
+#[tokio::test]
+async fn test_append_data_file() {
+    let fixture = get_shared_containers();
+    let rest_catalog = RestCatalog::new(fixture.catalog_config.clone());

Review Comment:
   Looks like all test use this way. Maybe we can modify them all at another pr.



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