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(sqlglot): Convert metric syntax back to dialect-specific after parsing it #273

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

Vitor-Avila
Copy link
Contributor

The CLI uses sqlglot to parse SQL syntax from dbt metrics. While we were specifying the SQL dialect when parsing the query, we were not specifying the dialect when converting the parsed result back to SQL, which would cause issues with engine-specific syntaxes. Some examples:

  • A BQ metric created using IF() statement would get converted to CASE (would still work but different syntax)
  • A BQ metric created using DATE_DIFF() would get converted to DATEDIFF() which doesn't work with BQ.

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

Aaah, good catch!

@Vitor-Avila Vitor-Avila merged commit 8a459f6 into main Mar 20, 2024
5 checks passed
@Vitor-Avila Vitor-Avila deleted the sqlglot-fix branch March 20, 2024 16:17
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