private SqlOperator toOp(SqlIdentifier name, final Function function) { return toOp(typeFactory, name, function); }
private SqlOperator toOp(SqlIdentifier name, final Function function) { return toOp(typeFactory, name, function); }
public void lookupOperatorOverloads(final SqlIdentifier opName, SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList) { if (syntax != SqlSyntax.FUNCTION) { return; } final Predicate<Function> predicate; if (category == null) { predicate = function -> true; } else if (category.isTableFunction()) { predicate = function -> function instanceof TableMacro || function instanceof TableFunction; } else { predicate = function -> !(function instanceof TableMacro || function instanceof TableFunction); } getFunctionsFrom(opName.names) .stream() .filter(predicate) .map(function -> toOp(opName, function)) .forEachOrdered(operatorList::add); }
public void lookupOperatorOverloads(final SqlIdentifier opName, SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList) { if (syntax != SqlSyntax.FUNCTION) { return; } final Predicate<Function> predicate; if (category == null) { predicate = function -> true; } else if (category.isTableFunction()) { predicate = function -> function instanceof TableMacro || function instanceof TableFunction; } else { predicate = function -> !(function instanceof TableMacro || function instanceof TableFunction); } getFunctionsFrom(opName.names) .stream() .filter(predicate) .map(function -> toOp(opName, function)) .forEachOrdered(operatorList::add); }
/** Creates an operator table that contains functions in the given class. * * @see ModelHandler#addFunctions */ public static SqlOperatorTable operatorTable(String className) { // Dummy schema to collect the functions final CalciteSchema schema = CalciteSchema.createRootSchema(false, false); ModelHandler.addFunctions(schema.plus(), null, ImmutableList.of(), className, "*", true); // The following is technical debt; see [CALCITE-2082] Remove // RelDataTypeFactory argument from SqlUserDefinedAggFunction constructor final SqlTypeFactoryImpl typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); final ListSqlOperatorTable table = new ListSqlOperatorTable(); for (String name : schema.getFunctionNames()) { for (Function function : schema.getFunctions(name, true)) { final SqlIdentifier id = new SqlIdentifier(name, SqlParserPos.ZERO); table.add( toOp(typeFactory, id, function)); } } return table; }
/** Creates an operator table that contains functions in the given class. * * @see ModelHandler#addFunctions */ public static SqlOperatorTable operatorTable(String className) { // Dummy schema to collect the functions final CalciteSchema schema = CalciteSchema.createRootSchema(false, false); ModelHandler.addFunctions(schema.plus(), null, ImmutableList.of(), className, "*", true); // The following is technical debt; see [CALCITE-2082] Remove // RelDataTypeFactory argument from SqlUserDefinedAggFunction constructor final SqlTypeFactoryImpl typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); final ListSqlOperatorTable table = new ListSqlOperatorTable(); for (String name : schema.getFunctionNames()) { for (Function function : schema.getFunctions(name, true)) { final SqlIdentifier id = new SqlIdentifier(name, SqlParserPos.ZERO); table.add( toOp(typeFactory, id, function)); } } return table; }