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

Expressions: Sql expressions with Duckdb #81666

Merged
merged 73 commits into from Feb 27, 2024
Merged

Conversation

scottlepp
Copy link
Contributor

@scottlepp scottlepp commented Jan 31, 2024

What is this feature?

This is a subset of the Optimus Duck hackathon. Which won the bronze in the Dec 2023 Hackathon.

This adds a SQL type to Expressions allowing the execution of SQL referencing queries on the panel. This provides powerful transformations, chaining SQL (think SQL Notebooks), analytics and aggregate functions from DuckDB, and provides the ability to transform data in Alerting, something that isn't possible with front end Transformations but is highly sought after.

Why do we need this feature?

Who is this feature for?

  • Anyone interested in using Transformations.
  • Users who prefer a standard query language (SQL) over using Front End Transformations.
  • Anyone who wants more powerful Alerting.

Population by State (gdev CSV file example)
image

Summarized Population for 2020 using SQL Expression
image

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

Fixes https://github.com/orgs/grafana/projects/55/views/19?pane=issue&itemId=51638046

@scottlepp scottlepp marked this pull request as ready for review January 31, 2024 20:46
@scottlepp scottlepp requested review from a team as code owners January 31, 2024 20:46
@scottlepp scottlepp requested review from gillesdemey, konrad147, soniaAguilarPeiron, suntala, idafurjes and yangkb09 and removed request for a team January 31, 2024 20:46
@scottlepp scottlepp requested a review from a team as a code owner February 26, 2024 22:48
@scottlepp
Copy link
Contributor Author

scottlepp commented Feb 26, 2024

@kylebrandt added the changes we discussed ( and fixed the issue you noticed ).

Can you check/review this again please? NOTE: you will need to have the duckdb cli installed now and in your path.

Copy link
Member

@ryantxu ryantxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great -- very nice compromise that lets us make progress without exploding the build size for everyone. Given the feature toggle and limited dependency issues, i think it is safe to merge and improve some of the ergonomics in follup PRs -- most important is error handling and explanations

go.mod Outdated Show resolved Hide resolved
Copy link
Contributor

@kylebrandt kylebrandt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make it more interoperable by laying over dataplane in another pass:

  • Add QueryType Dropdown (Table/TimeSeries/Numeric) in UI
  • Introduce two SSE types that mirror dataplane types, TimeSeriesLong and NumericLong
  • Use those types respectively when TimeSeries or Numeric or selected
  • (At this point, the output should work with Record queries for example)
  • Update SSE operators to be able to read the Long Types (could be shim grafana/dataplane/sdata should make this relatively easy)

@scottlepp scottlepp merged commit 7000920 into main Feb 27, 2024
19 checks passed
@scottlepp scottlepp deleted the sql-expressions-with-duckdb branch February 27, 2024 21:16
ryantxu added a commit that referenced this pull request Feb 27, 2024
duckdb temp storage of dataframes using parquet and querying from sql expressions
---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/backend area/frontend type/ci Tasks related to Continuous Integration workflow type/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants