Search in sources :

Example 6 with RaptorColumnHandle

use of io.trino.plugin.raptor.legacy.RaptorColumnHandle in project trino by trinodb.

the class TestShardPredicate method testRangeShardUuidPredicate.

@Test
public void testRangeShardUuidPredicate() {
    Slice uuid0 = utf8Slice(randomUUID().toString());
    TupleDomain<RaptorColumnHandle> tupleDomain = withColumnDomains(ImmutableMap.of(shardUuidColumnHandle(), create(SortedRangeSet.copyOf(VARCHAR, ImmutableList.of(greaterThanOrEqual(VARCHAR, uuid0))), false)));
    ShardPredicate shardPredicate = ShardPredicate.create(tupleDomain);
    assertEquals(shardPredicate.getPredicate(), "true");
}
Also used : RaptorColumnHandle(io.trino.plugin.raptor.legacy.RaptorColumnHandle) Slice(io.airlift.slice.Slice) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Test(org.testng.annotations.Test)

Example 7 with RaptorColumnHandle

use of io.trino.plugin.raptor.legacy.RaptorColumnHandle in project trino by trinodb.

the class TestDatabaseShardManager method testShardPruning.

@Test
public void testShardPruning() {
    ShardInfo shard1 = shardInfo(UUID.randomUUID(), "node1", ImmutableList.<ColumnStats>builder().add(new ColumnStats(1, 5, 10)).add(new ColumnStats(2, -20.0, 20.0)).add(new ColumnStats(3, date(2013, 5, 11), date(2013, 6, 13))).add(new ColumnStats(4, timestamp(2013, 5, 11, 4, 5, 6), timestamp(2013, 6, 13, 7, 8, 9))).add(new ColumnStats(5, "hello", "world")).add(new ColumnStats(6, false, true)).build());
    ShardInfo shard2 = shardInfo(UUID.randomUUID(), "node2", ImmutableList.<ColumnStats>builder().add(new ColumnStats(1, 2, 8)).add(new ColumnStats(2, null, 50.0)).add(new ColumnStats(3, date(2012, 1, 1), date(2012, 12, 31))).add(new ColumnStats(4, timestamp(2012, 1, 1, 2, 3, 4), timestamp(2012, 12, 31, 5, 6, 7))).add(new ColumnStats(5, "cat", "dog")).add(new ColumnStats(6, true, true)).build());
    ShardInfo shard3 = shardInfo(UUID.randomUUID(), "node3", ImmutableList.<ColumnStats>builder().add(new ColumnStats(1, 15, 20)).add(new ColumnStats(2, null, null)).add(new ColumnStats(3, date(2013, 4, 1), date(2013, 6, 1))).add(new ColumnStats(4, timestamp(2013, 4, 1, 8, 7, 6), timestamp(2013, 6, 1, 6, 5, 4))).add(new ColumnStats(5, "grape", "orange")).add(new ColumnStats(6, false, false)).build());
    List<ShardInfo> shards = ImmutableList.<ShardInfo>builder().add(shard1).add(shard2).add(shard3).build();
    List<ColumnInfo> columns = ImmutableList.<ColumnInfo>builder().add(new ColumnInfo(1, BIGINT)).add(new ColumnInfo(2, DOUBLE)).add(new ColumnInfo(3, DATE)).add(new ColumnInfo(4, TIMESTAMP_MILLIS)).add(new ColumnInfo(5, createVarcharType(10))).add(new ColumnInfo(6, BOOLEAN)).add(new ColumnInfo(7, VARBINARY)).build();
    RaptorColumnHandle c1 = new RaptorColumnHandle("c1", 1, BIGINT);
    RaptorColumnHandle c2 = new RaptorColumnHandle("c2", 2, DOUBLE);
    RaptorColumnHandle c3 = new RaptorColumnHandle("c3", 3, DATE);
    RaptorColumnHandle c4 = new RaptorColumnHandle("c4", 4, TIMESTAMP_MILLIS);
    RaptorColumnHandle c5 = new RaptorColumnHandle("c5", 5, createVarcharType(10));
    RaptorColumnHandle c6 = new RaptorColumnHandle("c6", 6, BOOLEAN);
    long tableId = createTable("test");
    shardManager.createTable(tableId, columns, false, OptionalLong.empty());
    long transactionId = shardManager.beginTransaction();
    shardManager.commitShards(transactionId, tableId, columns, shards, Optional.empty(), 0);
    shardAssertion(tableId).expected(shards);
    shardAssertion(tableId).equal(c1, BIGINT, 3L).expected(shard2);
    shardAssertion(tableId).equal(c1, BIGINT, 8L).expected(shard1, shard2);
    shardAssertion(tableId).equal(c1, BIGINT, 9L).expected(shard1);
    shardAssertion(tableId).equal(c1, BIGINT, 13L).expected();
    shardAssertion(tableId).between(c1, BIGINT, 8L, 14L).expected(shard1, shard2);
    shardAssertion(tableId).between(c1, BIGINT, 8L, 15L).expected(shards);
    shardAssertion(tableId).between(c1, BIGINT, 8L, 16L).expected(shards);
    shardAssertion(tableId).between(c1, BIGINT, 12L, 14L).expected();
    shardAssertion(tableId).between(c1, BIGINT, 5L, 10L).expected(shard1, shard2);
    shardAssertion(tableId).between(c1, BIGINT, 16L, 18L).expected(shard3);
    shardAssertion(tableId).between(c1, BIGINT, 1L, 25L).expected(shards);
    shardAssertion(tableId).between(c1, BIGINT, 4L, 12L).expected(shard1, shard2);
    shardAssertion(tableId).range(c1, lessThan(BIGINT, 5L)).expected(shard1, shard2);
    shardAssertion(tableId).range(c1, lessThan(BIGINT, 4L)).expected(shard2);
    shardAssertion(tableId).range(c1, lessThan(BIGINT, 11L)).expected(shard1, shard2);
    shardAssertion(tableId).range(c1, lessThan(BIGINT, 25L)).expected(shards);
    shardAssertion(tableId).range(c1, greaterThan(BIGINT, 1L)).expected(shards);
    shardAssertion(tableId).range(c1, greaterThan(BIGINT, 8L)).expected(shards);
    shardAssertion(tableId).range(c1, greaterThan(BIGINT, 9L)).expected(shard1, shard3);
    shardAssertion(tableId).between(c1, BIGINT, -25L, 25L).between(c2, DOUBLE, -1000.0, 1000.0).between(c3, BIGINT, 0L, 50000L).between(c4, TIMESTAMP_MILLIS, 0L, timestamp(2015, 1, 2, 3, 4, 5)).between(c5, createVarcharType(10), utf8Slice("a"), utf8Slice("zzzzz")).between(c6, BOOLEAN, false, true).expected(shards);
    shardAssertion(tableId).between(c1, BIGINT, 4L, 12L).between(c3, DATE, date(2013, 3, 3), date(2013, 5, 25)).expected(shard1);
    shardAssertion(tableId).equal(c2, DOUBLE, 25.0).expected(shard2, shard3);
    shardAssertion(tableId).equal(c2, DOUBLE, 50.1).expected(shard3);
    shardAssertion(tableId).equal(c3, DATE, date(2013, 5, 12)).expected(shard1, shard3);
    shardAssertion(tableId).range(c4, greaterThan(TIMESTAMP_MILLIS, timestamp(2013, 1, 1, 0, 0, 0))).expected(shard1, shard3);
    shardAssertion(tableId).between(c5, createVarcharType(10), utf8Slice("cow"), utf8Slice("milk")).expected(shards);
    shardAssertion(tableId).equal(c5, createVarcharType(10), utf8Slice("fruit")).expected();
    shardAssertion(tableId).equal(c5, createVarcharType(10), utf8Slice("pear")).expected(shard1);
    shardAssertion(tableId).equal(c5, createVarcharType(10), utf8Slice("cat")).expected(shard2);
    shardAssertion(tableId).range(c5, greaterThan(createVarcharType(10), utf8Slice("gum"))).expected(shard1, shard3);
    shardAssertion(tableId).range(c5, lessThan(createVarcharType(10), utf8Slice("air"))).expected();
    shardAssertion(tableId).equal(c6, BOOLEAN, true).expected(shard1, shard2);
    shardAssertion(tableId).equal(c6, BOOLEAN, false).expected(shard1, shard3);
    shardAssertion(tableId).range(c6, greaterThanOrEqual(BOOLEAN, false)).expected(shards);
    shardAssertion(tableId).range(c6, lessThan(BOOLEAN, true)).expected(shards);
    shardAssertion(tableId).range(c6, lessThan(BOOLEAN, false)).expected(shard1, shard3);
    // Test multiple ranges
    shardAssertion(tableId).domain(c1, createDomain(lessThan(BIGINT, 0L), greaterThan(BIGINT, 25L))).expected();
    shardAssertion(tableId).domain(c1, createDomain(range(BIGINT, 3L, true, 4L, true), range(BIGINT, 16L, true, 18L, true))).expected(shard2, shard3);
    shardAssertion(tableId).domain(c5, createDomain(range(createVarcharType(10), utf8Slice("gum"), true, utf8Slice("happy"), true), range(createVarcharType(10), utf8Slice("pear"), true, utf8Slice("wall"), true))).expected(shard1, shard3);
    shardAssertion(tableId).domain(c1, createDomain(range(BIGINT, 3L, true, 4L, true), range(BIGINT, 16L, true, 18L, true))).domain(c5, createDomain(range(createVarcharType(10), utf8Slice("gum"), true, utf8Slice("happy"), true), range(createVarcharType(10), utf8Slice("pear"), true, utf8Slice("wall"), true))).expected(shard3);
}
Also used : RaptorColumnHandle(io.trino.plugin.raptor.legacy.RaptorColumnHandle) Test(org.testng.annotations.Test)

Example 8 with RaptorColumnHandle

use of io.trino.plugin.raptor.legacy.RaptorColumnHandle in project trino by trinodb.

the class TestDatabaseShardManager method testShardPruningNoStats.

@Test
public void testShardPruningNoStats() {
    ShardInfo shard = shardInfo(UUID.randomUUID(), "node");
    List<ShardInfo> shards = ImmutableList.of(shard);
    long tableId = createTable("test");
    List<ColumnInfo> columns = ImmutableList.of(new ColumnInfo(1, BIGINT));
    RaptorColumnHandle c1 = new RaptorColumnHandle("c1", 1, BIGINT);
    shardManager.createTable(tableId, columns, false, OptionalLong.empty());
    long transactionId = shardManager.beginTransaction();
    shardManager.commitShards(transactionId, tableId, columns, shards, Optional.empty(), 0);
    shardAssertion(tableId).expected(shards);
    shardAssertion(tableId).equal(c1, BIGINT, 3L).expected(shards);
}
Also used : RaptorColumnHandle(io.trino.plugin.raptor.legacy.RaptorColumnHandle) Test(org.testng.annotations.Test)

Example 9 with RaptorColumnHandle

use of io.trino.plugin.raptor.legacy.RaptorColumnHandle in project trino by trinodb.

the class TestRaptorMetadata method testCreateTable.

@Test
public void testCreateTable() {
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    metadata.createTable(SESSION, getOrdersTable(), false);
    ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
    assertInstanceOf(tableHandle, RaptorTableHandle.class);
    assertEquals(((RaptorTableHandle) tableHandle).getTableId(), 1);
    ConnectorTableMetadata table = metadata.getTableMetadata(SESSION, tableHandle);
    assertTableEqual(table, getOrdersTable());
    ColumnHandle columnHandle = metadata.getColumnHandles(SESSION, tableHandle).get("orderkey");
    assertInstanceOf(columnHandle, RaptorColumnHandle.class);
    assertEquals(((RaptorColumnHandle) columnHandle).getColumnId(), 1);
    ColumnMetadata columnMetadata = metadata.getColumnMetadata(SESSION, tableHandle, columnHandle);
    assertNotNull(columnMetadata);
    assertEquals(columnMetadata.getName(), "orderkey");
    assertEquals(columnMetadata.getType(), BIGINT);
}
Also used : RaptorColumnHandle(io.trino.plugin.raptor.legacy.RaptorColumnHandle) ColumnHandle(io.trino.spi.connector.ColumnHandle) ColumnMetadata(io.trino.spi.connector.ColumnMetadata) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Test(org.testng.annotations.Test)

Aggregations

RaptorColumnHandle (io.trino.plugin.raptor.legacy.RaptorColumnHandle)9 Test (org.testng.annotations.Test)8 Slice (io.airlift.slice.Slice)4 Slices.utf8Slice (io.airlift.slice.Slices.utf8Slice)4 Type (io.trino.spi.type.Type)2 ImmutableList (com.google.common.collect.ImmutableList)1 ShardInfo (io.trino.plugin.raptor.legacy.metadata.ShardInfo)1 ColumnIndexStatsUtils.jdbcType (io.trino.plugin.raptor.legacy.storage.ColumnIndexStatsUtils.jdbcType)1 Page (io.trino.spi.Page)1 ColumnHandle (io.trino.spi.connector.ColumnHandle)1 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)1 ConnectorPageSource (io.trino.spi.connector.ConnectorPageSource)1 ConnectorTableHandle (io.trino.spi.connector.ConnectorTableHandle)1 ConnectorTableMetadata (io.trino.spi.connector.ConnectorTableMetadata)1 Domain (io.trino.spi.predicate.Domain)1 NullableValue (io.trino.spi.predicate.NullableValue)1 Range (io.trino.spi.predicate.Range)1 Ranges (io.trino.spi.predicate.Ranges)1 TupleDomain (io.trino.spi.predicate.TupleDomain)1 VarcharType.createVarcharType (io.trino.spi.type.VarcharType.createVarcharType)1