[ 
https://issues.apache.org/jira/browse/PHOENIX-4866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16591405#comment-16591405
 ] 

cherish peng edited comment on PHOENIX-4866 at 8/24/18 11:57 AM:
-----------------------------------------------------------------

Below code alse throw the same error, but different lines:
{code:java}
SELECT ID,ORIGIN,ARRAY_DISTINCT(FIRST_VALUES(STEP, 10) WITHIN GROUP (ORDER BY 
EPOCH ASC),TRUE) STEPS FROM (SELECT EPOCH,LAST_VALUE (SID) WITHIN GROUP (ORDER 
BY EPOCH ASC) ID, LAST_VALUE (NAME) WITHIN GROUP ( ORDER BY EPOCH ASC) ORIGIN, 
LAST_VALUE (NAME) WITHIN GROUP (ORDER BY EPOCH ASC) STEP   FROM EVENTS_CESSIONS 
GROUP BY EPOCH ORDER BY ID) GROUP BY ID, ORIGIN;
throw: org.apache.phoenix.schema.FunctionNotFoundException: ERROR 6001 (42F01): 
Function undefined. functionName=ARRAY_DISTINCT at 
org.apache.phoenix.compile.FromCompiler$BaseColumnResolver.resolveFunction(FromCompiler.java:725)
 at 
org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:327)

{code}
If I replace the `ARRAY_DISTINCT(FIRST_VALUES(STEP, 10) WITHIN GROUP (ORDER BY 
EPOCH ASC),TRUE)` to ARRAY_ELEM(FIRST_VALUES(STEP, 10) WITHIN GROUP (ORDER BY 
EPOCH ASC), 0), it works! So, Phoenix's built-in Function is OK except custom 
Function.


was (Author: 1024bit):
Below code alse throw the same error, but different lines:

 
{code:java}
SELECT ID,ORIGIN,ARRAY_DISTINCT(FIRST_VALUES(STEP, 10) WITHIN GROUP (ORDER BY 
EPOCH ASC),TRUE) STEPS FROM (SELECT EPOCH,LAST_VALUE (SID) WITHIN GROUP (ORDER 
BY EPOCH ASC) ID, LAST_VALUE (NAME) WITHIN GROUP ( ORDER BY EPOCH ASC) ORIGIN, 
LAST_VALUE (NAME) WITHIN GROUP (ORDER BY EPOCH ASC) STEP   FROM EVENTS_CESSIONS 
GROUP BY EPOCH ORDER BY ID) GROUP BY ID, ORIGIN;
throw: org.apache.phoenix.schema.FunctionNotFoundException: ERROR 6001 (42F01): 
Function undefined. functionName=ARRAY_DISTINCT at 
org.apache.phoenix.compile.FromCompiler$BaseColumnResolver.resolveFunction(FromCompiler.java:725)
 at 
org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:327)
{code}

> UDFs get error: org.apache.phoenix.schema.FunctionNotFoundException: ERROR 
> 6001 (42F01): Function undefined
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-4866
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4866
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 5.0.0
>         Environment: [^ArrayDistinctFunction.java]
>            Reporter: cherish peng
>            Priority: Blocker
>              Labels: User-Defined-Function, functions, udfs
>         Attachments: ArrayDistinctFunction.java
>
>   Original Estimate: 72h
>  Remaining Estimate: 72h
>
>  
> {code:java}
> Environment: 
> apache-phoenix-5.0.0-HBase-2.0-bin 
> hbase-2.0.0
> hadoop-3.1.0
> {code}
> I built an udf `ARRAY_DISTINCT`, When i exec:
> {color:#d04437}①{color} SELECT ARRAY_DISTINCT(ARRAY['A', 'B', 'A', 'C'], 
> TRUE);
> throw error: "org.apache.phoenix.schema.FunctionNotFoundException: ERROR 6001 
> (42F01): Function undefined"
> However when i exec:
> {color:#d04437}②{color} SELECT ARRAY_DISTINCT(ARRAY['A', 'B', 'A', 'C'], 
> TRUE) {color:#f79232}FROM TABLE_NAME;{color}
> output:
> *+---------------------+*
> *|* *ARRAY['A','B','C']* *|*
> *+---------------------+*
> *+---------------------+*
>  
> {color:#d04437}③{color} SELECT 
> ARRAY_DISTINCT({color:#f79232}array_elements{color}, TRUE) as arr 
> {color:#f79232}FROM TABLE_NAME;{color}**
> {color:#f79232}output:{color}
> *+---------------------+*
> *| ARR*  **  *|*
> *+---------------------+*
> *| ARRAY['A','B','C'] |***
> *+---------------------+*
>  
>  My ddl: 
> CREATE FUNCTION ARRAY_DISTINCT(VARCHAR[], BOOLEAN) RETURNS VARCHAR AS 
> 'com.godalgo.udf.ArrayDistinctFunction';
> *I tried the built-in functions which provided by Phoenix, they only output ③ 
> .*
> *I put the  ARRAY_DISTINCT SOURCE TO attachment.*



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to