-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### 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
- Loading branch information
1 parent
5515c85
commit b626bb9
Showing
26 changed files
with
707 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*Copyright (C) 2022 Dremio Corporation | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License.*/ | ||
|
||
{%- macro dremio__support_multiple_grantees_per_dcl_statement() -%} | ||
{{ return(False) }} | ||
{%- endmacro -%} | ||
|
||
{% macro dremio__get_show_grant_sql(relation) %} | ||
{%- if relation.type == 'table' -%} | ||
{%- set relation_without_double_quotes = target.datalake ~ '.' ~ target.root_path ~ '.' ~ relation.identifier-%} | ||
{%- else -%} | ||
{%- set relation_without_double_quotes = relation.database ~ '.' ~ relation.schema ~ '.' ~ relation.identifier-%} | ||
{%- endif %} | ||
|
||
SELECT privilege, grantee_id | ||
FROM sys.privileges | ||
WHERE privileges.object_id='{{ relation_without_double_quotes }}' | ||
{% endmacro %} | ||
|
||
{%- macro dremio__get_grant_sql(relation, privilege, grantees) -%} | ||
grant {{ privilege }} on {{relation.type}} {{ relation }} to user {{ grantees | join(', ') }} | ||
{%- endmacro -%} | ||
|
||
{%- macro default__get_revoke_sql(relation, privilege, grantees) -%} | ||
revoke {{ privilege }} on {{ relation.type }} {{ relation }} from user {{ grantees | join(', ') }} | ||
{%- endmacro -%} | ||
|
||
{% macro dremio__call_dcl_statements(dcl_statement_list) %} | ||
{% for dcl_statement in dcl_statement_list %} | ||
{% call statement('grants') %} | ||
{{ dcl_statement }}; | ||
{% endcall %} | ||
{% endfor %} | ||
{% endmacro %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.