ClickHouse / ClickHouse/dbt-clickhouse

Be able to use an elevated role

Open
#700 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
362
Forks
177
Avg merge
2d 10h
Merged PRs (30d)
8

Description

**Is your feature request related to a problem? Please describe.**
I want to run DBT with an elevated role. For example, in `clickhouse-client` I can run:

```
SET ROLE elevated;

DROP TABLE IF EXISTS ....
```
The role is active for all the queries I run later.

I would like to e able to run DBT with this role.

I tried in `.profiles.yml`:

```
on-run-start:
- "SET ROLE elevated"
```
and
```
seeds:
project:
pre_hook: "SET ROLE elevated"
```
Both do not achieve my goal: I still see the role is not applied when the queries for a model are run.

Moreover, I noticed the same issue blocks me from using the native connector, as it runs a query

```
CREATE TABLE IF NOT EXISTS `__dbt_exchange_test_0_fa3d088e8fea11f1a907fdb336d5c617` (test String) ENGINE MergeTree() ORDER BY tuple()
```

before applying any on-run-start, etc... So the user needs to be able to create tables by default

**Describe the solution you'd like**
A simple way to provide roles to the user. For example a section in profile with roles

```
role:
- role1
- role2
```

that is used by all the queries run by dbt-clickhouse

**Describe alternatives you've considered**
I see that I can add `SET ROLE` to each model. It's ugly, and actually it might fail if another user tries to run `dbt` and does not have the roles available.

Contributor guide

Open the contributing guide

Research direction

No file or test is named. Start by tracing profile handling and the ClickHouse connector's connection setup, then verify how roles would apply to every query, including the initial native-connector table check and later model queries.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.