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 parsing macros in queries #74

Merged
merged 1 commit into from Oct 18, 2022
Merged

- fix parsing macros in queries #74

merged 1 commit into from Oct 18, 2022

Conversation

sasklacz
Copy link
Contributor

@sasklacz sasklacz commented Oct 16, 2022

This was originally reported as a bug in clickhouse plugin grafana/clickhouse-datasource#195 . Whenever there are are multiple parentheses in the query, parser is having a hard time finding the end of the macro command.

This solution is maybe not the prettiest, but I think it's pretty solid. It first cleans up the input query from any empty spaces before the parentheses. Then it parses the query looking for macros with parentheses and adds an empty space at the last parenthesis, so that we can still use our original regex for finding the macro AND arguments (which is now bulletproof, as before it could grab a bracket belonging to a select, or other outer command).

Added new test cases and tested in clickhouse datasource plugin.

Do we update the version anywhere ?

@CLAassistant
Copy link

CLAassistant commented Oct 16, 2022

CLA assistant check
All committers have signed the CLA.

macros.go Outdated Show resolved Hide resolved
@sasklacz
Copy link
Contributor Author

Got rid of the regex for parsing macros as suggested by @andresmgot

Copy link
Collaborator

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

nice 👍 happy to get rid of the regex!

macros.go Outdated Show resolved Hide resolved
@sasklacz sasklacz merged commit 53084cb into main Oct 18, 2022
@sasklacz sasklacz deleted the parsing-macros branch October 18, 2022 20:25
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.

None yet

3 participants