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

Till commented on ASTERIXDB-1606:
---------------------------------

I'm not too enthusiastic to add new syntax, that's just me :)
 
If we do it, a good way to go about it is to introduce it as a "syntactical 
sugar", .i.e. we provide a precise translation from the new syntax to the 
existing syntax and ensure that the new syntax works as expected in all 
contexts that the existing syntax works. So if you'd like to introduce this, 
I'd propose to create a small writeup that explains the sugar and to discuss it 
on the dev list.

As for the implementation, I think that it should do precisely what the sugar 
says -  which is to translate the new syntax to the existing syntax and then 
apply all optimizations on the normalized algebraic representation of the 
query. I think that there should be no knowledge of the use of the sugar in the 
operator-tree, as it would be bad if there we different ways to express the 
same semantics in the query language but only one way would be optimized 
correctly.

Does this make sense?

> Optimize "last value" query
> ---------------------------
>
>                 Key: ASTERIXDB-1606
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1606
>             Project: Apache AsterixDB
>          Issue Type: Bug
>            Reporter: Steven Jacobs
>            Priority: Minor
>
> We need to work on optimizing queries looking for a "most recent" or 
> "greatest" value of a given field. 
> As an example, consider an append-only dataset filled with user locations 
> over time, and suppose we want to know the user's last known location. 
> Currently, we would need to do this as an:
> order by $record.timeStamp
> limit 1
> We could improve this in two ways:
> 1) Improve usability by providing an alias syntax for users, e.g. "where 
> greatest timeStamp"
> 2) Improve the compilation of such a job to only retrieve a single record.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to