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 exposures crashing with referencing questions with multiple variables #226

Merged
merged 3 commits into from
Feb 16, 2024

Conversation

kkuznets
Copy link
Contributor

Problem
Running dbt-metabase exposures produces faulty exposures.json if the referenced Metabase questions contain multiple variables in one query.

To reproduce
The problem is due to the greedy nature of the .* regex pattern that will catch multiple sets of double braces if they exist within the same line.

Example query:

SELECT *
FROM generate_series(  DATE_TRUNC ('day',{{start_date}}  - cast({{rolling_days}} || ' days' as interval)),  DATE_TRUNC ('day',now() - interval '1 day'), '1 day') as buckets(day);

Solution
Make the regex less greedy to match as little text as possible.

@kkuznets kkuznets marked this pull request as ready for review February 14, 2024 01:51
@kkuznets kkuznets changed the title fix exposures crashing with referencing questions with variables fix exposures crashing with referencing questions with multiple variables Feb 14, 2024
@gouline
Copy link
Owner

gouline commented Feb 14, 2024

Nice! Can you please add a unit test that fails before your fix and succeeds after?

@kkuznets
Copy link
Contributor Author

Sure! Added a simple unit test.

@gouline gouline merged commit 09675ec into gouline:master Feb 16, 2024
1 check passed
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

2 participants