Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dbt/adapters/clickhouse/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def s3source_clause(
if comp:
comp = f"', {comp}'"
extra_credentials = ''
role_arn = role_arn or s3config.get('role_arn')
if role_arn:
extra_credentials = f", extra_credentials(role_arn='{role_arn}')"
return f"s3('{url}'{access}, '{fmt}'{struct}{comp}{extra_credentials})"
Expand Down
28 changes: 28 additions & 0 deletions tests/integration/adapter/clickhouse/test_clickhouse_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,31 @@ def test_read(self, project):
run_dbt(["run", "--select", "s3_taxis_source.sql"])
result = project.run_sql("select count() as num_rows from s3_taxis_source", fetch="one")
assert result[0] == 1000


class TestS3RoleArnGlobal:
@pytest.fixture(scope="class")
def project_config_update(self):
return {
'vars': {
'taxi_s3': {
'bucket': 'https://datasets-documentation.s3.eu-west-3.amazonaws.com/nyc-taxi/',
'fmt': 'TabSeparatedWithNames',
'role_arn': 'arn:aws:iam::123456789012:role/my-role'
}
}
}

@pytest.fixture(scope="class")
def models(self):
return {
"s3_taxis_source.sql": s3_taxis_full_source,
"schema.yml": schema_yaml,
}

def test_role_arn_in_compiled_sql(self, project):
# Only compile, don't run
result = run_dbt(["compile", "--select", "s3_taxis_source.sql"], expect_pass=True)

# Assert the SQL contains the expected role_arn function call
assert "extra_credentials(role_arn='arn:aws:iam::123456789012:role/my-role')" in result.results[0].node.compiled_code
Loading