use of com.facebook.presto.spi.SchemaTableName in project presto by prestodb.
the class AccumuloMetadata method getTableMetadata.
@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle table) {
AccumuloTableHandle handle = (AccumuloTableHandle) table;
checkArgument(handle.getConnectorId().equals(connectorId), "table is not for this connector");
SchemaTableName tableName = new SchemaTableName(handle.getSchema(), handle.getTable());
ConnectorTableMetadata metadata = getTableMetadata(tableName);
if (metadata == null) {
throw new TableNotFoundException(tableName);
}
return metadata;
}
use of com.facebook.presto.spi.SchemaTableName in project presto by prestodb.
the class AccumuloMetadata 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();
for (SchemaTableName tableName : listTables(session, prefix)) {
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.SchemaTableName in project presto by prestodb.
the class ZooKeeperMetadataManager method createTableMetadata.
public void createTableMetadata(AccumuloTable table) {
SchemaTableName tableName = table.getSchemaTableName();
String tablePath = getTablePath(tableName);
try {
if (curator.checkExists().forPath(tablePath) != null) {
throw new InvalidActivityException(format("Metadata for table %s already exists", tableName));
}
} catch (Exception e) {
throw new PrestoException(ZOOKEEPER_ERROR, "ZK error when checking if table already exists", e);
}
try {
curator.create().creatingParentsIfNeeded().forPath(tablePath, toJsonBytes(table));
} catch (Exception e) {
throw new PrestoException(ZOOKEEPER_ERROR, "Error creating table znode in ZooKeeper", e);
}
}
use of com.facebook.presto.spi.SchemaTableName in project presto by prestodb.
the class ZooKeeperMetadataManager method getViewNames.
public Set<String> getViewNames(String schema) {
String schemaPath = getSchemaPath(schema);
boolean exists;
try {
exists = curator.checkExists().forPath(schemaPath) != null;
} catch (Exception e) {
throw new PrestoException(ZOOKEEPER_ERROR, "Error checking if schema exists", e);
}
if (exists) {
try {
Set<String> tables = new HashSet<>();
tables.addAll(curator.getChildren().forPath(schemaPath).stream().filter(x -> isAccumuloView(new SchemaTableName(schema, x))).collect(Collectors.toList()));
return tables;
} catch (Exception e) {
throw new PrestoException(ZOOKEEPER_ERROR, "Error fetching schemas", e);
}
} else {
throw new PrestoException(ZOOKEEPER_ERROR, "No metadata for schema " + schema);
}
}
use of com.facebook.presto.spi.SchemaTableName in project presto by prestodb.
the class ZooKeeperMetadataManager method createViewMetadata.
public void createViewMetadata(AccumuloView view) {
SchemaTableName tableName = view.getSchemaTableName();
String viewPath = getTablePath(tableName);
try {
if (curator.checkExists().forPath(viewPath) != null) {
throw new InvalidActivityException(format("Metadata for view %s already exists", tableName));
}
} catch (Exception e) {
throw new PrestoException(ZOOKEEPER_ERROR, "ZK error when checking if view already exists", e);
}
try {
curator.create().creatingParentsIfNeeded().forPath(viewPath, toJsonBytes(view));
} catch (Exception e) {
throw new PrestoException(ZOOKEEPER_ERROR, "Error creating view znode in ZooKeeper", e);
}
}
Aggregations