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

fix: Ad-Hoc filters not applied because variables are not recognized by the AST parser #733

Merged
merged 5 commits into from
Mar 1, 2024

Conversation

SpencerTorres
Copy link
Collaborator

Fixes #714

Changes:

  • Fixed the AST from not recognizing variables such as ${var} ${var.key} and ${var:singlequote}. This was causing Ad-Hoc filters to not be applied, and prevented switching back to the Query Builder.
  • Switching from SQL Editor back to Query Builder works again. This worked before, but was also broken when using variables. Also it would open an empty query, but now the AST is able to recognize the v4 builder options a little better.
  • Fixed an issue where an empty database name would put FROM "undefined"."table"
  • Multi filters (such as ones using WHERE .. IN) now allows for spaces. v3 allowed for a,b,c or a, b, c, v4 had just the first one but now it supports both. You can also include expressions and it works nicely, for example: a, b, toString('c')
  • Added new unit tests that specifically focus the AST when using macros and variables.
  • Re-added some tests for the AST + SQL generator. These were removed before because the SQL generator was separated from the utils module, but I've added it back. The original intent of these tests seems to be testing consistency when converting sql->builderOptions->sql.
  • updated changelog

@asimpson asimpson enabled auto-merge (squash) February 29, 2024 16:45
asimpson
asimpson previously approved these changes Feb 29, 2024
Copy link
Contributor

@asimpson asimpson left a comment

Choose a reason for hiding this comment

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

Seems to work well, thanks! 🏆

auto-merge was automatically disabled February 29, 2024 20:53

Head branch was pushed to by a user without write access

@mshustov mshustov requested a review from asimpson March 1, 2024 09:09
@asimpson asimpson enabled auto-merge (squash) March 1, 2024 18:07
@asimpson asimpson merged commit 48b156b into grafana:main Mar 1, 2024
28 of 30 checks passed
@mshustov mshustov deleted the fix-issue-714 branch March 1, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ad-hoc does not work, failing grafana template variables parsing
3 participants