Search in sources :

Example 66 with SchemaTableName

use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.

the class TestHiveMetadata method testCreatePredicateWithNaN.

@Test
public void testCreatePredicateWithNaN() {
    HiveColumnHandle columnHandle = DOUBLE_COLUMN_HANDLE;
    ImmutableList.Builder<HivePartition> partitions = ImmutableList.builder();
    partitions.add(new HivePartition(new SchemaTableName("test", "test"), "p1", ImmutableMap.of(columnHandle, NullableValue.of(DOUBLE, Double.NaN))));
    partitions.add(new HivePartition(new SchemaTableName("test", "test"), "p2", ImmutableMap.of(columnHandle, NullableValue.of(DOUBLE, 4.2))));
    Domain domain = createPredicate(ImmutableList.of(columnHandle), partitions.build()).getDomains().orElseThrow().get(columnHandle);
    assertEquals(domain, Domain.notNull(DOUBLE));
}
Also used : ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) Domain(io.trino.spi.predicate.Domain) SchemaTableName(io.trino.spi.connector.SchemaTableName) Test(org.testng.annotations.Test)

Example 67 with SchemaTableName

use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.

the class TestHiveMetadata method testCreatePredicate.

@Test(timeOut = 10_000)
public void testCreatePredicate() {
    ImmutableList.Builder<HivePartition> partitions = ImmutableList.builder();
    for (int i = 0; i < 5_000; i++) {
        partitions.add(new HivePartition(new SchemaTableName("test", "test"), Integer.toString(i), ImmutableMap.of(TEST_COLUMN_HANDLE, NullableValue.of(VARCHAR, utf8Slice(Integer.toString(i))))));
    }
    Domain domain = createPredicate(ImmutableList.of(TEST_COLUMN_HANDLE), partitions.build()).getDomains().orElseThrow().get(TEST_COLUMN_HANDLE);
    assertEquals(domain, Domain.create(ValueSet.copyOf(VARCHAR, IntStream.range(0, 5_000).mapToObj(i -> utf8Slice(Integer.toString(i))).collect(toImmutableList())), false));
}
Also used : ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) Domain(io.trino.spi.predicate.Domain) SchemaTableName(io.trino.spi.connector.SchemaTableName) Test(org.testng.annotations.Test)

Example 68 with SchemaTableName

use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.

the class TestHiveMetadata method testCreateOnlyNullsPredicate.

@Test
public void testCreateOnlyNullsPredicate() {
    ImmutableList.Builder<HivePartition> partitions = ImmutableList.builder();
    for (int i = 0; i < 5; i++) {
        partitions.add(new HivePartition(new SchemaTableName("test", "test"), Integer.toString(i), ImmutableMap.of(TEST_COLUMN_HANDLE, NullableValue.asNull(VARCHAR))));
    }
    Domain domain = createPredicate(ImmutableList.of(TEST_COLUMN_HANDLE), partitions.build()).getDomains().orElseThrow().get(TEST_COLUMN_HANDLE);
    assertEquals(domain, Domain.onlyNull(VARCHAR));
}
Also used : ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) Domain(io.trino.spi.predicate.Domain) SchemaTableName(io.trino.spi.connector.SchemaTableName) Test(org.testng.annotations.Test)

Example 69 with SchemaTableName

use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.

the class TestPartitionOfflineException method testMessage.

@Test
public void testMessage() {
    assertMessage(new SchemaTableName("schema", "table"), "pk=1", false, "", "Table 'schema.table' partition 'pk=1' is offline");
    assertMessage(new SchemaTableName("schema", "table"), "pk=1", false, null, "Table 'schema.table' partition 'pk=1' is offline");
    assertMessage(new SchemaTableName("schema", "table"), "pk=1", true, "", "Table 'schema.table' partition 'pk=1' is offline for Presto");
    assertMessage(new SchemaTableName("schema", "table"), "pk=1", true, null, "Table 'schema.table' partition 'pk=1' is offline for Presto");
    assertMessage(new SchemaTableName("schema", "table"), "pk=1", false, "offline reason", "Table 'schema.table' partition 'pk=1' is offline: offline reason");
    assertMessage(new SchemaTableName("schema", "table"), "pk=1", true, "offline reason", "Table 'schema.table' partition 'pk=1' is offline for Presto: offline reason");
}
Also used : SchemaTableName(io.trino.spi.connector.SchemaTableName) Test(org.testng.annotations.Test)

Example 70 with SchemaTableName

use of io.trino.spi.connector.SchemaTableName in project trino by trinodb.

the class TestingMetadata method getColumnMetadata.

@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) {
    SchemaTableName tableName = getTableName(tableHandle);
    int columnIndex = ((TestingColumnHandle) columnHandle).getOrdinalPosition();
    return tables.get(tableName).getColumns().get(columnIndex);
}
Also used : SchemaTableName(io.trino.spi.connector.SchemaTableName)

Aggregations

SchemaTableName (io.trino.spi.connector.SchemaTableName)446 Test (org.testng.annotations.Test)212 ImmutableList (com.google.common.collect.ImmutableList)131 ImmutableMap (com.google.common.collect.ImmutableMap)106 List (java.util.List)102 TrinoException (io.trino.spi.TrinoException)100 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)98 ConnectorSession (io.trino.spi.connector.ConnectorSession)98 CatalogSchemaTableName (io.trino.spi.connector.CatalogSchemaTableName)92 TableNotFoundException (io.trino.spi.connector.TableNotFoundException)89 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)86 ConnectorTableMetadata (io.trino.spi.connector.ConnectorTableMetadata)86 Optional (java.util.Optional)78 Map (java.util.Map)67 ColumnHandle (io.trino.spi.connector.ColumnHandle)66 TupleDomain (io.trino.spi.predicate.TupleDomain)59 ConnectorMetadata (io.trino.spi.connector.ConnectorMetadata)58 Path (org.apache.hadoop.fs.Path)55 ConnectorTableHandle (io.trino.spi.connector.ConnectorTableHandle)53 ImmutableSet (com.google.common.collect.ImmutableSet)52