Skip to content

support variables, that are passed instead of numbers#57

Open
AndrewChubatiuk wants to merge 1 commit into
masterfrom
parse-variables-in-expressions
Open

support variables, that are passed instead of numbers#57
AndrewChubatiuk wants to merge 1 commit into
masterfrom
parse-variables-in-expressions

Conversation

@AndrewChubatiuk

@AndrewChubatiuk AndrewChubatiuk commented Oct 2, 2025

Copy link
Copy Markdown
  • support variables, that are passed instead of numbers
  • add ParseWithVars, that preserves variables in expressions
  • add label_values function support to parse grafana queries

using library to properly modify metricsql expressions imported rules and dashboards here. while parsing metricsql expression in grafana dashboards it fails when:

  • unquoted variable is used as a function argument: histogram_quantile($quantile, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))
  • parsing expression, which contains grafana specific label_values function

@codecov

codecov Bot commented Oct 2, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.91525% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.81%. Comparing base (a808ea4) to head (01c77e4).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
parser.go 91.30% 1 Missing and 1 partial ⚠️
lexer.go 96.96% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #57      +/-   ##
==========================================
+ Coverage   89.73%   89.81%   +0.07%     
==========================================
  Files          11       11              
  Lines        2981     3023      +42     
==========================================
+ Hits         2675     2715      +40     
- Misses        209      210       +1     
- Partials       97       98       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AndrewChubatiuk
AndrewChubatiuk force-pushed the parse-variables-in-expressions branch 4 times, most recently from 3f46c44 to 34e335c Compare October 3, 2025 06:58
@makasim
makasim requested review from f41gh7 and makasim October 13, 2025 11:44
@AndrewChubatiuk
AndrewChubatiuk force-pushed the parse-variables-in-expressions branch from 34e335c to cb98770 Compare February 16, 2026 20:18
…pressions

Add `PrettifyExpr` that allows to return prettified string generated from existing expression
@AndrewChubatiuk
AndrewChubatiuk force-pushed the parse-variables-in-expressions branch from cb98770 to 01c77e4 Compare July 2, 2026 10:28
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.

2 participants