diff --git a/dbt/adapters/duckdb/secrets.py b/dbt/adapters/duckdb/secrets.py index 62b1307d..243c99e6 100644 --- a/dbt/adapters/duckdb/secrets.py +++ b/dbt/adapters/duckdb/secrets.py @@ -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"] ] diff --git a/tests/unit/test_credentials.py b/tests/unit/test_credentials.py index 72c5b8a3..fd0756a3 100644 --- a/tests/unit/test_credentials.py +++ b/tests/unit/test_credentials.py @@ -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' )""" @@ -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' )""" @@ -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) @@ -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' )""" @@ -166,7 +166,7 @@ def test_add_hf_secret(): assert sql == \ """CREATE SECRET ( type huggingface, - token abc + token 'abc' )""" diff --git a/tests/unit/test_duckdb_adapter.py b/tests/unit/test_duckdb_adapter.py index 43fba6c0..f0942938 100644 --- a/tests/unit/test_duckdb_adapter.py +++ b/tests/unit/test_duckdb_adapter.py @@ -118,7 +118,7 @@ def test_create_secret(self, connector): connection.handle._cursor._cursor.execute.assert_called_with( """CREATE OR REPLACE SECRET _dbt_secret_1 ( type s3, - key_id abc, - secret xyz, - region us-west-2 + key_id 'abc', + secret 'xyz', + region 'us-west-2' )""")