-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
cross db queries in redshift #3236
Comments
Great point @sonac, thanks for opening the issue. There are other places in the dbt-redshift adapter codebase where it takes a strong stance against the possibility of cross-database querying (#3179). Given that, I'm actually surprised you didn't run into a compilation error earlier. With the advent of cross-db querying on RA3 nodes, it's clear that we'll need to change more functionality around the runtime cache + catalog queries. Thankfully, we already have a good sense of what this can look like in dbt-snowflake, and we can adopt it piecemeal—to my knowledge, it's still not yet to create tables/views in a different Redshift database. We started discussion in the other issue about how dbt should determine its behavior. Ideally, there would be an obvious metadata query to run—or better yet, a piece of information to pull off the cursor object—but after checking with the Redshift team, the query to determine node type is a bit more involved. Rather than go that route, I find myself in favor of a new What do you think? Is the addition of that functionality something you'd be interested in helping to contribute? |
indeed, I'd be keen helping, since this functionality would ease our testing setup. |
since we would also like to leverage cross-db queries it would be great to help. Also, since we wanted to re-arrange some of our dbt setup with this ra3 capability it would be great to have that rather sooner than later 😄 |
@sonac @misteliy Okay, I think there are three major steps involved here:
|
I've looked into it and it seems like it's actually not that trivial to extract metadata from another database within the redshift, system views are inaccessible in cross-db queries (maybe because of their reliance on inbuilt functions like |
Hi, fantastic to get started. I could also offer to leverage our current redshift expert from AWS which is currently engaged in our project. If you want I could set up a quick call next week to address all necessary questions. Let me know if you think that would be useful. |
I think the ideal version of this implementation preserves all existing behavior on dc2/ds2 nodes, including the explicit compilation error if a user tries to do something disallowed (querying tables in a different database). Hence the desire for an equally explicit |
Cool, it would've been great if somebody else would test it out, since if I'm not using filters on that view - I'm running into weird errors that some relation doesn't exist (and it's hard to debug why it occurs since it using some inbuilt redshift functions) |
Sorry for the late reply. We were able to query the
|
However, we might have identified bigger issues with redshift cross db:
but this not
SQL Error [0A000]: ERROR: cross-database reference to database "sources" is not supported 😟 |
This would be great for our project :) |
@misteliy That's very exciting! I think sources in "external" databases would still represent a huge value-add for many projects. Did you get a sense of which macros and methods we need to reimplement to make it possible? |
Hi Guys To summarize what we discovered:
|
This was resolved by #3408 — as in, the bit we can do for now: querying sources that live in other databases when using RA3 nodes. When Redshift adds write DDL/DML support, we can consider adding support for other resources types in other databases. |
Describe the bug
When using source database that is different from the target (https://docs.getdbt.com/reference/resource-properties/database), I ran into an issue that adapter doesn't fetch columns, since it seems like it looks only into target db for meta information about them: https://github.com/fishtown-analytics/dbt/blob/develop/plugins/redshift/dbt/include/redshift/macros/adapters.sql#L79
Steps To Reproduce
Expected behavior
Adapter expected to get meta information about source tables from source database
Screenshots and log output
Not applicable
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using:
OSX
The output of
python --version
:3.9.4
Additional context
Not applicable
The text was updated successfully, but these errors were encountered: