-
Notifications
You must be signed in to change notification settings - Fork 40
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
[Bug] GRANT revoke statements in redshift fails when usernames contain certain characters (eg. .
)
#172
Comments
Thanks for reporting this @ivansabik ! The relevant code appears to be in In the meantime, you might be able to resolve it by adding something like the following to your dbt project in a file named {%- macro default__get_revoke_sql(relation, privilege, grantees) -%}
-- just figure out the right code to put here
{%- endmacro -%} |
@ivansabik wanna give this a try? This worked for me in dbt-postgres, but I didn't try it out in dbt-redshift:
{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}
{%- set quoted_grantees = [] -%}
{%- for grantee in grantees -%}
{%- do quoted_grantees.append(adapter.quote(grantee)) -%}
{% endfor -%}
revoke {{ privilege }} on {{ relation }} from {{ quoted_grantees | join(', ') }}
{%- endmacro -%} See below for the details to reproduce this.
|
In order handle both {%- macro quote_grantees(grantees) -%}
{%- set quoted_grantees = [] -%}
{%- for grantee in grantees -%}
{%- do quoted_grantees.append(adapter.quote(grantee)) -%}
{% endfor -%}
{%- do return(quoted_grantees) -%}
{%- endmacro -%}
{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}
revoke {{ privilege }} on {{ relation }} from {{ quote_grantees(grantees) | join(', ') }}
{%- endmacro -%}
{%- macro default__get_grant_sql(relation, privilege, grantees) -%}
grant {{ privilege }} on {{ relation }} to {{ quote_grantees(grantees) | join(', ') }}
{%- endmacro -%} Something to be aware of: going this route would make all user names / roles case-sensitive when they are written in the YAML. |
I have the same issue, is there any news about the fix of this bugs in future DBT versions? |
Forgot to post an update here but the suggested solution workaround did the trick for me using Redshift |
Is this a new bug in dbt-core?
Current Behavior
When grants are setup in an incremental model dbt attempts to run some a REVOKE statement. When the username(s) that currently have access to that table contain a dot character (eg.
ivan.sabik
), which is completely valid for a Redshift username , building those models fails with:That would be solved by adding quotes to those users, that is instead of
revoke select on table eventview from ivan.sabik
it should berevoke select on table eventview from "ivan.sabik"
Expected Behavior
REVOKE statements don't throw a syntax error
Steps To Reproduce
syntax error at or near "."
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
No response
The text was updated successfully, but these errors were encountered: