Refine search
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}; } }
public boolean matches(SchemaTableName schemaTableName) { // null schema name matches everything if (schemaName == null) { return true; } if (!schemaName.equals(schemaTableName.getSchemaName())) { return false; } return tableName == null || tableName.equals(schemaTableName.getTableName()); }
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(); }
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 static SystemTableHandle fromSchemaTableName(ConnectorId connectorId, SchemaTableName tableName) { requireNonNull(tableName, "tableName is null"); return new SystemTableHandle(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()); }
private void prepareDropPartition(SchemaTableName schemaTableName, List<String> partitionValues) { metastoreDeleteOperations.add(new IrreversibleMetastoreOperation( format("drop partition %s.%s %s", schemaTableName.getSchemaName(), schemaTableName.getTableName(), partitionValues), () -> delegate.dropPartition(schemaTableName.getSchemaName(), schemaTableName.getTableName(), partitionValues, true))); }
public static SchemaTableName getSourceTableNameForPartitionsTable(SchemaTableName tableName) { checkArgument(isPartitionsSystemTable(tableName), "not a partitions table name"); return new SchemaTableName( tableName.getSchemaName(), tableName.getTableName().substring(0, tableName.getTableName().length() - PARTITIONS_TABLE_SUFFIX.length())); } }
@JsonIgnore public static String getFullTableName(SchemaTableName tableName) { return getFullTableName(tableName.getSchemaName(), tableName.getTableName()); }
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 boolean checkTablePermission(ConnectorTransactionHandle transaction, Identity identity, SchemaTableName tableName, HivePrivilege... requiredPrivileges) { if (INFORMATION_SCHEMA_NAME.equals(tableName.getSchemaName())) { return true; } SemiTransactionalHiveMetastore metastore = metastoreProvider.apply(((HiveTransactionHandle) transaction)); Set<HivePrivilege> privilegeSet = metastore.getTablePrivileges(identity.getUser(), tableName.getSchemaName(), tableName.getTableName()).stream() .map(HivePrivilegeInfo::getHivePrivilege) .collect(Collectors.toSet()); return privilegeSet.containsAll(ImmutableSet.copyOf(requiredPrivileges)); }
@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()); }
private void prepareDropTable(SchemaTableName schemaTableName) { metastoreDeleteOperations.add(new IrreversibleMetastoreOperation( format("drop table %s", schemaTableName), () -> delegate.dropTable(schemaTableName.getSchemaName(), schemaTableName.getTableName(), true))); }
private List<HiveColumnHandle> getPartitionColumns(SchemaTableName tableName) { Table sourceTable = metastore.getTable(tableName.getSchemaName(), tableName.getTableName()).get(); return getPartitionKeyColumnHandles(sourceTable); }
public void createView(SchemaTableName viewName, String viewData) { if (getSchemaNames().contains(viewName.getSchemaName())) { if (getViewNames(viewName.getSchemaName()).contains(viewName.getTableName())) { throw new PrestoException(ALREADY_EXISTS, "View already exists"); } if (getTableNames(viewName.getSchemaName()).contains(viewName.getTableName())) { throw new PrestoException(INVALID_VIEW, "View already exists as data table"); } } metaManager.createViewMetadata(new AccumuloView(viewName.getSchemaName(), viewName.getTableName(), viewData)); }
@Override public void grantTablePrivileges(ConnectorSession session, SchemaTableName schemaTableName, Set<Privilege> privileges, String grantee, boolean grantOption) { String schemaName = schemaTableName.getSchemaName(); String tableName = schemaTableName.getTableName(); Set<HivePrivilegeInfo> hivePrivilegeInfos = privileges.stream() .map(privilege -> new HivePrivilegeInfo(toHivePrivilege(privilege), grantOption)) .collect(toSet()); metastore.grantTablePrivileges(schemaName, tableName, grantee, hivePrivilegeInfos); }
@Override public void revokeTablePrivileges(ConnectorSession session, SchemaTableName schemaTableName, Set<Privilege> privileges, String grantee, boolean grantOption) { String schemaName = schemaTableName.getSchemaName(); String tableName = schemaTableName.getTableName(); Set<HivePrivilegeInfo> hivePrivilegeInfos = privileges.stream() .map(privilege -> new HivePrivilegeInfo(toHivePrivilege(privilege), grantOption)) .collect(toSet()); metastore.revokeTablePrivileges(schemaName, tableName, grantee, hivePrivilegeInfos); }
public boolean isMaterializedView(SchemaTableName schemaTableName) { KeyspaceMetadata keyspace = getKeyspaceByCaseInsensitiveName(schemaTableName.getSchemaName()); return keyspace.getMaterializedView(schemaTableName.getTableName()) != null; }
private Optional<ConnectorTableMetadata> getTableMetadata(SchemaTableName tableName) { ElasticsearchTableDescription table = client.getTable(tableName.getSchemaName(), tableName.getTableName()); if (table == null) { return Optional.empty(); } return Optional.of(new ConnectorTableMetadata(tableName, client.getColumnMetadata(table))); }