phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Lomore (JIRA)" <>
Subject [jira] [Commented] (PHOENIX-3355) Register Phoenix built-in functions as Calcite functions
Date Wed, 02 Nov 2016 22:09:58 GMT


Eric Lomore commented on PHOENIX-3355:

[~maryannxue], I am running into a few more issues, would you mind taking a look? 

Functions with the expected constructor with parameter List.class now work as expected. But
those that do not cannot instantiate properly.

    private void constructUDFFunction() throws IOException {
            Constructor<?> constructor = clazz.getConstructor(List.class);
            udfFunction = (ScalarFunction)constructor.newInstance(this.children);
} {code}

For example, ToDateFunction stacktrace:
{code}Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: org.apache.phoenix.expression.function.ToDateFunction.<init>(java.util.List)
	at org.apache.phoenix.expression.function.UDFExpression.constructUDFFunction(
	at org.apache.phoenix.expression.function.UDFExpression.<init>(
	at org.apache.phoenix.calcite.CalciteUtils$19.newExpression(
	at org.apache.phoenix.calcite.CalciteUtils.convertChildren(
	at org.apache.phoenix.calcite.CalciteUtils.access$000(
	at org.apache.phoenix.calcite.CalciteUtils$3.newExpression(
	at org.apache.phoenix.calcite.CalciteUtils.toExpression(
	at org.apache.phoenix.calcite.rel.PhoenixTableScan.<init>(
	at org.apache.phoenix.calcite.rel.PhoenixTableScan.create(
	at org.apache.phoenix.calcite.rules.PhoenixFilterScanMergeRule.onMatch(
	at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(
	... 47 more
Caused by: java.lang.NoSuchMethodException: org.apache.phoenix.expression.function.ToDateFunction.<init>(java.util.List)
	at java.lang.Class.getConstructor0(
	at java.lang.Class.getConstructor(
	at org.apache.phoenix.expression.function.UDFExpression.constructUDFFunction(
	... 57 more

The only uniform way to instantiate on the phoenix side is through the parse node create function
(ex. ToDateParseNode.create()).

public FunctionExpression create(List<Expression> children, StatementContext context)
throws SQLException {
 // creates ExampleFunction
} {code}

We would still have to register PhoenixScalarFunction using the class name of a function,
but in constructUDFFunction() it would need to refer to the ParseNode. Unfortunately, I'm
a bit stuck on where to go from here. We would be using a parse node but not at parse time
which introduces some complications. See my latest commit here:
You'll notice StatementContext is null which cannot be the case, but I don't see a way around

> Register Phoenix built-in functions as Calcite functions
> --------------------------------------------------------
>                 Key: PHOENIX-3355
>                 URL:
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Assignee: Eric Lomore
>              Labels: calcite
>         Attachments: PHOENIX-3355.wip, PHOENIX-3355.wip2
> We should register all Phoenix built-in functions that don't exist in Calcite.

This message was sent by Atlassian JIRA

View raw message