Skip to content

Fix: pass dialect to MD5 func builder in generate_surrogate_key macro#3273

Merged
georgesittas merged 1 commit intomainfrom
jo/fix_generate_surrogate_key
Oct 21, 2024
Merged

Fix: pass dialect to MD5 func builder in generate_surrogate_key macro#3273
georgesittas merged 1 commit intomainfrom
jo/fix_generate_surrogate_key

Conversation

@georgesittas
Copy link
Contributor

@georgesittas georgesittas commented Oct 21, 2024

Today we get the first behavior when using this macro in BigQuery, which is incorrect.

>>> from sqlglot import exp
>>> exp.func("MD5", exp.Literal.string(f"Original value")).sql("bigquery")
"TO_HEX(MD5('Original value'))"
>>> exp.func("MD5", exp.Literal.string(f"Original value"), dialect="bigquery").sql("bigquery")
"MD5('Original value')"

Context: https://tobiko-data.slack.com/archives/C0448SFS3PF/p1729531496678999

@georgesittas georgesittas requested a review from a team October 21, 2024 17:45
@mr-mcox
Copy link

mr-mcox commented Oct 21, 2024

Thank you for addressing this - it was causing me a bit of confusion!

@georgesittas
Copy link
Contributor Author

Sure thing, appreciate the report!

@georgesittas georgesittas merged commit 0ce23c0 into main Oct 21, 2024
@georgesittas georgesittas deleted the jo/fix_generate_surrogate_key branch October 21, 2024 18:54
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.

3 participants