use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class SqlToOperationConverter method convertCreateView.
/**
* Convert CREATE VIEW statement.
*/
private Operation convertCreateView(SqlCreateView sqlCreateView) {
final SqlNode query = sqlCreateView.getQuery();
final SqlNodeList fieldList = sqlCreateView.getFieldList();
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlCreateView.fullViewName());
ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
String comment = sqlCreateView.getComment().map(c -> c.getNlsString().getValue()).orElse(null);
CatalogView catalogView = convertViewQuery(query, fieldList.getList(), OperationConverterUtils.extractProperties(sqlCreateView.getProperties().orElse(null)), comment);
return new CreateViewOperation(identifier, catalogView, sqlCreateView.isIfNotExists(), sqlCreateView.isTemporary());
}
use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class SqlToOperationConverter method convertDescribeTable.
/**
* Convert DESCRIBE [EXTENDED] [[catalogName.] dataBasesName].sqlIdentifier.
*/
private Operation convertDescribeTable(SqlRichDescribeTable sqlRichDescribeTable) {
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlRichDescribeTable.fullTableName());
ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
return new DescribeTableOperation(identifier, sqlRichDescribeTable.isExtended());
}
use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class SqlToOperationConverter method convertShowColumns.
/**
* Convert SHOW COLUMNS statement.
*/
private Operation convertShowColumns(SqlShowColumns sqlShowColumns) {
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlShowColumns.fullTableName());
ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
return new ShowColumnsOperation(identifier, sqlShowColumns.getLikeSqlPattern(), sqlShowColumns.isWithLike(), sqlShowColumns.isNotLike(), sqlShowColumns.getPreposition());
}
use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class SqlCreateTableConverter method convertCreateTable.
/**
* Convert the {@link SqlCreateTable} node.
*/
Operation convertCreateTable(SqlCreateTable sqlCreateTable) {
sqlCreateTable.getTableConstraints().forEach(validateTableConstraint);
CatalogTable catalogTable = createCatalogTable(sqlCreateTable);
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlCreateTable.fullTableName());
ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
return new CreateTableOperation(identifier, catalogTable, sqlCreateTable.isIfNotExists(), sqlCreateTable.isTemporary());
}
use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class AbstractStreamTableEnvironmentImpl method fromStreamInternal.
protected <T> Table fromStreamInternal(DataStream<T> dataStream, @Nullable Schema schema, @Nullable String viewPath, ChangelogMode changelogMode) {
Preconditions.checkNotNull(dataStream, "Data stream must not be null.");
Preconditions.checkNotNull(changelogMode, "Changelog mode must not be null.");
if (dataStream.getExecutionEnvironment() != executionEnvironment) {
throw new ValidationException("The DataStream's StreamExecutionEnvironment must be identical to the one that " + "has been passed to the StreamTableEnvironment during instantiation.");
}
final CatalogManager catalogManager = getCatalogManager();
final OperationTreeBuilder operationTreeBuilder = getOperationTreeBuilder();
final SchemaTranslator.ConsumingResult schemaTranslationResult = SchemaTranslator.createConsumingResult(catalogManager.getDataTypeFactory(), dataStream.getType(), schema);
final ResolvedCatalogTable resolvedCatalogTable = catalogManager.resolveCatalogTable(new ExternalCatalogTable(schemaTranslationResult.getSchema()));
final ContextResolvedTable contextResolvedTable;
if (viewPath != null) {
UnresolvedIdentifier unresolvedIdentifier = getParser().parseIdentifier(viewPath);
final ObjectIdentifier objectIdentifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
contextResolvedTable = ContextResolvedTable.temporary(objectIdentifier, resolvedCatalogTable);
} else {
contextResolvedTable = ContextResolvedTable.anonymous("datastream_source", resolvedCatalogTable);
}
final QueryOperation scanOperation = new ExternalQueryOperation<>(contextResolvedTable, dataStream, schemaTranslationResult.getPhysicalDataType(), schemaTranslationResult.isTopLevelRecord(), changelogMode);
final List<String> projections = schemaTranslationResult.getProjections();
if (projections == null) {
return createTable(scanOperation);
}
final QueryOperation projectOperation = operationTreeBuilder.project(projections.stream().map(ApiExpressionUtils::unresolvedRef).collect(Collectors.toList()), scanOperation);
return createTable(projectOperation);
}
Aggregations