Add test for optimized parquet writer in hive module
@@ -22,11 +22,13 @@ import com.facebook.presto.hive.metastore.Storage;
import com.facebook.presto.hive.metastore.StorageFormat;
import com.facebook.presto.hive.orc.DwrfBatchPageSourceFactory;
import com.facebook.presto.hive.orc.OrcBatchPageSourceFactory;
+import com.facebook.presto.hive.parquet.ParquetFileWriterFactory;
import com.facebook.presto.hive.parquet.ParquetPageSourceFactory;
import com.facebook.presto.hive.rcfile.RcFilePageSourceFactory;
import com.facebook.presto.orc.OrcWriterOptions;
import com.facebook.presto.orc.StorageStripeMetadataSource;
import com.facebook.presto.orc.cache.StorageOrcFileTailSource;
+import com.facebook.presto.parquet.writer.ParquetWriterOptions;
import com.facebook.presto.spi.ConnectorPageSource;
import com.facebook.presto.spi.ConnectorSession;
import com.facebook.presto.spi.ErrorCodeSupplier;
@@ -319,6 +321,31 @@ public class TestHiveFileFormats
.isReadableByPageSource(new OrcBatchPageSourceFactory(TYPE_MANAGER, false, HDFS_ENVIRONMENT, STATS, 100, new StorageOrcFileTailSource(), new StorageStripeMetadataSource()));
}
+ @Test(dataProvider = "rowCount")
+ public void testOptimizedParquetWriter(int rowCount)
+ throws Exception
+ {
+ TestingConnectorSession session = new TestingConnectorSession(
+ new HiveSessionProperties(
+ new HiveClientConfig()
+ .setOrcOptimizedWriterEnabled(true)
+ .setOrcWriterValidationPercentage(100.0),
+ new OrcFileWriterConfig(),
+ new ParquetFileWriterConfig().setParquetOptimizedWriterEnabled(true)).getSessionProperties());
+
+ // A Presto page can not contain a map with null keys, so a page based writer can not write null keys
+ List<TestColumn> testColumns = TEST_COLUMNS.stream()
+ .filter(testColumn -> !testColumn.getName().equals("t_map_null_key") && !testColumn.getName().equals("t_map_null_key_complex_value") && !testColumn.getName().equals("t_map_null_key_complex_key_value"))
+ .collect(toList());
+
+ assertThatFileFormat(PARQUET)
+ .withSession(session)
+ .withColumns(testColumns)
+ .withRowsCount(rowCount)
+ .withFileWriterFactory(new ParquetFileWriterFactory(HDFS_ENVIRONMENT, TYPE_MANAGER, new NodeVersion("test"), HIVE_STORAGE_TIME_ZONE, ParquetWriterOptions.builder().build()))
+ .isReadableByPageSource(new ParquetPageSourceFactory(TYPE_MANAGER, HDFS_ENVIRONMENT, STATS));
+ }
+
@Test(dataProvider = "rowCount")
public void testOrcUseColumnNames(int rowCount)
throws Exception
