Skip to content

Snowflake Integer Placeholder Replacement #3163

Closed Answered by georgesittas
brentonmallen1 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @brentonmallen1,

I assume you meant that it's not possible to pass these kwargs by doing replace_placeholders(expr, 10=..., 11=...). To work around this limitation you can just expand a dictionary in Python, like so:

>>> import sqlglot
>>>
>>> sql = """
... select
...         col1, col2, col3, col4, sum(col5) as sum_col5
...     from table_name
...     where col_name IN (:10,:11)
...     group by 1,2,3,4
... """
>>>
>>> sqlglot.exp.replace_placeholders(sqlglot.parse_one(sql), **{"10": "foo", "11": "bar"}).sql()
"SELECT col1, col2, col3, col4, SUM(col5) AS sum_col5 FROM table_name WHERE col_name IN ('foo', 'bar') GROUP BY 1, 2, 3, 4"

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@brentonmallen1
Comment options

Answer selected by georgesittas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants