apache phoenix udf无法在服务器端工作

kuarbcqp  于 2021-06-08  发布在  Hbase
关注(0)|答案(1)|浏览(549)

我已经用自定义的udf函数创建了jar,并将jar复制到dynamic.jar.dir中,所以当我使用我的udf函数作为 SELECT 我得到的结果没有问题。
但是当函数是 WHERE 子句i获取错误:找不到自定义函数的类。

select PK FROM "my.custom.view" where MY_FUN(ARRAY["COLF"."COL1"], 'SOMEPARAM')  limit 1;
Caused by: org.apache.hadoop.hbase.DoNotRetryIOException: BooleanExpressionFilter failed during reading: java.lang.ClassNotFoundException: com.myCompany.phoenix.MyCustomFunction
    at org.apache.phoenix.util.ServerUtil.createIOException(ServerUtil.java:96)
    at org.apache.phoenix.util.ServerUtil.throwIOException(ServerUtil.java:62)
    at org.apache.phoenix.filter.BooleanExpressionFilter.readFields(BooleanExpressionFilter.java:109)
    at org.apache.phoenix.filter.SingleKeyValueComparisonFilter.readFields(SingleKeyValueComparisonFilter.java:133)
    at org.apache.hadoop.hbase.util.Writables.getWritable(Writables.java:131)
    at org.apache.hadoop.hbase.util.Writables.getWritable(Writables.java:101)
    at org.apache.phoenix.filter.SingleCQKeyValueComparisonFilter.parseFrom(SingleCQKeyValueComparisonFilter.java:50)
    ... 16 more

基本站点.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://localhost:57000/user/hbase</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>localhost</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>21081</value>
    </property>

    <property>
        <name>hbase.client.keyvalue.maxsize</name>
        <value>0</value>
    </property>

    <!-- SEP is basically replication, so enable it -->
    <property>
        <name>hbase.replication</name>
        <value>true</value>
    </property>

    <property>
        <name>hbase.mapreduce.bulkload.max.hfiles.perRegion.perFamily</name>
        <value>128</value>
    </property>

    <property>
        <name>hbase.fs.tmp.dir</name>
        <value>/tmp/hbase</value>
    </property>

<property>
    <name>phoenix.functions.allowUserDefinedFunctions</name>
    <value>true</value>
  </property>
  <property>
    <name>hbase.dynamic.jars.dir</name>
    <value>${hbase.rootdir}/lib/</value>
  </property>

<property>
  <name>fs.hdfs.impl</name>
  <value>org.apache.hadoop.hdfs.DistributedFileSystem</value>
</property>

</configuration>

手动添加jar:

hdfs dfs -copyFromLocal -f /my.jar hdfs:///user/hbase/lib/my.jar

对于函数创建,使用:

CREATE FUNCTION MY_FUN(BINARY[], VARCHAR) RETURNS BOOLEAN as 'com.myCompany.phoenix.MyCustomFunction' using jar 'hdfs://localhost:57000/user/hbase/lib/my.jar';
k2arahey

k2arahey1#

当我从4.7升级到phoenix 5.0时,遇到了类似的情况。我遇到一个异常,指出由于权限问题,我现在需要将udf.jar放入/apps/hbase/data/lib。在旧环境中,我可以使用/apps/hbase/lib目录。也许这也发生在你身上,但它并没有提醒你新的道路改变。

相关问题