Search in sources :

Example 6 with HiveConfig

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

the class TestMetastoreHiveStatisticsProvider method testGetTableStatisticsValidationFailure.

@Test
public void testGetTableStatisticsValidationFailure() {
    PartitionStatistics corruptedStatistics = PartitionStatistics.builder().setBasicStatistics(new HiveBasicStatistics(-1, 0, 0, 0)).build();
    String partitionName = "p1=string1/p2=1234";
    MetastoreHiveStatisticsProvider statisticsProvider = new MetastoreHiveStatisticsProvider((session, table, hivePartitions) -> ImmutableMap.of(partitionName, corruptedStatistics));
    assertThatThrownBy(() -> statisticsProvider.getTableStatistics(getHiveSession(new HiveConfig().setIgnoreCorruptedStatistics(false)), TABLE, ImmutableMap.of(), ImmutableMap.of(), ImmutableList.of(partition(partitionName)))).isInstanceOf(TrinoException.class).hasFieldOrPropertyWithValue("errorCode", HIVE_CORRUPTED_COLUMN_STATISTICS.toErrorCode());
    assertEquals(statisticsProvider.getTableStatistics(getHiveSession(new HiveConfig().setIgnoreCorruptedStatistics(true)), TABLE, ImmutableMap.of(), ImmutableMap.of(), ImmutableList.of(partition(partitionName))), TableStatistics.empty());
}
Also used : MetastoreHiveStatisticsProvider.validatePartitionStatistics(io.trino.plugin.hive.statistics.MetastoreHiveStatisticsProvider.validatePartitionStatistics) PartitionStatistics(io.trino.plugin.hive.PartitionStatistics) TrinoException(io.trino.spi.TrinoException) HiveBasicStatistics(io.trino.plugin.hive.HiveBasicStatistics) HiveConfig(io.trino.plugin.hive.HiveConfig) Test(org.testng.annotations.Test)

Example 7 with HiveConfig

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

the class TestRubixCaching method setup.

@BeforeClass
public void setup() throws IOException {
    cacheStoragePath = getStoragePath("/");
    config = new HdfsConfig();
    List<PropertyMetadata<?>> hiveSessionProperties = getHiveSessionProperties(new HiveConfig(), new RubixEnabledConfig().setCacheEnabled(true), new OrcReaderConfig()).getSessionProperties();
    context = new HdfsContext(TestingConnectorSession.builder().setPropertyMetadata(hiveSessionProperties).build());
    nonCachingFileSystem = getNonCachingFileSystem();
}
Also used : OrcReaderConfig(io.trino.plugin.hive.orc.OrcReaderConfig) HdfsConfig(io.trino.plugin.hive.HdfsConfig) PropertyMetadata(io.trino.spi.session.PropertyMetadata) HdfsContext(io.trino.plugin.hive.HdfsEnvironment.HdfsContext) HiveConfig(io.trino.plugin.hive.HiveConfig) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with HiveConfig

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

the class ParquetTester method assertMaxReadBytes.

void assertMaxReadBytes(List<ObjectInspector> objectInspectors, Iterable<?>[] writeValues, Iterable<?>[] readValues, List<String> columnNames, List<Type> columnTypes, Optional<MessageType> parquetSchema, DataSize maxReadBlockSize) throws Exception {
    CompressionCodecName compressionCodecName = UNCOMPRESSED;
    HiveSessionProperties hiveSessionProperties = new HiveSessionProperties(new HiveConfig().setHiveStorageFormat(HiveStorageFormat.PARQUET).setUseParquetColumnNames(false), new OrcReaderConfig(), new OrcWriterConfig(), new ParquetReaderConfig().setMaxReadBlockSize(maxReadBlockSize), new ParquetWriterConfig());
    ConnectorSession session = TestingConnectorSession.builder().setPropertyMetadata(hiveSessionProperties.getSessionProperties()).build();
    try (TempFile tempFile = new TempFile("test", "parquet")) {
        JobConf jobConf = new JobConf();
        jobConf.setEnum(COMPRESSION, compressionCodecName);
        jobConf.setBoolean(ENABLE_DICTIONARY, true);
        jobConf.setEnum(WRITER_VERSION, PARQUET_1_0);
        writeParquetColumn(jobConf, tempFile.getFile(), compressionCodecName, createTableProperties(columnNames, objectInspectors), getStandardStructObjectInspector(columnNames, objectInspectors), getIterators(writeValues), parquetSchema, false);
        Iterator<?>[] expectedValues = getIterators(readValues);
        try (ConnectorPageSource pageSource = fileFormat.createFileFormatReader(session, HDFS_ENVIRONMENT, tempFile.getFile(), columnNames, columnTypes)) {
            assertPageSource(columnTypes, expectedValues, pageSource, Optional.of(getParquetMaxReadBlockSize(session).toBytes()));
            assertFalse(stream(expectedValues).allMatch(Iterator::hasNext));
        }
    }
}
Also used : OrcWriterConfig(io.trino.plugin.hive.orc.OrcWriterConfig) ConnectorPageSource(io.trino.spi.connector.ConnectorPageSource) HiveSessionProperties(io.trino.plugin.hive.HiveSessionProperties) HiveConfig(io.trino.plugin.hive.HiveConfig) OrcReaderConfig(io.trino.plugin.hive.orc.OrcReaderConfig) CompressionCodecName(org.apache.parquet.hadoop.metadata.CompressionCodecName) AbstractIterator(com.google.common.collect.AbstractIterator) Iterator(java.util.Iterator) ConnectorSession(io.trino.spi.connector.ConnectorSession) TestingConnectorSession(io.trino.testing.TestingConnectorSession) JobConf(org.apache.hadoop.mapred.JobConf)

Example 9 with HiveConfig

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

the class TestTimestamp method testTimestampBackedByInt64.

@Test
public void testTimestampBackedByInt64() throws Exception {
    MessageType parquetSchema = parseMessageType("message hive_timestamp { optional int64 test (TIMESTAMP_MILLIS); }");
    ContiguousSet<Long> epochMillisValues = ContiguousSet.create(Range.closedOpen((long) -1_000, (long) 1_000), DiscreteDomain.longs());
    ImmutableList.Builder<SqlTimestamp> timestampsMillis = ImmutableList.builder();
    ImmutableList.Builder<Long> bigints = ImmutableList.builder();
    for (long value : epochMillisValues) {
        timestampsMillis.add(SqlTimestamp.fromMillis(3, value));
        bigints.add(value);
    }
    List<ObjectInspector> objectInspectors = singletonList(javaLongObjectInspector);
    List<String> columnNames = ImmutableList.of("test");
    ConnectorSession session = getHiveSession(new HiveConfig());
    try (ParquetTester.TempFile tempFile = new ParquetTester.TempFile("test", "parquet")) {
        JobConf jobConf = new JobConf();
        jobConf.setEnum(WRITER_VERSION, PARQUET_1_0);
        ParquetTester.writeParquetColumn(jobConf, tempFile.getFile(), CompressionCodecName.SNAPPY, ParquetTester.createTableProperties(columnNames, objectInspectors), getStandardStructObjectInspector(columnNames, objectInspectors), new Iterator<?>[] { epochMillisValues.iterator() }, Optional.of(parquetSchema), false);
        testReadingAs(TIMESTAMP_MILLIS, session, tempFile, columnNames, timestampsMillis.build());
        testReadingAs(BIGINT, session, tempFile, columnNames, bigints.build());
    }
}
Also used : PrimitiveObjectInspectorFactory.javaLongObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaLongObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) ObjectInspectorFactory.getStandardStructObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory.getStandardStructObjectInspector) ImmutableList(com.google.common.collect.ImmutableList) SqlTimestamp(io.trino.spi.type.SqlTimestamp) HiveConfig(io.trino.plugin.hive.HiveConfig) ConnectorSession(io.trino.spi.connector.ConnectorSession) JobConf(org.apache.hadoop.mapred.JobConf) MessageTypeParser.parseMessageType(org.apache.parquet.schema.MessageTypeParser.parseMessageType) MessageType(org.apache.parquet.schema.MessageType) Test(org.testng.annotations.Test)

Aggregations

HiveConfig (io.trino.plugin.hive.HiveConfig)9 ConnectorSession (io.trino.spi.connector.ConnectorSession)5 Test (org.testng.annotations.Test)5 ConnectorPageSource (io.trino.spi.connector.ConnectorPageSource)3 HdfsConfig (io.trino.plugin.hive.HdfsConfig)2 HiveSessionProperties (io.trino.plugin.hive.HiveSessionProperties)2 HiveType (io.trino.plugin.hive.HiveType)2 OrcReaderConfig (io.trino.plugin.hive.orc.OrcReaderConfig)2 TimestampType.createTimestampType (io.trino.spi.type.TimestampType.createTimestampType)2 TimestampWithTimeZoneType.createTimestampWithTimeZoneType (io.trino.spi.type.TimestampWithTimeZoneType.createTimestampWithTimeZoneType)2 Type (io.trino.spi.type.Type)2 MaterializedResult (io.trino.testing.MaterializedResult)2 MaterializedRow (io.trino.testing.MaterializedRow)2 File (java.io.File)2 JobConf (org.apache.hadoop.mapred.JobConf)2 BeforeClass (org.testng.annotations.BeforeClass)2 AbstractIterator (com.google.common.collect.AbstractIterator)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 GenericHiveRecordCursorProvider (io.trino.plugin.hive.GenericHiveRecordCursorProvider)1