Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbt-core 1.2 upgrade: Grants #42

Closed
jlarue26 opened this issue Oct 24, 2022 · 1 comment · Fixed by #62
Closed

dbt-core 1.2 upgrade: Grants #42

jlarue26 opened this issue Oct 24, 2022 · 1 comment · Fixed by #62
Assignees
Labels
enhancement New feature or request upgrade

Comments

@jlarue26
Copy link
Contributor

From dbt-labs/dbt-core#5468:

Managing access grants is one of the most asked for features from dbt users. We’re delivering this capability, but naturally there’s variance across data platforms as to how grants work, so time for adapter maintainers to roll their sleeves up. You might get lucky and not have to override any of them, but in case you do, below are descriptions of the new methods and macros, grouped into level of complexity (start with the easy ones first!)

💡 Note 💡
This new functionality does not add users, only grants access. You'll have to handle adding users elsewhere, and it has implications for the GRANT adapter tests.

Pull requests for adding grants for dbt Labs-maintained adapters should be very useful as a reference, for example: dbt-labs/dbt-bigquery#212.

See link for list of Override-able macros and methods.

@jlarue26
Copy link
Contributor Author

jlarue26 commented Oct 24, 2022

Version Requirement: This functionality only available to instances using Dremio v22.0+ Enterprise Edition.

References:

@jlarue26 jlarue26 self-assigned this Oct 24, 2022
@jlarue26 jlarue26 added the enhancement New feature or request label Nov 6, 2022
@jlarue26 jlarue26 assigned jlarue26 and ArgusLi and unassigned jlarue26 Nov 6, 2022
@ravjotbrar ravjotbrar assigned ravjotbrar and unassigned ArgusLi Nov 7, 2022
ravjotbrar added a commit that referenced this issue Nov 9, 2022
### Summary

This PR makes the necessary changes to support grants in our adapter.
All tests provided by dbt-core pass (with modifications). For grants to
work, changes need to be made to the relevant "grant" macros. Also made
a few miscellaneous changes including updating smoke_tests to not wipe
out current profiles.yml file.

### Description

#### Macros
- **support_multiple_grantees_per_dcl_statement**: Dremio only supports
one grantee per statement
- **get_show_grant_sql**: Gets data from privileges table
- **get_grant_sql** : Contains sql for granting a privilege
- **get_revoke_sql**: Contains sql for revoking a privilege
- **call_dcl_statements**: Dremio only supports calling one statement at
a time

These macros are all called by the default apply_grants macro provided
by dbt-core. For this reason, we need to make sure apply_grants is
called in each of the materializations (table, view, seed, incremental).

#### Tests
- **test_model_grants**: Tests grants for views and tables
- **test_incremental_grants**: Tests grants for incremental
materializations
- **test_seed_grants**: Tests grants for seeds
- **test_snapshot_grants**: Tests grants for snapshots
- **test_invalid_grants**: Tests invalid grants by providing a invalid
privilege and invalid user

#### Miscellaneous
- Added logic to keep current profiles.yml file in smoke_tests
- Removed the schema.sql macro, as those methods are overridden in
impl.py
- Added logic to drop a table when drop_schema is called (only spaces
allow the entire schema to be deleted)
- Added copyright headers to basic func tests

### Related Issue

#42

### Additional Reviewers

@ArgusLi @jlarue26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upgrade
Development

Successfully merging a pull request may close this issue.

3 participants