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

Support grants #130

Merged
merged 4 commits into from
Oct 13, 2022
Merged

Support grants #130

merged 4 commits into from
Oct 13, 2022

Conversation

mdesmet
Copy link
Member

@mdesmet mdesmet commented Sep 17, 2022

Overview

Support grants as described in https://docs.getdbt.com/reference/resource-configs/grants

Tested using sql-standard access control on a Hive catalog.

Checklist

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • README.md updated and added information about my change
  • I have run changie new to create a changelog entry

docker-compose-starburst.yml Outdated Show resolved Hide resolved
Comment on lines +73 to +76
{% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}
{% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}

{{ run_hooks(post_hooks) }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it also be applicable to incremental.sql?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked on dbt-snowflake and applied the same onto ours.

It seems not tested within core dbt. It's however the same hooks but only applied on full_refresh.

Views is tested and is working, although no hooks in the materialization are called.

dbt/include/trino/macros/apply_grants.sql Show resolved Hide resolved
dbt/include/trino/macros/apply_grants.sql Show resolved Hide resolved
@mdesmet
Copy link
Member Author

mdesmet commented Oct 5, 2022

Created 2 follow up issues #147, #146

hive-metastore:
image: ghcr.io/innoverio/hive-metastore-multiarch:sha-28c28bc #TODO: replace with Starburst hive container once config is merged
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with Starburst hive container once config is merged

Could you please use a concrete ticket in the TODO ? For me it is not clear at the moment what is the limitation of Starburst HMS which requires the usage of a different HMS image.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to discuss if we want it or not, the Starburst HMS doesn't offer direct access to the Hive config, so we would need to add environment variables and convert them to valid Hive configurations.

We also would need to consider if we want the Starburst HMS to support these exotic Hive settings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not wrong, it's only hive.users.in.admin.role parameter which is not exposed in Starburst HMS, it shouldn't be a big deal to expose it there. Are there any other parameters which are not available in Starburst HMS?

Copy link
Member Author

@mdesmet mdesmet Oct 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other parameters (except for hive.users.in.admin.role) are required. I'll do a PR there but let that not stop us from releasing this one.

setup.py Outdated
@@ -86,7 +86,7 @@ def _get_dbt_core_version():
},
install_requires=[
"dbt-core~={}".format(dbt_version),
"trino==0.315.0",
"trino==0.317.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all these changes related to supporting grants or could they be extracted to smaller unrelated PRs ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need 0.317.0 as in that version we introduced roles support.

We even need the not yet released 0.318.0 as we need another fix as prepared statements are not yet fully working in 0.317.0 (see the CI failures and trinodb/trino-python-client#249)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion. The PR contains 6 commits - which seemed to me (correct me if I'm wrong) are not all related to one another. Could you extract the commits which are unrelated to the grants to one or more preparatory PRs ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a PR with only Trino, Starburst and trino-python-client version upgrade but I'm waiting for the 0.318.0 version to be released.

dbt/include/trino/macros/apply_grants.sql Show resolved Hide resolved


@pytest.mark.hive
# TODO: setup roles in Galaxy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a TODO relevant for this PR ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reminder to test grants with SEP and Galaxy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include issue number in the comment here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added issues for both Galaxy and SEP tests.

tests/functional/adapter/test_model_grants.py Show resolved Hide resolved
Copy link
Contributor

@hovaesco hovaesco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's address the missing Starburst HMS feature first.

@mdesmet
Copy link
Member Author

mdesmet commented Oct 13, 2022

@findinpath, @hovaesco : outside of the container image (that's being replaced right now). Are there any more blockers in this PR.

I would like to make a new release of dbt 1.2 today (including grants) and then focus on the 1.3 version.

@mdesmet mdesmet merged commit 9471340 into starburstdata:master Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants