Search in sources :

Example 1 with SqlSyntax

use of org.apache.calcite.sql.SqlSyntax in project flink by apache.

the class FunctionCatalogOperatorTable method lookupOperatorOverloads.

@Override
public void lookupOperatorOverloads(SqlIdentifier opName, SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList, SqlNameMatcher nameMatcher) {
    if (opName.isStar()) {
        return;
    }
    final UnresolvedIdentifier identifier = UnresolvedIdentifier.of(opName.names);
    functionCatalog.lookupFunction(identifier).flatMap(resolvedFunction -> convertToSqlFunction(category, resolvedFunction)).ifPresent(operatorList::add);
}
Also used : DataTypeFactory(org.apache.flink.table.catalog.DataTypeFactory) TypeInference(org.apache.flink.table.types.inference.TypeInference) SqlSyntax(org.apache.calcite.sql.SqlSyntax) DeferredTypeFlinkTableFunction(org.apache.flink.table.planner.plan.schema.DeferredTypeFlinkTableFunction) DataType(org.apache.flink.table.types.DataType) UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier) BuiltInFunctionDefinition(org.apache.flink.table.functions.BuiltInFunctionDefinition) AggregateFunctionDefinition(org.apache.flink.table.functions.AggregateFunctionDefinition) FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) FlinkTypeFactory(org.apache.flink.table.planner.calcite.FlinkTypeFactory) SqlNameMatcher(org.apache.calcite.sql.validate.SqlNameMatcher) SqlIdentifier(org.apache.calcite.sql.SqlIdentifier) TypeConversions.fromLegacyInfoToDataType(org.apache.flink.table.types.utils.TypeConversions.fromLegacyInfoToDataType) SqlOperator(org.apache.calcite.sql.SqlOperator) FunctionKind(org.apache.flink.table.functions.FunctionKind) Nullable(javax.annotation.Nullable) TypeStrategies(org.apache.flink.table.types.inference.TypeStrategies) SqlKind(org.apache.calcite.sql.SqlKind) TableFunctionDefinition(org.apache.flink.table.functions.TableFunctionDefinition) ScalarFunctionDefinition(org.apache.flink.table.functions.ScalarFunctionDefinition) GenericTypeInfo(org.apache.flink.api.java.typeutils.GenericTypeInfo) FunctionDefinition(org.apache.flink.table.functions.FunctionDefinition) SqlOperatorTable(org.apache.calcite.sql.SqlOperatorTable) SqlFunctionCategory(org.apache.calcite.sql.SqlFunctionCategory) ContextResolvedFunction(org.apache.flink.table.catalog.ContextResolvedFunction) HiveAggSqlFunction(org.apache.flink.table.planner.functions.utils.HiveAggSqlFunction) List(java.util.List) SqlFunction(org.apache.calcite.sql.SqlFunction) BridgingSqlAggFunction(org.apache.flink.table.planner.functions.bridging.BridgingSqlAggFunction) BridgingSqlFunction(org.apache.flink.table.planner.functions.bridging.BridgingSqlFunction) ValidationException(org.apache.flink.table.api.ValidationException) Optional(java.util.Optional) HiveFunctionUtils.isHiveFunc(org.apache.flink.table.planner.functions.utils.HiveFunctionUtils.isHiveFunc) Internal(org.apache.flink.annotation.Internal) HiveTableSqlFunction(org.apache.flink.table.planner.functions.utils.HiveTableSqlFunction) UserDefinedFunctionUtils(org.apache.flink.table.planner.functions.utils.UserDefinedFunctionUtils) FunctionIdentifier(org.apache.flink.table.functions.FunctionIdentifier) TypeConversions(org.apache.flink.table.types.utils.TypeConversions) Row(org.apache.flink.types.Row) UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier)

Example 2 with SqlSyntax

use of org.apache.calcite.sql.SqlSyntax in project hazelcast by hazelcast.

the class HazelcastSqlOperatorTableTest method testNoOverride.

/**
 * Make sure there are no overrides for operators defined in the operator table.
 */
@Test
public void testNoOverride() {
    Map<BiTuple<String, SqlSyntax>, SqlOperator> map = new HashMap<>();
    for (SqlOperator operator : HazelcastSqlOperatorTable.instance().getOperatorList()) {
        BiTuple<String, SqlSyntax> key = BiTuple.of(operator.getName(), operator.getSyntax());
        SqlOperator oldOperator = map.put(key, operator);
        assertNull("Duplicate operator \"" + operator.getName(), oldOperator);
    }
}
Also used : HashMap(java.util.HashMap) SqlSyntax(org.apache.calcite.sql.SqlSyntax) SqlOperator(org.apache.calcite.sql.SqlOperator) BiTuple(com.hazelcast.internal.util.BiTuple) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

SqlOperator (org.apache.calcite.sql.SqlOperator)2 SqlSyntax (org.apache.calcite.sql.SqlSyntax)2 BiTuple (com.hazelcast.internal.util.BiTuple)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Optional (java.util.Optional)1 Nullable (javax.annotation.Nullable)1 SqlFunction (org.apache.calcite.sql.SqlFunction)1 SqlFunctionCategory (org.apache.calcite.sql.SqlFunctionCategory)1 SqlIdentifier (org.apache.calcite.sql.SqlIdentifier)1 SqlKind (org.apache.calcite.sql.SqlKind)1 SqlOperatorTable (org.apache.calcite.sql.SqlOperatorTable)1 SqlNameMatcher (org.apache.calcite.sql.validate.SqlNameMatcher)1 Internal (org.apache.flink.annotation.Internal)1 GenericTypeInfo (org.apache.flink.api.java.typeutils.GenericTypeInfo)1 ValidationException (org.apache.flink.table.api.ValidationException)1 ContextResolvedFunction (org.apache.flink.table.catalog.ContextResolvedFunction)1 DataTypeFactory (org.apache.flink.table.catalog.DataTypeFactory)1