Search in sources :

Example 1 with HivePageSourceFactory

use of io.trino.plugin.hive.HivePageSourceFactory in project trino by trinodb.

the class TestTimestampMicros method createPageSource.

private ConnectorPageSource createPageSource(ConnectorSession session, File parquetFile, String columnName, HiveType columnHiveType, Type columnType) {
    // TODO after https://github.com/trinodb/trino/pull/5283, replace the method with
    // return FileFormat.PRESTO_PARQUET.createFileFormatReader(session, HDFS_ENVIRONMENT, parquetFile, columnNames, columnTypes);
    HivePageSourceFactory pageSourceFactory = StandardFileFormats.TRINO_PARQUET.getHivePageSourceFactory(HDFS_ENVIRONMENT).orElseThrow();
    Properties schema = new Properties();
    schema.setProperty(SERIALIZATION_LIB, HiveStorageFormat.PARQUET.getSerde());
    ReaderPageSource pageSourceWithProjections = pageSourceFactory.createPageSource(new Configuration(false), session, new Path(parquetFile.toURI()), 0, parquetFile.length(), parquetFile.length(), schema, List.of(createBaseColumn(columnName, 0, columnHiveType, columnType, REGULAR, Optional.empty())), TupleDomain.all(), Optional.empty(), OptionalInt.empty(), false, AcidTransaction.NO_ACID_TRANSACTION).orElseThrow();
    pageSourceWithProjections.getReaderColumns().ifPresent(projections -> {
        throw new IllegalStateException("Unexpected projections: " + projections);
    });
    return pageSourceWithProjections.get();
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) ReaderPageSource(io.trino.plugin.hive.ReaderPageSource) Properties(java.util.Properties) HivePageSourceFactory(io.trino.plugin.hive.HivePageSourceFactory)

Aggregations

HivePageSourceFactory (io.trino.plugin.hive.HivePageSourceFactory)1 ReaderPageSource (io.trino.plugin.hive.ReaderPageSource)1 Properties (java.util.Properties)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1