chamikaramj commented on code in PR #30797:
URL: https://github.com/apache/beam/pull/30797#discussion_r1556446483


##########
sdks/java/io/iceberg/src/main/java/org/apache/beam/io/iceberg/RecordWriter.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package org.apache.beam.io.iceberg;
+
+import static org.apache.beam.io.iceberg.RowHelper.rowToRecord;
+
+import java.io.IOException;
+import org.apache.beam.sdk.values.Row;
+import org.apache.iceberg.DataFile;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.avro.Avro;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.data.parquet.GenericParquetWriter;
+import org.apache.iceberg.io.DataWriter;
+import org.apache.iceberg.io.OutputFile;
+import org.apache.iceberg.orc.ORC;
+import org.apache.iceberg.parquet.Parquet;
+
+class RecordWriter {
+
+  private final DataWriter<Record> icebergDataWriter;
+
+  private final Table table;
+
+  RecordWriter(Catalog catalog, IcebergDestination destination, String 
filename)
+      throws IOException {
+    this(
+        catalog.loadTable(destination.getTableIdentifier()), 
destination.getFileFormat(), filename);
+  }
+
+  RecordWriter(Table table, FileFormat fileFormat, String filename) throws 
IOException {
+    this.table = table;
+
+    String absoluteFilename = table.location() + "/" + filename;
+    OutputFile outputFile = table.io().newOutputFile(absoluteFilename);
+    switch (fileFormat) {
+      case AVRO:
+        icebergDataWriter =
+            Avro.writeData(outputFile)
+                
.createWriterFunc(org.apache.iceberg.data.avro.DataWriter::create)
+                .schema(table.schema())
+                .withSpec(table.spec())
+                .overwrite()
+                .build();
+        break;
+      case PARQUET:
+        icebergDataWriter =
+            Parquet.writeData(outputFile)
+                .createWriterFunc(GenericParquetWriter::buildWriter)
+                .schema(table.schema())
+                .withSpec(table.spec())
+                .overwrite()
+                .build();
+        break;
+      case ORC:
+        throw new UnsupportedOperationException("ORC file format not currently 
supported.");
+        //        icebergDataWriter =

Review Comment:
   Delete ?



##########
settings.gradle.kts:
##########
@@ -355,3 +355,7 @@ include("sdks:java:io:kafka:kafka-01103")
 findProject(":sdks:java:io:kafka:kafka-01103")?.name = "kafka-01103"
 include("sdks:java:managed")
 findProject(":sdks:java:managed")?.name = "managed"
+include("sdks:java:io:iceberg")
+findProject(":sdks:java:io:iceberg")?.name = "iceberg"
+include("sdks:java:io:catalog")

Review Comment:
   It doesn't look like we add anything under "sdks:java:io:catalog".



-- 
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: github-unsubscr...@beam.apache.org

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

Reply via email to