use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class TableEnvironmentImpl method registerTable.
@Override
public void registerTable(String name, Table table) {
UnresolvedIdentifier identifier = UnresolvedIdentifier.of(name);
createTemporaryView(identifier, table);
}
use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class SqlToOperationConverter method convertCreateFunction.
/**
* Convert CREATE FUNCTION statement.
*/
private Operation convertCreateFunction(SqlCreateFunction sqlCreateFunction) {
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlCreateFunction.getFunctionIdentifier());
if (sqlCreateFunction.isSystemFunction()) {
return new CreateTempSystemFunctionOperation(unresolvedIdentifier.getObjectName(), sqlCreateFunction.getFunctionClassName().getValueAs(String.class), sqlCreateFunction.isIfNotExists(), parseLanguage(sqlCreateFunction.getFunctionLanguage()));
} else {
FunctionLanguage language = parseLanguage(sqlCreateFunction.getFunctionLanguage());
CatalogFunction catalogFunction = new CatalogFunctionImpl(sqlCreateFunction.getFunctionClassName().getValueAs(String.class), language);
ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
return new CreateCatalogFunctionOperation(identifier, catalogFunction, sqlCreateFunction.isIfNotExists(), sqlCreateFunction.isTemporary());
}
}
use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class SqlToOperationConverter method convertAlterFunction.
/**
* Convert ALTER FUNCTION statement.
*/
private Operation convertAlterFunction(SqlAlterFunction sqlAlterFunction) {
if (sqlAlterFunction.isSystemFunction()) {
throw new ValidationException("Alter temporary system function is not supported");
}
FunctionLanguage language = parseLanguage(sqlAlterFunction.getFunctionLanguage());
CatalogFunction catalogFunction = new CatalogFunctionImpl(sqlAlterFunction.getFunctionClassName().getValueAs(String.class), language);
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlAlterFunction.getFunctionIdentifier());
ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
return new AlterCatalogFunctionOperation(identifier, catalogFunction, sqlAlterFunction.isIfExists(), sqlAlterFunction.isTemporary());
}
use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class SqlToOperationConverter method convertAlterView.
/**
* convert ALTER VIEW statement.
*/
private Operation convertAlterView(SqlAlterView alterView) {
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(alterView.fullViewName());
ObjectIdentifier viewIdentifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
Optional<ContextResolvedTable> optionalCatalogTable = catalogManager.getTable(viewIdentifier);
if (!optionalCatalogTable.isPresent() || optionalCatalogTable.get().isTemporary()) {
throw new ValidationException(String.format("View %s doesn't exist or is a temporary view.", viewIdentifier.toString()));
}
CatalogBaseTable baseTable = optionalCatalogTable.get().getTable();
if (baseTable instanceof CatalogTable) {
throw new ValidationException("ALTER VIEW for a table is not allowed");
}
if (alterView instanceof SqlAlterViewRename) {
UnresolvedIdentifier newUnresolvedIdentifier = UnresolvedIdentifier.of(((SqlAlterViewRename) alterView).fullNewViewName());
ObjectIdentifier newTableIdentifier = catalogManager.qualifyIdentifier(newUnresolvedIdentifier);
return new AlterViewRenameOperation(viewIdentifier, newTableIdentifier);
} else if (alterView instanceof SqlAlterViewProperties) {
SqlAlterViewProperties alterViewProperties = (SqlAlterViewProperties) alterView;
CatalogView oldView = (CatalogView) baseTable;
Map<String, String> newProperties = new HashMap<>(oldView.getOptions());
newProperties.putAll(OperationConverterUtils.extractProperties(alterViewProperties.getPropertyList()));
CatalogView newView = new CatalogViewImpl(oldView.getOriginalQuery(), oldView.getExpandedQuery(), oldView.getSchema(), newProperties, oldView.getComment());
return new AlterViewPropertiesOperation(viewIdentifier, newView);
} else if (alterView instanceof SqlAlterViewAs) {
SqlAlterViewAs alterViewAs = (SqlAlterViewAs) alterView;
final SqlNode newQuery = alterViewAs.getNewQuery();
CatalogView oldView = (CatalogView) baseTable;
CatalogView newView = convertViewQuery(newQuery, Collections.emptyList(), oldView.getOptions(), oldView.getComment());
return new AlterViewAsOperation(viewIdentifier, newView);
} else {
throw new ValidationException(String.format("[%s] needs to implement", alterView.toSqlString(CalciteSqlDialect.DEFAULT)));
}
}
use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.
the class SqlToOperationConverter method convertShowCreateTable.
/**
* Convert SHOW CREATE TABLE statement.
*/
private Operation convertShowCreateTable(SqlShowCreateTable sqlShowCreateTable) {
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlShowCreateTable.getFullTableName());
ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
return new ShowCreateTableOperation(identifier);
}
Aggregations