Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert SQL Lag query to Druid #13474

Closed
Jaytimbadia7 opened this issue Dec 1, 2022 · 8 comments
Closed

Convert SQL Lag query to Druid #13474

Jaytimbadia7 opened this issue Dec 1, 2022 · 8 comments
Labels

Comments

@Jaytimbadia7
Copy link

Hey Druid!

We have a query written in SQL which contains LAG function. We need that query in Druid SQL. Can you please lead us?

Example SQL query:

SELECT
  time_col,
  id,
  (time_col - lag (time_col, 1) over ( partition by id order by time_col)) as time_elapsed
FROM datatable

Can you please let us know its Druid conversion?

@Jaytimbadia7
Copy link
Author

Jaytimbadia7 commented Dec 1, 2022

Also, is Druid insertion of data from kafka in order or is it random insertion with no proper row ordering.
If that's the case, Lag/Lead functions won't be achievable, right?

https://groups.google.com/g/druid-user/c/5kbu34ONKTA @petermarshallio

@abhishekagarwal87
Copy link
Contributor

Druid doesn't support window functions yet. There is work in progress here #13458.

@Jaytimbadia7
Copy link
Author

That's good to hear. But is data ingestion to druid non-orderly.
Will Lag function work with development in work?

@Jaytimbadia7
Copy link
Author

Jaytimbadia7 commented Dec 1, 2022

Will this simple query work in druid?

Below is SQL query. Need Druid Equivalent.

SELECT
  (time_col - lag (time_col, 1)  as time_elapsed
FROM datatable

Will it support in future since data ingestion is non-orderly? Any suggestions?

@alvaro-ponce
Copy link

Hi!
I'm interested in this kind of queries too.
As I can see, the PR mentioned above is closed, but I can not easily find if this functionality is finally added in last Druid Version or if it will be added in the next one.

Can you @abhishekagarwal87 give us some information please?

Thank you

@abhishekagarwal87
Copy link
Contributor

It will be available in next release (26.0.0). If you want to try it out locally, you can download the source code from master branch and build a distribution locally. https://github.com/apache/druid/blob/master/docs/development/build.md

Copy link

This issue has been marked as stale due to 280 days of inactivity.
It will be closed in 4 weeks if no further activity occurs. If this issue is still
relevant, please simply write any comment. Even if closed, you can still revive the
issue at any time or discuss it on the dev@druid.apache.org list.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Jan 13, 2024
Copy link

This issue has been closed due to lack of activity. If you think that
is incorrect, or the issue requires additional review, you can revive the issue at
any time.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants