Hi all, I am brand brand new to DBT so.. if this ...
# troubleshooting
e
Hi all, I am brand brand new to DBT so.. if this belongs in DBT forum just tell me , but I have successfully gotten a model to run.. it takes a source table I'd tapped.. and transforms it.. pushing the result to a schema called
analytics
.. my problem/question is.. how do I ADD GRANT permission statements in the event of a successful run? because each run seems to wipe out the permissions I'd manually set tickers_last_7d.sql
Copy code
{{
   config(
     materialized='table'
   )
 }}

 select *
 from {{ source('tap_ibkr_tickers', 'ib_tickers') }}
 where query_start_time::date >= query_start_time - interval '7 days';

GRANT USAGE ON SCHEMA analytics TO "juju_apache-superset";
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA analytics TO "juju_apache-superset";
Copy code
Completed with 1 error and 0 warnings:
16:20:34  
16:20:34  Database Error in model tickers_last_7d (models/tap_ibkr_tickers/tickers_last_7d.sql)
16:20:34    syntax error at or near ";"
16:20:34    LINE 10: ...ry_start_time::date >= query_start_time - interval '7 days';
a
First question, is this for Snowflake or another SQL platform? Second, will schema level grants work for your use case?
e
ah Hi AJ, 1. This is on postgres 2. hmmm I am still a total data noob but.. trying to keep the pipeline flowing for now so.. yes?
when I do those GRANTS outside of dbt... dbt comes in and just .. wipes it all out and Apache Superset loses permission to read/write
a
The quickest resolution is probably to use "default" grants within the schema: https://stackoverflow.com/a/22684537
e
cool, I can give these a try now thank you
a
Yw! Those can be executed separate from your dbt flow, but they'll apply to future tables you create with dbt. Longer term, you can build in either schema -level grants or table level grants into your dbt flow so they are executed dynamically. I think in dbt-land they are "operations" but I'm a little rusty tbh. Hope that helps to get you going though! I'm sure others have solutions also, and I know dbt has at least one blog post on this topic as well.
e
As a data noob this is good to know stuff. My hope is this year to feature freeze my platform and just focus on using DBT, Airflow + Python .. to build a data warehouse
for anyone else coming through, here's what fixed it. Thanks again AJ
Copy code
ALTER DEFAULT PRIVILEGES FOR USER "juju_meltano-stnks" IN SCHEMA analytics GRANT SELECT ON TABLES TO "juju_apache-superset";