Search in sources :

Example 1 with ParquetRecordCursorProvider

use of com.facebook.presto.hive.parquet.ParquetRecordCursorProvider in project presto by prestodb.

the class TestHiveFileFormats method testParquetUseColumnNames.

@Test(dataProvider = "rowCount")
public void testParquetUseColumnNames(int rowCount) throws Exception {
    List<TestColumn> writeColumns = getTestColumnsSupportedByParquet();
    List<TestColumn> readColumns = Lists.reverse(writeColumns);
    assertThatFileFormat(PARQUET).withWriteColumns(writeColumns).withReadColumns(readColumns).withRowsCount(rowCount).withSession(parquetCursorSession).isReadableByRecordCursor(new ParquetRecordCursorProvider(true, HDFS_ENVIRONMENT));
    assertThatFileFormat(PARQUET).withWriteColumns(writeColumns).withReadColumns(readColumns).withRowsCount(rowCount).withSession(parquetCursorPushdownSession).isReadableByRecordCursor(new ParquetRecordCursorProvider(true, HDFS_ENVIRONMENT));
}
Also used : ParquetRecordCursorProvider(com.facebook.presto.hive.parquet.ParquetRecordCursorProvider) Test(org.testng.annotations.Test)

Example 2 with ParquetRecordCursorProvider

use of com.facebook.presto.hive.parquet.ParquetRecordCursorProvider in project presto by prestodb.

the class TestHiveFileFormats method testParquetThrift.

@Test(dataProvider = "rowCount")
public void testParquetThrift(int rowCount) throws Exception {
    RowType nameType = new RowType(ImmutableList.of(createUnboundedVarcharType(), createUnboundedVarcharType()), Optional.empty());
    RowType phoneType = new RowType(ImmutableList.of(createUnboundedVarcharType(), createUnboundedVarcharType()), Optional.empty());
    RowType personType = new RowType(ImmutableList.of(nameType, INTEGER, createUnboundedVarcharType(), new ArrayType(phoneType)), Optional.empty());
    List<TestColumn> testColumns = ImmutableList.of(new TestColumn("persons", getStandardListObjectInspector(getStandardStructObjectInspector(ImmutableList.of("name", "id", "email", "phones"), ImmutableList.of(getStandardStructObjectInspector(ImmutableList.of("first_name", "last_name"), ImmutableList.of(javaStringObjectInspector, javaStringObjectInspector)), javaIntObjectInspector, javaStringObjectInspector, getStandardListObjectInspector(getStandardStructObjectInspector(ImmutableList.of("number", "type"), ImmutableList.of(javaStringObjectInspector, javaStringObjectInspector)))))), null, arrayBlockOf(personType, rowBlockOf(ImmutableList.of(nameType, INTEGER, createUnboundedVarcharType(), new ArrayType(phoneType)), rowBlockOf(ImmutableList.of(createUnboundedVarcharType(), createUnboundedVarcharType()), "Bob", "Roberts"), 0, "bob.roberts@example.com", arrayBlockOf(phoneType, rowBlockOf(ImmutableList.of(createUnboundedVarcharType(), createUnboundedVarcharType()), "1234567890", null))))));
    File file = new File(this.getClass().getClassLoader().getResource("addressbook.parquet").getPath());
    FileSplit split = new FileSplit(new Path(file.getAbsolutePath()), 0, file.length(), new String[0]);
    HiveRecordCursorProvider cursorProvider = new ParquetRecordCursorProvider(false, HDFS_ENVIRONMENT);
    testCursorProvider(cursorProvider, split, PARQUET, testColumns, 1);
}
Also used : ArrayType(com.facebook.presto.type.ArrayType) Path(org.apache.hadoop.fs.Path) ParquetRecordCursorProvider(com.facebook.presto.hive.parquet.ParquetRecordCursorProvider) RowType(com.facebook.presto.type.RowType) FileSplit(org.apache.hadoop.mapred.FileSplit) File(java.io.File) Test(org.testng.annotations.Test)

Example 3 with ParquetRecordCursorProvider

use of com.facebook.presto.hive.parquet.ParquetRecordCursorProvider in project presto by prestodb.

the class TestHiveFileFormats method testParquet.

@Test(dataProvider = "rowCount")
public void testParquet(int rowCount) throws Exception {
    List<TestColumn> testColumns = getTestColumnsSupportedByParquet();
    assertThatFileFormat(PARQUET).withColumns(testColumns).withRowsCount(rowCount).withSession(parquetCursorSession).isReadableByRecordCursor(new ParquetRecordCursorProvider(false, HDFS_ENVIRONMENT));
    assertThatFileFormat(PARQUET).withColumns(testColumns).withRowsCount(rowCount).withSession(parquetCursorPushdownSession).isReadableByRecordCursor(new ParquetRecordCursorProvider(false, HDFS_ENVIRONMENT));
}
Also used : ParquetRecordCursorProvider(com.facebook.presto.hive.parquet.ParquetRecordCursorProvider) Test(org.testng.annotations.Test)

Example 4 with ParquetRecordCursorProvider

use of com.facebook.presto.hive.parquet.ParquetRecordCursorProvider in project presto by prestodb.

the class TestHiveFileFormats method testParquetCaseInsensitiveColumnLookup.

@Test(dataProvider = "rowCount")
public void testParquetCaseInsensitiveColumnLookup(int rowCount) throws Exception {
    List<TestColumn> writeColumns = ImmutableList.of(new TestColumn("column_name", javaStringObjectInspector, "test", utf8Slice("test"), false));
    List<TestColumn> readColumns = ImmutableList.of(new TestColumn("Column_Name", javaStringObjectInspector, "test", utf8Slice("test"), false));
    assertThatFileFormat(PARQUET).withWriteColumns(writeColumns).withReadColumns(readColumns).withRowsCount(rowCount).withSession(parquetCursorSession).isReadableByRecordCursor(new ParquetRecordCursorProvider(true, HDFS_ENVIRONMENT));
    assertThatFileFormat(PARQUET).withWriteColumns(writeColumns).withReadColumns(readColumns).withRowsCount(rowCount).withSession(parquetCursorPushdownSession).isReadableByRecordCursor(new ParquetRecordCursorProvider(true, HDFS_ENVIRONMENT));
}
Also used : ParquetRecordCursorProvider(com.facebook.presto.hive.parquet.ParquetRecordCursorProvider) Test(org.testng.annotations.Test)

Aggregations

ParquetRecordCursorProvider (com.facebook.presto.hive.parquet.ParquetRecordCursorProvider)4 Test (org.testng.annotations.Test)4 ArrayType (com.facebook.presto.type.ArrayType)1 RowType (com.facebook.presto.type.RowType)1 File (java.io.File)1 Path (org.apache.hadoop.fs.Path)1 FileSplit (org.apache.hadoop.mapred.FileSplit)1