Skip to content

Commit 2ca440b

Browse files
authored
fix: parse query_tags string into List[QueryTag] for execute_statement (#359)
The SDK's StatementExecutionAPI.execute_statement() expects query_tags as Optional[List[QueryTag]], but executor.py passed the raw string directly, causing: 'str' object has no attribute 'as_dict' Parse "key:value,key2:value2" format into QueryTag objects. Handles edge cases: empty strings, colons in values, spaces, malformed entries (gracefully skipped). Fixes #358
1 parent a183359 commit 2ca440b

File tree

1 file changed

+7
-1
lines changed
  • databricks-tools-core/databricks_tools_core/sql/sql_utils

1 file changed

+7
-1
lines changed

databricks-tools-core/databricks_tools_core/sql/sql_utils/executor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ def execute(
8686
if row_limit is not None:
8787
exec_params["row_limit"] = row_limit
8888
if query_tags:
89-
exec_params["query_tags"] = query_tags
89+
from databricks.sdk.service.sql import QueryTag
90+
exec_params["query_tags"] = [
91+
QueryTag(key=k.strip(), value=v.strip())
92+
for pair in query_tags.split(",")
93+
for k, v in [pair.split(":", 1)]
94+
if ":" in pair
95+
]
9096

9197
# Submit the statement
9298
try:

0 commit comments

Comments
 (0)