pvary commented on a change in pull request #1407:
URL: https://github.com/apache/iceberg/pull/1407#discussion_r491988299



##########
File path: 
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergOutputFormat.java
##########
@@ -0,0 +1,285 @@
+/*
+ * 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.iceberg.mr.hive;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.Set;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.JobContext;
+import org.apache.hadoop.mapred.JobContextImpl;
+import org.apache.hadoop.mapred.JobID;
+import org.apache.hadoop.mapred.OutputCommitter;
+import org.apache.hadoop.mapred.TaskAttemptContext;
+import org.apache.hadoop.mapred.TaskAttemptContextImpl;
+import org.apache.hadoop.mapred.TaskAttemptID;
+import org.apache.hadoop.mapreduce.JobStatus;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.SchemaParser;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.TableScan;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.hadoop.HadoopTables;
+import org.apache.iceberg.mr.Catalogs;
+import org.apache.iceberg.mr.InputFormatConfig;
+import org.apache.iceberg.mr.TestHelper;
+import org.apache.iceberg.mr.hive.HiveIcebergOutputFormat.IcebergRecordWriter;
+import org.apache.iceberg.mr.mapreduce.IcebergWritable;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class TestHiveIcebergOutputFormat {
+
+  private static final Object[] TESTED_FILE_FORMATS = new Object[] {"avro", 
"orc", "parquet"};
+
+  @Rule
+  public TemporaryFolder temp = new TemporaryFolder();
+
+  @Parameterized.Parameters(name = "{0}")
+  public static Object[] parameters() {
+    return TESTED_FILE_FORMATS;
+  }
+
+  // parametrized variables
+  private final FileFormat fileFormat;
+
+  private static final Configuration conf = new Configuration();
+  private TestHelper helper;
+  private Table table;
+  private TestOutputFormat testOutputFormat;
+
+  public TestHiveIcebergOutputFormat(String fileFormat) {
+    this.fileFormat = 
FileFormat.valueOf(fileFormat.toUpperCase(Locale.ENGLISH));
+  }
+
+  @Before
+  public void before() throws Exception {
+    helper = new TestHelper(conf,
+        new HadoopTables(conf),
+        temp.newFolder(this.fileFormat.name()).toString(),
+        HiveIcebergSerDeTestUtils.FULL_SCHEMA,
+        null,
+        fileFormat,
+        temp);
+
+    table = helper.createUnpartitionedTable();
+    testOutputFormat = new TestOutputFormat(table, fileFormat);
+  }
+
+  @Test
+  public void testWriteRow() throws IOException {
+    // Write a row.
+    List<Record> records =
+        Arrays.asList(new Record[] { 
HiveIcebergSerDeTestUtils.getTestRecord(FileFormat.PARQUET.equals(fileFormat)) 
});
+
+    testOutputFormat.write(records, false, false);
+    testOutputFormat.validate(records);
+  }
+
+  @Test
+  public void testNullRow() throws IOException {
+    // FIXME: ORC file does not read back the row consisting only of nulls. 
The data in the files seems ok.
+    if (FileFormat.ORC.equals(fileFormat)) {
+      return;
+    }
+    // Write a row.
+    List<Record> records = Arrays.asList(new Record[] { 
HiveIcebergSerDeTestUtils.getNullTestRecord() });
+
+    testOutputFormat.write(records, false, false);
+    testOutputFormat.validate(records);
+  }
+
+  @Test
+  public void testMultipleRows() throws IOException {
+    // Write 2 rows. One with nulls too.
+    List<Record> records = Arrays.asList(new Record[] {
+        
HiveIcebergSerDeTestUtils.getTestRecord(FileFormat.PARQUET.equals(fileFormat)),
+        HiveIcebergSerDeTestUtils.getNullTestRecord()
+    });
+
+    testOutputFormat.write(records, false, false);
+    testOutputFormat.validate(records);
+  }
+
+  @Test
+  public void testRandomRecords() throws IOException {
+    // Write 30 random rows
+    // FIXME: Parquet appender expect byte[] instead of UUID when writing 
values.

Review comment:
       I am not even sure that this could be changed without broader community 
approval - might be a breaking change for existing parquet writers




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

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