Search in sources :

Example 1 with ParquetOutputFormat

use of org.apache.parquet.hadoop.ParquetOutputFormat in project parquet-mr by apache.

the class TestMapredParquetOutputFormat method testGetHiveRecordWriter.

@SuppressWarnings("unchecked")
@Test
public void testGetHiveRecordWriter() throws IOException {
    Properties tableProps = new Properties();
    tableProps.setProperty("columns", "foo,bar");
    tableProps.setProperty("columns.types", "int:int");
    final Progressable mockProgress = mock(Progressable.class);
    final ParquetOutputFormat<ArrayWritable> outputFormat = (ParquetOutputFormat<ArrayWritable>) mock(ParquetOutputFormat.class);
    JobConf jobConf = new JobConf();
    try {
        new MapredParquetOutputFormat(outputFormat) {

            @Override
            protected ParquetRecordWriterWrapper getParquerRecordWriterWrapper(ParquetOutputFormat<ArrayWritable> realOutputFormat, JobConf jobConf, String finalOutPath, Progressable progress) throws IOException {
                assertEquals(outputFormat, realOutputFormat);
                assertNotNull(jobConf.get(DataWritableWriteSupport.PARQUET_HIVE_SCHEMA));
                assertEquals("/foo", finalOutPath.toString());
                assertEquals(mockProgress, progress);
                throw new RuntimeException("passed tests");
            }
        }.getHiveRecordWriter(jobConf, new Path("/foo"), null, false, tableProps, mockProgress);
        fail("should throw runtime exception.");
    } catch (RuntimeException e) {
        assertEquals("passed tests", e.getMessage());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ParquetOutputFormat(org.apache.parquet.hadoop.ParquetOutputFormat) ParquetRecordWriterWrapper(org.apache.hadoop.hive.ql.io.parquet.write.ParquetRecordWriterWrapper) IOException(java.io.IOException) Properties(java.util.Properties) Progressable(org.apache.hadoop.util.Progressable) ArrayWritable(org.apache.hadoop.io.ArrayWritable) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Example 2 with ParquetOutputFormat

use of org.apache.parquet.hadoop.ParquetOutputFormat in project hive by apache.

the class TestMapredParquetOutputFormat method testGetHiveRecordWriter.

@SuppressWarnings("unchecked")
@Test
public void testGetHiveRecordWriter() throws IOException {
    Properties tableProps = new Properties();
    tableProps.setProperty("columns", "foo,bar");
    tableProps.setProperty("columns.types", "int:int");
    final Progressable mockProgress = mock(Progressable.class);
    final ParquetOutputFormat<ParquetHiveRecord> outputFormat = (ParquetOutputFormat<ParquetHiveRecord>) mock(ParquetOutputFormat.class);
    JobConf jobConf = new JobConf();
    try {
        new MapredParquetOutputFormat(outputFormat) {

            @Override
            protected ParquetRecordWriterWrapper getParquerRecordWriterWrapper(ParquetOutputFormat<ParquetHiveRecord> realOutputFormat, JobConf jobConf, String finalOutPath, Progressable progress, Properties tableProperties) throws IOException {
                assertEquals(outputFormat, realOutputFormat);
                assertNotNull(jobConf.get(DataWritableWriteSupport.PARQUET_HIVE_SCHEMA));
                assertEquals("/foo", finalOutPath.toString());
                assertEquals(mockProgress, progress);
                throw new RuntimeException("passed tests");
            }
        }.getHiveRecordWriter(jobConf, new Path("/foo"), null, false, tableProps, mockProgress);
        fail("should throw runtime exception.");
    } catch (RuntimeException e) {
        assertEquals("passed tests", e.getMessage());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ParquetHiveRecord(org.apache.hadoop.hive.serde2.io.ParquetHiveRecord) ParquetOutputFormat(org.apache.parquet.hadoop.ParquetOutputFormat) ParquetRecordWriterWrapper(org.apache.hadoop.hive.ql.io.parquet.write.ParquetRecordWriterWrapper) IOException(java.io.IOException) Properties(java.util.Properties) Progressable(org.apache.hadoop.util.Progressable) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)2 Properties (java.util.Properties)2 Path (org.apache.hadoop.fs.Path)2 ParquetRecordWriterWrapper (org.apache.hadoop.hive.ql.io.parquet.write.ParquetRecordWriterWrapper)2 JobConf (org.apache.hadoop.mapred.JobConf)2 Progressable (org.apache.hadoop.util.Progressable)2 ParquetOutputFormat (org.apache.parquet.hadoop.ParquetOutputFormat)2 Test (org.junit.Test)2 ParquetHiveRecord (org.apache.hadoop.hive.serde2.io.ParquetHiveRecord)1 ArrayWritable (org.apache.hadoop.io.ArrayWritable)1