public boolean matches(QualifiedObjectName objectName) { return Objects.equals(catalogName, objectName.getCatalogName()) && schemaName.map(schema -> Objects.equals(schema, objectName.getSchemaName())).orElse(true) && tableName.map(table -> Objects.equals(table, objectName.getObjectName())).orElse(true); }
public boolean matches(QualifiedObjectName objectName) { return Objects.equals(catalogName, objectName.getCatalogName()) && schemaName.map(schema -> Objects.equals(schema, objectName.getSchemaName())).orElse(true) && tableName.map(table -> Objects.equals(table, objectName.getObjectName())).orElse(true); }
public ConnectorId getConnectorId(Session session, QualifiedObjectName table) { if (table.getSchemaName().equals(INFORMATION_SCHEMA_NAME)) { return informationSchemaId; } if (systemTables.getTableHandle(session.toConnectorSession(systemTablesId), table.asSchemaTableName()) != null) { return systemTablesId; } return connectorId; }
public ConnectorId getConnectorId(Session session, QualifiedObjectName table) { if (table.getSchemaName().equals(INFORMATION_SCHEMA_NAME)) { return informationSchemaId; } if (systemTables.getTableHandle(session.toConnectorSession(systemTablesId), table.asSchemaTableName()) != null) { return systemTablesId; } return connectorId; }
public static QualifiedName createQualifiedName(QualifiedObjectName name) { return QualifiedName.of(name.getCatalogName(), name.getSchemaName(), name.getObjectName()); }
private InternalTable buildViews(Session session, Set<QualifiedTablePrefix> prefixes) { InternalTable.Builder table = InternalTable.builder(informationSchemaTableColumns(TABLE_VIEWS)); for (QualifiedTablePrefix prefix : prefixes) { for (Entry<QualifiedObjectName, ViewDefinition> entry : metadata.getViews(session, prefix).entrySet()) { table.add( entry.getKey().getCatalogName(), entry.getKey().getSchemaName(), entry.getKey().getObjectName(), entry.getValue().getOriginalSql()); } } return table.build(); }
private InternalTable buildViews(Session session, Set<QualifiedTablePrefix> prefixes) { InternalTable.Builder table = InternalTable.builder(informationSchemaTableColumns(TABLE_VIEWS)); for (QualifiedTablePrefix prefix : prefixes) { for (Entry<QualifiedObjectName, ViewDefinition> entry : metadata.getViews(session, prefix).entrySet()) { table.add( entry.getKey().getCatalogName(), entry.getKey().getSchemaName(), entry.getKey().getObjectName(), entry.getValue().getOriginalSql()); } } return table.build(); }
List<Identifier> parts = node.getName().getOriginalParts(); Identifier tableName = parts.get(0); Identifier schemaName = (parts.size() > 1) ? parts.get(1) : new Identifier(objectName.getSchemaName()); Identifier catalogName = (parts.size() > 2) ? parts.get(2) : new Identifier(objectName.getCatalogName()); String sql = formatSql(new CreateView(QualifiedName.of(ImmutableList.of(catalogName, schemaName, tableName)), query, false, Optional.empty()), Optional.of(parameters)).trim(); QualifiedName.of(objectName.getCatalogName(), objectName.getSchemaName(), objectName.getObjectName()), columns, false,
private Map<ColumnHandle, NullableValue> asFixedValues(QualifiedObjectName objectName) { return ImmutableMap.of( CATALOG_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(objectName.getCatalogName())), SCHEMA_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(objectName.getSchemaName())), TABLE_NAME_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(objectName.getObjectName()))); }
private Map<ColumnHandle, NullableValue> asFixedValues(QualifiedObjectName objectName) { return ImmutableMap.of( CATALOG_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(objectName.getCatalogName())), SCHEMA_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(objectName.getSchemaName())), TABLE_NAME_COLUMN_HANDLE, new NullableValue(createUnboundedVarcharType(), utf8Slice(objectName.getObjectName()))); }
QualifiedName.of(objectName.getCatalogName(), objectName.getSchemaName(), objectName.getObjectName()), columns, false,
throw new SemanticException(MISSING_CATALOG, table, "Catalog %s does not exist", name.getCatalogName()); if (!metadata.schemaExists(session, new CatalogSchemaName(name.getCatalogName(), name.getSchemaName()))) { throw new SemanticException(MISSING_SCHEMA, table, "Schema %s does not exist", name.getSchemaName());
throw new SemanticException(MISSING_CATALOG, table, "Catalog %s does not exist", name.getCatalogName()); if (!metadata.schemaExists(session, new CatalogSchemaName(name.getCatalogName(), name.getSchemaName()))) { throw new SemanticException(MISSING_SCHEMA, table, "Schema %s does not exist", name.getSchemaName());
session.getRequiredTransactionId(), session.getIdentity(), new CatalogSchemaName(catalogName, qualifiedTableName.getSchemaName())); equal(identifier("table_schema"), new StringLiteral(qualifiedTableName.getSchemaName())), equal(identifier("table_name"), new StringLiteral(qualifiedTableName.getObjectName()))));
session.getRequiredTransactionId(), session.getIdentity(), new CatalogSchemaName(catalogName, qualifiedTableName.getSchemaName())); equal(identifier("table_schema"), new StringLiteral(qualifiedTableName.getSchemaName())), equal(identifier("table_name"), new StringLiteral(qualifiedTableName.getObjectName()))));
@Override protected Node visitShowColumns(ShowColumns showColumns, Void context) { QualifiedObjectName tableName = createQualifiedObjectName(session, showColumns, showColumns.getTable()); if (!metadata.getView(session, tableName).isPresent() && !metadata.getTableHandle(session, tableName).isPresent()) { throw new SemanticException(MISSING_TABLE, showColumns, "Table '%s' does not exist", tableName); } return simpleQuery( selectList( aliasedName("column_name", "Column"), aliasedName("data_type", "Type"), aliasedNullToEmpty("extra_info", "Extra"), aliasedNullToEmpty("comment", "Comment")), from(tableName.getCatalogName(), TABLE_COLUMNS), logicalAnd( equal(identifier("table_schema"), new StringLiteral(tableName.getSchemaName())), equal(identifier("table_name"), new StringLiteral(tableName.getObjectName()))), ordering(ascending("ordinal_position"))); }
@Override protected Node visitShowColumns(ShowColumns showColumns, Void context) { QualifiedObjectName tableName = createQualifiedObjectName(session, showColumns, showColumns.getTable()); if (!metadata.getView(session, tableName).isPresent() && !metadata.getTableHandle(session, tableName).isPresent()) { throw new SemanticException(MISSING_TABLE, showColumns, "Table '%s' does not exist", tableName); } return simpleQuery( selectList( aliasedName("column_name", "Column"), aliasedName("data_type", "Type"), aliasedNullToEmpty("extra_info", "Extra"), aliasedNullToEmpty("comment", "Comment")), from(tableName.getCatalogName(), TABLE_COLUMNS), logicalAnd( equal(identifier("table_schema"), new StringLiteral(tableName.getSchemaName())), equal(identifier("table_name"), new StringLiteral(tableName.getObjectName()))), ordering(ascending("ordinal_position"))); }