phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 方震(大数据&滴滴研究院) <>
Subject Exception when create an index with UDF but not using this UDF in select statement
Date Thu, 02 Jun 2016 06:59:29 GMT

One exception i have met but not sure if it is an issue. here are the steps
1. Create a function

     CREATE FUNCTION geohash_1(double, double) returns varchar as 'co.mac.test.GeoHashFunction'
using jar '/Users/mac/Downloads/phoenix-4.5.2-HBase-1.0/phoenix-plugins/target/phoenix-plugins-4.5.2-HBase-1.0.jar’;

1. Create a Geohash UDF and use this to create the index

     CREATE INDEX geohash_mac_test_3 ON MAC_TEST_3(geohash_1(lng, lat));

 > this is to make the index work when we query like select A from MAC_TEST_3 where GEOHASH_1(LNG,
LAT) = ‘wts22xxgfg';

2. Use the select statement without geohash UDF: select * from MAC_TEST_3 where A=‘aaa’

  Exception happen here:

  Error: ERROR 6001 (42F01): Function undefined. functionName=GEOHASH_1 (state=42F01,code=6001)
org.apache.phoenix.schema.FunctionNotFoundException: ERROR 6001 (42F01): Function undefined.
        at org.apache.phoenix.compile.FromCompiler$BaseColumnResolver.resolveFunction(
        at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(
        at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(
        at org.apache.phoenix.parse.FunctionParseNode.accept(
        at org.apache.phoenix.parse.IndexExpressionParseNodeRewriter.<init>(
        at org.apache.phoenix.optimize.QueryOptimizer.addPlan(
        at org.apache.phoenix.optimize.QueryOptimizer.getApplicablePlans(
        at org.apache.phoenix.optimize.QueryOptimizer.optimize(
        at org.apache.phoenix.optimize.QueryOptimizer.optimize(
        at org.apache.phoenix.jdbc.PhoenixStatement$
        at org.apache.phoenix.jdbc.PhoenixStatement$
        at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(
        at org.apache.phoenix.jdbc.PhoenixStatement.execute(
        at sqlline.Commands.execute(
        at sqlline.Commands.sql(
        at sqlline.SqlLine.dispatch(
        at sqlline.SqlLine.begin(
        at sqlline.SqlLine.start(
        at sqlline.SqlLine.main(

but if i use the UPPER function to create index, things work well. I did a simple DEBUG, and
find the difference is here

Somehow QueryPlan thinks the GEOHASH_1 is a UDFParseNode, but UPPER is a FunctionParseNode.
Is this because I manually call “CREATE FUNCTION” For the geohash_1?

    public Expression visitLeave(FunctionParseNode node, List<Expression> children)
throws SQLException {
        PFunction function = null;
        if(node instanceof UDFParseNode) {
            function = context.getResolver().resolveFunction(node.getName());
            BuiltInFunctionInfo info = new BuiltInFunctionInfo(function);
            node = new UDFParseNode(node.getName(), node.getChildren(), info);
        children = node.validate(children, context);
        Expression expression = null;
        if (function == null) {

Question is: is this a right behavior or what should I do if i want to make the geohash a

View raw message