parameterized ALTER TABLE SET TAGS
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 12:54 PM - edited 03-18-2025 01:14 PM
I would like to use parametrized sql queries to run SET TAGs commands on tables, but cannot figure out how to parameterize the query to prevent SQL injection. Both the `?` and `:key` parameter syntaxes throw a syntax error
Basically, I'd like to do this, but without string formatting so I can protect against SQL injection. Is there a way to do this?
tags = ", ".join(list_of_tags)
spark.sql(
f"ALTER TABLE IDENTIFIER(:table) SET TAGS {tags}",
args={"table": table_name},
)Note: the above isn't even valid syntax - once I add the IDENTIFIER clause, ANY FORM of SET TAGS following it will fail.