Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Support using prql as query language #863

Closed
waynexia opened this issue Jan 11, 2023 · 5 comments
Closed

Support using prql as query language #863

waynexia opened this issue Jan 11, 2023 · 5 comments
Labels
C-feature Category Features

Comments

@waynexia
Copy link
Member

What problem does the new feature solve?

Add a new query language support for prql https://prql-lang.org, which allows writing queries in pipeline-like style. I tried a few queries in the playground, one impressive example is querying "the top 10 cities average billing info among the latest 100 records". It needs a CTE first to get the latest 100 records, and then calculate their average. But this CTE is hidden in prql:

from invoices
sort [-invoice_date]
take 100
group [billing_city] (
  aggregate [
    avg = average total
  ]
)
sort [-_frame.avg]
take 10

Generated SQL:

WITH table_1 AS (
  SELECT
    billing_city,
    total
  FROM
    invoices
  LIMIT
    100
)
SELECT
  billing_city,
  AVG(total) AS avg
FROM
  table_1
GROUP BY
  billing_city
ORDER BY
  avg DESC
LIMIT
  10

It also provides some short-hand time/date/interval annotations, we could also benefit from it.

What does the feature do?

Support prql language. It would not have many things to do as it provides an embedded compiler library that can compile prql to SQL. We only need to touch the parser IMO.

Implementation challenges

No response

@waynexia waynexia added the C-feature Category Features label Jan 11, 2023
@WenyXu
Copy link
Member

WenyXu commented Feb 23, 2023

It seems to suit me, Can I take this?

@waynexia
Copy link
Member Author

It seems like suit for me, Can I take this?

Thanks for your enthusiasm ❤️ This feature is still under discussion, and we wonder if it suits GreptimeDB. You could also comment to tell what you think about it

@killme2008
Copy link
Contributor

This query language looks interesting. Maybe we can give it a shot in the Flow project. @discord9

@tisonkun
Copy link
Collaborator

One thing I'm afraid is that, as in #3557 -

Third-party DSL without a vast ecosystem might be short-lived. Flux itself is an example.

... whether it's even a good direction.

@tisonkun
Copy link
Collaborator

Move to Ideas until we have any concrete plan.

@GreptimeTeam GreptimeTeam locked and limited conversation to collaborators Apr 19, 2024
@tisonkun tisonkun converted this issue into discussion #3748 Apr 19, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
C-feature Category Features
Projects
None yet
Development

No branches or pull requests

4 participants