use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class TestRaptorMetadata method testTableProperties.
@Test
public void testTableProperties() throws Exception {
assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
ConnectorTableMetadata ordersTable = getOrdersTable(ImmutableMap.of(ORDERING_PROPERTY, ImmutableList.of("orderdate", "custkey"), TEMPORAL_COLUMN_PROPERTY, "orderdate"));
metadata.createTable(SESSION, ordersTable);
ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
assertInstanceOf(tableHandle, RaptorTableHandle.class);
RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
assertEquals(raptorTableHandle.getTableId(), 1);
long tableId = raptorTableHandle.getTableId();
MetadataDao metadataDao = dbi.onDemand(MetadataDao.class);
// verify sort columns
List<TableColumn> sortColumns = metadataDao.listSortColumns(tableId);
assertTableColumnsEqual(sortColumns, ImmutableList.of(new TableColumn(DEFAULT_TEST_ORDERS, "orderdate", DATE, 4, OptionalInt.empty(), OptionalInt.of(0), true), new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2, OptionalInt.empty(), OptionalInt.of(1), false)));
// verify temporal column
assertEquals(metadataDao.getTemporalColumnId(tableId), Long.valueOf(4));
// verify no organization
assertFalse(metadataDao.getTableInformation(tableId).isOrganized());
metadata.dropTable(SESSION, tableHandle);
}
use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class TestRaptorMetadata method testTemporalColumn.
@Test
public void testTemporalColumn() throws Exception {
assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
ConnectorTableMetadata ordersTable = getOrdersTable(ImmutableMap.of(TEMPORAL_COLUMN_PROPERTY, "orderdate"));
metadata.createTable(SESSION, ordersTable);
ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
assertInstanceOf(tableHandle, RaptorTableHandle.class);
RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
assertEquals(raptorTableHandle.getTableId(), 1);
long tableId = raptorTableHandle.getTableId();
MetadataDao metadataDao = dbi.onDemand(MetadataDao.class);
// verify sort columns are not set
List<TableColumn> sortColumns = metadataDao.listSortColumns(tableId);
assertEquals(sortColumns.size(), 0);
assertEquals(sortColumns, ImmutableList.of());
// verify temporal column is set
assertEquals(metadataDao.getTemporalColumnId(tableId), Long.valueOf(4));
metadata.dropTable(SESSION, tableHandle);
}
use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class TestRaptorMetadata method testCreateBucketedTable.
@Test
public void testCreateBucketedTable() {
assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
ConnectorTableMetadata ordersTable = getOrdersTable(ImmutableMap.of(BUCKET_COUNT_PROPERTY, 16, BUCKETED_ON_PROPERTY, ImmutableList.of("custkey", "orderkey")));
metadata.createTable(SESSION, ordersTable);
ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
assertInstanceOf(tableHandle, RaptorTableHandle.class);
RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
assertEquals(raptorTableHandle.getTableId(), 1);
long tableId = raptorTableHandle.getTableId();
MetadataDao metadataDao = dbi.onDemand(MetadataDao.class);
assertTableColumnsEqual(metadataDao.listBucketColumns(tableId), ImmutableList.of(new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2, OptionalInt.of(0), OptionalInt.empty(), false), new TableColumn(DEFAULT_TEST_ORDERS, "orderkey", BIGINT, 1, OptionalInt.of(1), OptionalInt.empty(), false)));
assertEquals(raptorTableHandle.getBucketCount(), OptionalInt.of(16));
assertEquals(getTableDistributionId(tableId), Long.valueOf(1));
metadata.dropTable(SESSION, tableHandle);
// create a new table and verify it has a different distribution
metadata.createTable(SESSION, ordersTable);
tableId = ((RaptorTableHandle) metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS)).getTableId();
assertEquals(tableId, 2);
assertEquals(getTableDistributionId(tableId), Long.valueOf(2));
}
use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class RedisMetadata method listTableColumns.
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) {
requireNonNull(prefix, "prefix is null");
ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();
List<SchemaTableName> tableNames;
if (prefix.getSchemaName() == null) {
tableNames = listTables(session, null);
} else {
tableNames = ImmutableList.of(new SchemaTableName(prefix.getSchemaName(), prefix.getTableName()));
}
for (SchemaTableName tableName : tableNames) {
ConnectorTableMetadata tableMetadata = getTableMetadata(tableName);
// table can disappear during listing operation
if (tableMetadata != null) {
columns.put(tableName, tableMetadata.getColumns());
}
}
return columns.build();
}
use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class TestExampleMetadata method getTableMetadata.
@Test
public void getTableMetadata() {
// known table
ConnectorTableMetadata tableMetadata = metadata.getTableMetadata(SESSION, NUMBERS_TABLE_HANDLE);
assertEquals(tableMetadata.getTable(), new SchemaTableName("example", "numbers"));
assertEquals(tableMetadata.getColumns(), ImmutableList.of(new ColumnMetadata("text", createUnboundedVarcharType()), new ColumnMetadata("value", BIGINT)));
// unknown tables should produce null
assertNull(metadata.getTableMetadata(SESSION, new ExampleTableHandle(CONNECTOR_ID, "unknown", "unknown")));
assertNull(metadata.getTableMetadata(SESSION, new ExampleTableHandle(CONNECTOR_ID, "example", "unknown")));
assertNull(metadata.getTableMetadata(SESSION, new ExampleTableHandle(CONNECTOR_ID, "unknown", "numbers")));
}
Aggregations