use of com.facebook.presto.spi.SchemaTableName in project presto by prestodb.
the class RaptorMetadata method getTableMetadata.
@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle tableHandle) {
RaptorTableHandle handle = (RaptorTableHandle) tableHandle;
SchemaTableName tableName = new SchemaTableName(handle.getSchemaName(), handle.getTableName());
List<TableColumn> tableColumns = dao.listTableColumns(handle.getTableId());
if (tableColumns.isEmpty()) {
throw new TableNotFoundException(tableName);
}
ImmutableMap.Builder<String, Object> properties = ImmutableMap.builder();
SortedMap<Integer, String> bucketing = new TreeMap<>();
SortedMap<Integer, String> ordering = new TreeMap<>();
for (TableColumn column : tableColumns) {
if (column.isTemporal()) {
properties.put(TEMPORAL_COLUMN_PROPERTY, column.getColumnName());
}
column.getBucketOrdinal().ifPresent(bucketOrdinal -> bucketing.put(bucketOrdinal, column.getColumnName()));
column.getSortOrdinal().ifPresent(sortOrdinal -> ordering.put(sortOrdinal, column.getColumnName()));
}
if (!bucketing.isEmpty()) {
properties.put(BUCKETED_ON_PROPERTY, ImmutableList.copyOf(bucketing.values()));
}
if (!ordering.isEmpty()) {
properties.put(ORDERING_PROPERTY, ImmutableList.copyOf(ordering.values()));
}
handle.getBucketCount().ifPresent(bucketCount -> properties.put(BUCKET_COUNT_PROPERTY, bucketCount));
handle.getDistributionName().ifPresent(distributionName -> properties.put(DISTRIBUTION_NAME_PROPERTY, distributionName));
// Only display organization and table_supports_delta_delete property if set
if (handle.isOrganized()) {
properties.put(ORGANIZED_PROPERTY, true);
}
if (handle.isTableSupportsDeltaDelete()) {
properties.put(TABLE_SUPPORTS_DELTA_DELETE, true);
}
List<ColumnMetadata> columns = tableColumns.stream().map(TableColumn::toColumnMetadata).collect(toCollection(ArrayList::new));
columns.add(hiddenColumn(SHARD_UUID_COLUMN_NAME, SHARD_UUID_COLUMN_TYPE));
if (handle.isBucketed()) {
columns.add(hiddenColumn(BUCKET_NUMBER_COLUMN_NAME, INTEGER));
}
properties.putAll(getExtraProperties(handle.getTableId()));
return new ConnectorTableMetadata(tableName, columns, properties.build());
}
use of com.facebook.presto.spi.SchemaTableName in project presto by prestodb.
the class TestPrometheusRetrieveUpValueIntegrationTests method testCreateTable.
@Test(expectedExceptions = PrestoException.class, dependsOnMethods = "testRetrieveUpValue")
public void testCreateTable() {
PrometheusMetadata metadata = new PrometheusMetadata(client);
metadata.createTable(SESSION, new ConnectorTableMetadata(new SchemaTableName("default", "foo"), ImmutableList.of(new ColumnMetadata("text", createUnboundedVarcharType()))), false);
}
use of com.facebook.presto.spi.SchemaTableName in project presto by prestodb.
the class AtopMetadata method getColumnMetadata.
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) {
String columnName = ((AtopColumnHandle) columnHandle).getName();
for (ColumnMetadata column : getTableMetadata(session, tableHandle).getColumns()) {
if (column.getName().equals(columnName)) {
return column;
}
}
AtopTableHandle atopTableHandle = (AtopTableHandle) tableHandle;
SchemaTableName tableName = new SchemaTableName(atopTableHandle.getSchema(), atopTableHandle.getTable().getName());
throw new ColumnNotFoundException(tableName, columnName);
}
use of com.facebook.presto.spi.SchemaTableName in project presto by prestodb.
the class AtopMetadata method getTableMetadata.
@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle tableHandle) {
AtopTableHandle atopTableHandle = (AtopTableHandle) tableHandle;
ImmutableList.Builder<ColumnMetadata> columns = ImmutableList.builder();
for (AtopColumn column : atopTableHandle.getTable().getColumns()) {
columns.add(new ColumnMetadata(column.getName(), typeManager.getType(column.getType())));
}
SchemaTableName schemaTableName = new SchemaTableName(atopTableHandle.getSchema(), atopTableHandle.getTable().getName());
return new ConnectorTableMetadata(schemaTableName, columns.build());
}
use of com.facebook.presto.spi.SchemaTableName in project presto by prestodb.
the class AtopMetadata method listTableColumns.
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) {
ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();
for (SchemaTableName tableName : listTables(session, prefix.getSchemaName())) {
ConnectorTableMetadata tableMetadata = getTableMetadata(session, getTableHandle(session, tableName));
columns.put(tableName, tableMetadata.getColumns());
}
return columns.build();
}
Aggregations