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 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 SystemTableHandle fromSchemaTableName(ConnectorId connectorId, SchemaTableName tableName) { requireNonNull(tableName, "tableName is null"); return new SystemTableHandle(connectorId, tableName.getSchemaName(), tableName.getTableName()); }
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); }
@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()); }
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 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()); }
@Override public synchronized Optional<List<String>> getAllViews(String databaseName) { ImmutableList.Builder<String> tables = ImmutableList.builder(); for (SchemaTableName schemaTableName : this.views.keySet()) { if (schemaTableName.getSchemaName().equals(databaseName)) { tables.add(schemaTableName.getTableName()); } } return Optional.of(tables.build()); }
@Override protected ConnectorTableHandle getTableHandle(ConnectorMetadata metadata, SchemaTableName tableName) { if (tableName.getTableName().startsWith(TEMPORARY_TABLE_PREFIX)) { return super.getTableHandle(metadata, tableName); } throw new SkipException("tests using existing tables are not supported"); }
private static HiveBasicStatistics getBasicStatisticsForPartition(Transaction transaction, SchemaTableName table, String partitionName) { return transaction .getMetastore(table.getSchemaName()) .getPartitionStatistics(table.getSchemaName(), table.getTableName(), ImmutableSet.of(partitionName)) .get(partitionName) .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); }
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(); }
@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; }