Search in sources :

Example 1 with FunctionLanguage

use of org.apache.flink.table.catalog.FunctionLanguage 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());
    }
}
Also used : CreateCatalogFunctionOperation(org.apache.flink.table.operations.ddl.CreateCatalogFunctionOperation) UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier) FunctionLanguage(org.apache.flink.table.catalog.FunctionLanguage) CatalogFunction(org.apache.flink.table.catalog.CatalogFunction) CreateTempSystemFunctionOperation(org.apache.flink.table.operations.ddl.CreateTempSystemFunctionOperation) CatalogFunctionImpl(org.apache.flink.table.catalog.CatalogFunctionImpl) ObjectIdentifier(org.apache.flink.table.catalog.ObjectIdentifier)

Example 2 with FunctionLanguage

use of org.apache.flink.table.catalog.FunctionLanguage 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());
}
Also used : ValidationException(org.apache.flink.table.api.ValidationException) AlterCatalogFunctionOperation(org.apache.flink.table.operations.ddl.AlterCatalogFunctionOperation) UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier) FunctionLanguage(org.apache.flink.table.catalog.FunctionLanguage) CatalogFunction(org.apache.flink.table.catalog.CatalogFunction) CatalogFunctionImpl(org.apache.flink.table.catalog.CatalogFunctionImpl) ObjectIdentifier(org.apache.flink.table.catalog.ObjectIdentifier)

Aggregations

CatalogFunction (org.apache.flink.table.catalog.CatalogFunction)2 CatalogFunctionImpl (org.apache.flink.table.catalog.CatalogFunctionImpl)2 FunctionLanguage (org.apache.flink.table.catalog.FunctionLanguage)2 ObjectIdentifier (org.apache.flink.table.catalog.ObjectIdentifier)2 UnresolvedIdentifier (org.apache.flink.table.catalog.UnresolvedIdentifier)2 ValidationException (org.apache.flink.table.api.ValidationException)1 AlterCatalogFunctionOperation (org.apache.flink.table.operations.ddl.AlterCatalogFunctionOperation)1 CreateCatalogFunctionOperation (org.apache.flink.table.operations.ddl.CreateCatalogFunctionOperation)1 CreateTempSystemFunctionOperation (org.apache.flink.table.operations.ddl.CreateTempSystemFunctionOperation)1