[ 
https://issues.apache.org/jira/browse/CALCITE-5376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jiajun Xie updated CALCITE-5376:
--------------------------------
    Description: 
Following on from the mailing list thread - 
[https://lists.apache.org/thread/3rk8zo5r38c6gpj7j0oy0453cxwlmnm7]

 

Spark has the following function definition for FIRST and LAST

[https://spark.apache.org/docs/3.0.1/api/sql/index.html#first]

[https://spark.apache.org/docs/3.0.1/api/sql/index.html#last] 

 

At the moment trying to use these functions with a query like 
{code:java}
select first(age) from customers{code}
gives an error along the lines of
{code:java}
Function 'FIRST(`customers`.`age`, 0)' can only be used in MATCH_RECOGNIZE{code}
 

In terms of testing, I can reproduce the error using BabelQuidemTest and 
setting up a case for spark.

 

Given that Spark’s first function is very similar to the FIRST_VALUE function, 
I think SqlFirstLastValueAggFunction is probably a useful starting point, but 
some pointers about where to look would be helpful. Particularly around 
potential parser changes.

 

Thanks in advance

  was:
# Following on from the mailing list thread - 
[https://lists.apache.org/thread/3rk8zo5r38c6gpj7j0oy0453cxwlmnm7]

 

Spark has the following function definition for FIRST and LAST

[https://spark.apache.org/docs/3.0.1/api/sql/index.html#first]

[https://spark.apache.org/docs/3.0.1/api/sql/index.html#last] 

 

At the moment trying to use these functions with a query like 
{code:java}
select first(age) from customers{code}
gives an error along the lines of
{code:java}
Function 'FIRST(`customers`.`age`, 0)' can only be used in MATCH_RECOGNIZE{code}
 

In terms of testing, I can reproduce the error using BabelQuidemTest and 
setting up a case for spark.

 

Given that Spark’s first function is very similar to the FIRST_VALUE function, 
I think SqlFirstLastValueAggFunction is probably a useful starting point, but 
some pointers about where to look would be helpful. Particularly around 
potential parser changes.

 

Thanks in advance


> Support Spark’s FIRST and LAST functions
> ----------------------------------------
>
>                 Key: CALCITE-5376
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5376
>             Project: Calcite
>          Issue Type: Task
>            Reporter: Sophie
>            Priority: Major
>
> Following on from the mailing list thread - 
> [https://lists.apache.org/thread/3rk8zo5r38c6gpj7j0oy0453cxwlmnm7]
>  
> Spark has the following function definition for FIRST and LAST
> [https://spark.apache.org/docs/3.0.1/api/sql/index.html#first]
> [https://spark.apache.org/docs/3.0.1/api/sql/index.html#last] 
>  
> At the moment trying to use these functions with a query like 
> {code:java}
> select first(age) from customers{code}
> gives an error along the lines of
> {code:java}
> Function 'FIRST(`customers`.`age`, 0)' can only be used in 
> MATCH_RECOGNIZE{code}
>  
> In terms of testing, I can reproduce the error using BabelQuidemTest and 
> setting up a case for spark.
>  
> Given that Spark’s first function is very similar to the FIRST_VALUE 
> function, I think SqlFirstLastValueAggFunction is probably a useful starting 
> point, but some pointers about where to look would be helpful. Particularly 
> around potential parser changes.
>  
> Thanks in advance



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to