Describe the feature
What
I think this is a direct successor to dbt-labs/dbt-redshift#217. There's many other related issues listed below.
Today, the only supported cross-database scenario in dbt-redshift is to allow source tables to be in another database. There are considerable caveats to this narrow use case:
- a cluster is used of node_type
ra3 or serverless
- a
profiles.yml profile that specifies: ra3_node: true
- a
source table is defined in a database different than what's given in profile
- all models referencing the "foreign db" source table must be materialized as a table (views are not supported)
there is a newer feature, still in preview, Datashare, that allows writes to external databases. For example, if I am logged into the FOO database on cluster FIZZ, a configuration exists such that I can create tables within database BAR on cluster BUZZ (and vise versa).
Ideal end-state
A dbt-redshift project could take any model in the DAG and have it materialized in another with a simply as providing {{ config( database = 'BAR' ) }} at the top of the model. That is, provided that the databases used have been properly configured as such.
How
Challenges
The challenges in supporting this new feature are varied:
| problem |
example |
| dbt-redshift inheirits from dbt-postgres |
redshift__create_schema() which invokes postgres__create_schema() which only uses two-part names, schema.relation, exlcuding a required database |
| dbt-redshift relies on postgres metadata views that don't support Datashares |
redshift__get_columns_in_relation() queries information_schema."columns" but should perhaps use SVV_ALL_COLUMNS instead` |
| discrepancy across Redshift SKUs for support of Datashares |
ra3_node and serverless supports Datasharing/crossdb-writes, dc2 clusters do not |
discrepancy in performance between pg_* metadata tables and SVV_* datashare-supporting Redshift system tables |
information_schema."columns" takes a few dozen millisecionds to return all column metadata in the current database. SVV_ALL_COLUMNS can be more than 50X slower than this |
Work required
Before the actual coding begins, it is imperative that we first learn the following:
- what datasharing scenarios could feasibly be supported
- the current & future best practice for fetching metadata
- the performance impact of using
SVV_* tables for all SKUs (ra3, serverless, dc2)
### Possible work required
- [ ] shift away from `pg_` metadata queries to those that include "external" database metadata
- [ ] override any `postgres` macros that exclude `database` from `relation` name e.g. redshift__create_schema()
- [ ] (possible) remove both `verify_database` method and `ra3_node` profile parameter
- [ ] ensure functionality of metadata-related macros in "core" packages such as dbt-codegen, dbt-utils, dbt-audit-helper etc
- [ ] write cross database integration tests
- [ ] add RA3 and serverless to our CI pipeline
related
### related issues
- [ ] https://github.com/dbt-labs/dbt-core/issues/3179
- [ ] https://github.com/dbt-labs/dbt-core/issues/3236
- [ ] https://github.com/dbt-labs/dbt-core/issues/5297
- [ ] dbt-labs/dbt-redshift#94
- [ ] dbt-labs/dbt-adapters#652
- [ ] dbt-labs/dbt-redshift#217
- [ ] dbt-labs/dbt-redshift#281
- [ ] dbt-labs/dbt-redshift#501
- [ ] dbt-labs/dbt-adapters#645
- [ ] dbt-labs/dbt-adapters#643
- [ ] dbt-labs/dbt-adapters#639
- [ ] https://github.com/dbt-labs/dbt-redshift/pull/905
relevant AWS Redshift docs
Who will this benefit?
dbt-redshift users who want to use Datasharing to federate a dbt project across databases and clusters
Describe the feature
What
I think this is a direct successor to dbt-labs/dbt-redshift#217. There's many other related issues listed below.
Today, the only supported cross-database scenario in dbt-redshift is to allow
sourcetables to be in another database. There are considerable caveats to this narrow use case:ra3orserverlessprofiles.ymlprofile that specifies:ra3_node: truesourcetable is defined in adatabasedifferent than what's given in profilethere is a newer feature, still in preview, Datashare, that allows writes to external databases. For example, if I am logged into the
FOOdatabase on clusterFIZZ, a configuration exists such that I can create tables within databaseBARon clusterBUZZ(and vise versa).Ideal end-state
A dbt-redshift project could take any model in the DAG and have it materialized in another with a simply as providing
{{ config( database = 'BAR' ) }}at the top of the model. That is, provided that the databases used have been properly configured as such.How
Challenges
The challenges in supporting this new feature are varied:
redshift__create_schema()which invokespostgres__create_schema()which only uses two-part names,schema.relation, exlcuding a requireddatabaseredshift__get_columns_in_relation()queriesinformation_schema."columns"but should perhaps useSVV_ALL_COLUMNSinstead`ra3_nodeandserverlesssupports Datasharing/crossdb-writes,dc2clusters do notpg_*metadata tables andSVV_*datashare-supporting Redshift system tablesinformation_schema."columns"takes a few dozen millisecionds to return all column metadata in the current database.SVV_ALL_COLUMNScan be more than 50X slower than thisWork required
Before the actual coding begins, it is imperative that we first learn the following:
SVV_*tables for all SKUs (ra3, serverless, dc2)related
relevant AWS Redshift docs
Who will this benefit?
dbt-redshift users who want to use Datasharing to federate a dbt project across databases and clusters