@Override public List<String> listSchemaNames(ConnectorSession session) { Set<String> schemaNames = new HashSet<>(); for (SchemaTableName schemaTableName : tables.keySet()) { schemaNames.add(schemaTableName.getSchemaName()); } return ImmutableList.copyOf(schemaNames); }
@Override public List<SchemaTableName> listViews(ConnectorSession session, Optional<String> schemaName) { ImmutableList.Builder<SchemaTableName> builder = ImmutableList.builder(); for (SchemaTableName viewName : views.keySet()) { if (schemaName.map(viewName.getSchemaName()::equals).orElse(true)) { builder.add(viewName); } } return builder.build(); }
public Optional<Set<TablePrivilege>> match(String user, SchemaTableName table) { if (userRegex.map(regex -> regex.matcher(user).matches()).orElse(true) && schemaRegex.map(regex -> regex.matcher(table.getSchemaName()).matches()).orElse(true) && tableRegex.map(regex -> regex.matcher(table.getTableName()).matches()).orElse(true)) { return Optional.of(privileges); } return Optional.empty(); }
private static Object[] tableRow(String catalog, SchemaTableName name, String type) { return new Object[] {catalog, name.getSchemaName(), name.getTableName(), type, null, null, null, null, null, null}; } }
@Override public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { return tables.listSystemTables(session).stream() .map(SystemTable::getTableMetadata) .map(ConnectorTableMetadata::getTable) .filter(table -> schemaNameOrNull == null || table.getSchemaName().equals(schemaNameOrNull)) .collect(toImmutableList()); }
@Override public ExampleTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) { if (!listSchemaNames(session).contains(tableName.getSchemaName())) { return null; } ExampleTable table = exampleClient.getTable(tableName.getSchemaName(), tableName.getTableName()); if (table == null) { return null; } return new ExampleTableHandle(connectorId, tableName.getSchemaName(), tableName.getTableName()); }
@Override public ConnectorTableHandle getTableHandle(ConnectorSession connectorSession, SchemaTableName tableName) { if (!TABLES.containsKey(tableName)) { return null; } return new InformationSchemaTableHandle(catalogName, tableName.getSchemaName(), tableName.getTableName()); }
public void run(ExtendedHiveMetastore metastore) { if (partitionName.isPresent()) { metastore.updatePartitionStatistics(tableName.getSchemaName(), tableName.getTableName(), partitionName.get(), this::updateStatistics); } else { metastore.updateTableStatistics(tableName.getSchemaName(), tableName.getTableName(), this::updateStatistics); } done = true; }
public void undo(ExtendedHiveMetastore metastore) { if (!done) { return; } if (partitionName.isPresent()) { metastore.updatePartitionStatistics(tableName.getSchemaName(), tableName.getTableName(), partitionName.get(), this::resetStatistics); } else { metastore.updateTableStatistics(tableName.getSchemaName(), tableName.getTableName(), this::resetStatistics); } }
public static Function<SchemaTableName, QualifiedObjectName> convertFromSchemaTableName(String catalogName) { return input -> new QualifiedObjectName(catalogName, input.getSchemaName(), input.getTableName()); } }
private List<HiveColumnHandle> getPartitionColumns(SchemaTableName tableName) { Table sourceTable = metastore.getTable(tableName.getSchemaName(), tableName.getTableName()).get(); return getPartitionKeyColumnHandles(sourceTable); }
public synchronized void declareIntentionToWrite(ConnectorSession session, WriteMode writeMode, Path stagingPathRoot, String filePrefix, SchemaTableName schemaTableName) { setShared(); if (writeMode == WriteMode.DIRECT_TO_TARGET_EXISTING_DIRECTORY) { Map<List<String>, Action<PartitionAndMore>> partitionActionsOfTable = partitionActions.get(schemaTableName); if (partitionActionsOfTable != null && !partitionActionsOfTable.isEmpty()) { throw new PrestoException(NOT_SUPPORTED, "Can not insert into a table with a partition that has been modified in the same transaction when Presto is configured to skip temporary directories."); } } HdfsContext context = new HdfsContext(session, schemaTableName.getSchemaName(), schemaTableName.getTableName()); declaredIntentionsToWrite.add(new DeclaredIntentionToWrite(writeMode, context, stagingPathRoot, filePrefix, schemaTableName)); }
private Input createInput(TableMetadata table, Optional<TableLayoutHandle> layout, Set<Column> columns) { SchemaTableName schemaTable = table.getTable(); Optional<Object> inputMetadata = layout.flatMap(tableLayout -> metadata.getInfo(session, tableLayout)); return new Input(table.getConnectorId(), schemaTable.getSchemaName(), schemaTable.getTableName(), inputMetadata, ImmutableList.copyOf(columns)); }
@Override public void checkCanCreateTable(ConnectorTransactionHandle transaction, ConnectorIdentity identity, SchemaTableName tableName) { if (!isDatabaseOwner(identity, tableName.getSchemaName())) { denyCreateTable(tableName.toString()); } }
@Override public synchronized Optional<List<String>> getAllTables(String databaseName) { ImmutableList.Builder<String> tables = ImmutableList.builder(); for (SchemaTableName schemaTableName : this.relations.keySet()) { if (schemaTableName.getSchemaName().equals(databaseName)) { tables.add(schemaTableName.getTableName()); } } return Optional.of(tables.build()); }
@Override public synchronized Optional<List<String>> getAllTables(String databaseName) { ImmutableList.Builder<String> tables = ImmutableList.builder(); for (SchemaTableName schemaTableName : this.relations.keySet()) { if (schemaTableName.getSchemaName().equals(databaseName)) { tables.add(schemaTableName.getTableName()); } } return Optional.of(tables.build()); }
private static HiveBasicStatistics getBasicStatisticsForTable(Transaction transaction, SchemaTableName table) { return transaction .getMetastore(table.getSchemaName()) .getTableStatistics(table.getSchemaName(), table.getTableName()) .getBasicStatistics(); }
private static HiveBasicStatistics getBasicStatisticsForTable(Transaction transaction, SchemaTableName table) { return transaction .getMetastore(table.getSchemaName()) .getTableStatistics(table.getSchemaName(), table.getTableName()) .getBasicStatistics(); }
public static void insertIntoTableClusteringKeysInequality(CassandraSession session, SchemaTableName table, Date date, int rowsCount) { for (Integer rowNumber = 1; rowNumber <= rowsCount; rowNumber++) { Insert insert = QueryBuilder.insertInto(table.getSchemaName(), table.getTableName()) .value("key", "key_1") .value("clust_one", "clust_one") .value("clust_two", rowNumber) .value("clust_three", date.getTime() + rowNumber * 10); session.execute(insert); } assertEquals(session.execute("SELECT COUNT(*) FROM " + table).all().get(0).getLong(0), rowsCount); }
@Override public Void visitTableScan(TableScanNode node, IoPlanBuilder context) { TableMetadata tableMetadata = metadata.getTableMetadata(session, node.getTable()); context.addInputTableColumnInfo(new IoPlan.TableColumnInfo( new CatalogSchemaTableName( tableMetadata.getConnectorId().getCatalogName(), tableMetadata.getTable().getSchemaName(), tableMetadata.getTable().getTableName()), parseConstraints(node.getTable(), node.getCurrentConstraint()))); return null; }