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

Julian Hyde commented on CALCITE-5376:
--------------------------------------

That sounds about right.

I don't think any parser changes are required. If so, the best place to test 
this would be {{SqlOperatorTest}}. (For comparison, note that the {{CHR}} 
function, which is only available in the Oracle library, is tested in 
{{SqlOperatorTest.testChr}}.)

You should also have a validator test. You need to check that a query that 
contains {{FIRST}} and is in the Spark library is an aggregate query. (Call 
{{SqlValidatorFixture.isAggregate}}.)

> 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