Skip to content

Commit

Permalink
add quotes when secret params are not type or provider
Browse files Browse the repository at this point in the history
  • Loading branch information
guenp committed Jul 31, 2024
1 parent ec65e43 commit 3190554
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dbt/adapters/duckdb/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def to_sql(self) -> str:
params.update(params.pop("secret_kwargs", {}))
params_sql = f",\n{tab}".join(
[
f"{key} {value}"
f"{key} '{value}'" if key not in ["type", "provider"] else f"{key} {value}"
for key, value in params.items()
if value is not None and key not in ["name", "persistent"]
]
Expand Down
26 changes: 13 additions & 13 deletions tests/unit/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def test_add_secret_with_empty_name():
assert sql == \
"""CREATE SECRET (
type s3,
key_id abc,
secret xyz,
region us-west-2
key_id 'abc',
secret 'xyz',
region 'us-west-2'
)"""


Expand Down Expand Up @@ -68,10 +68,10 @@ def test_add_secret_with_name():
assert sql == \
"""CREATE OR REPLACE SECRET my_secret (
type s3,
scope s3://my-bucket,
key_id abc,
secret xyz,
region us-west-2
scope 's3://my-bucket',
key_id 'abc',
secret 'xyz',
region 'us-west-2'
)"""


Expand Down Expand Up @@ -107,7 +107,7 @@ def test_add_unsupported_secret_param():
assert sql == \
"""CREATE OR REPLACE SECRET _dbt_secret_1 (
type s3,
password secret
password 'secret'
)"""
with pytest.raises(duckdb.BinderException) as e:
duckdb.sql(sql)
Expand Down Expand Up @@ -141,10 +141,10 @@ def test_add_azure_secret():
"""CREATE SECRET (
type azure,
provider service_principal,
tenant_id abc,
client_id xyz,
client_certificate_path foo\\bar\\baz.pem,
account_name 123
tenant_id 'abc',
client_id 'xyz',
client_certificate_path 'foo\\bar\\baz.pem',
account_name '123'
)"""


Expand All @@ -166,7 +166,7 @@ def test_add_hf_secret():
assert sql == \
"""CREATE SECRET (
type huggingface,
token abc
token 'abc'
)"""


Expand Down

0 comments on commit 3190554

Please sign in to comment.