@Override public SqlCall createCall( SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... o) { assert functionQualifier == null; return new SqlCreateFunction(pos, (SqlIdentifier) o[0], o[1], o[2]); }
private void handleCreateFunction(SqlCreateFunction sqlCreateFunction) throws ClassNotFoundException { if(sqlCreateFunction.jarName() != null) { throw new UnsupportedOperationException("UDF 'USING JAR' not implemented"); } Method method; Function function; if ((method=findMethod(sqlCreateFunction.className(), "evaluate")) != null) { function = ScalarFunctionImpl.create(method); } else if (findMethod(sqlCreateFunction.className(), "add") != null) { function = AggregateFunctionImpl.create(Class.forName(sqlCreateFunction.className())); } else { throw new RuntimeException("Invalid scalar or aggregate function"); } schema.add(sqlCreateFunction.functionName().toUpperCase(), function); hasUdf = true; }
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { getOperator().unparse(writer, this, leftPrec, rightPrec); }
/** * CREATE FUNCTION functionname AS 'classname' */ final public SqlNode SqlCreateFunction() throws ParseException { SqlParserPos pos; SqlIdentifier functionName; SqlNode className; SqlNode jarName = null; jj_consume_token(CREATE); pos = getPos(); jj_consume_token(FUNCTION); functionName = CompoundIdentifier(); jj_consume_token(AS); className = StringLiteral(); if (jj_2_49(2)) { jj_consume_token(USING); jj_consume_token(JAR); jarName = StringLiteral(); } else { ; } {if (true) return new SqlCreateFunction(pos, functionName, className, jarName);} throw new Error("Missing return statement in function"); }
/** * CREATE FUNCTION functionname AS 'classname' */ final public SqlNode SqlCreateFunction() throws ParseException { SqlParserPos pos; SqlIdentifier functionName; SqlNode className; SqlNode jarName = null; jj_consume_token(CREATE); pos = getPos(); jj_consume_token(FUNCTION); functionName = CompoundIdentifier(); jj_consume_token(AS); className = StringLiteral(); if (jj_2_49(2)) { jj_consume_token(USING); jj_consume_token(JAR); jarName = StringLiteral(); } else { ; } {if (true) return new SqlCreateFunction(pos, functionName, className, jarName);} throw new Error("Missing return statement in function"); }