Skip to content
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

get redshift external tables #753

Merged
merged 4 commits into from
Nov 27, 2023

Conversation

brendan-cook-87
Copy link
Contributor

@brendan-cook-87 brendan-cook-87 commented Jan 6, 2023

redshift external tables are not listed in information_schema.tables but we can extract the same info from svv_external tables and union the results. also quote database name as redshift allows dashes which require quotes

resolves #752

This is a:

  • documentation update
  • bug fix with no breaking changes
  • new functionality
  • a breaking change

All pull requests from community contributors should target the main branch (default).

Description & motivation

external tables in redshift are not listed in information_schema.tables
they are listed in svv_external_tables

so that this macro works as expected (lists all tables in the specified schema, whether external or not)
there is a new dispatch for redshift__get_tables_by_pattern_sql which calls the default macro
and unions the result with the same information (with the same pattern matching) from svv_external_tables.

redshift also allows dashes in database names, which the macro does not quote, so can generate invalid sql.

Checklist

  • This code is associated with an Issue which has been triaged and accepted for development.
  • I have verified that these changes work locally on the following warehouses (Note: it's okay if you do not have access to all warehouses, this helps us understand what has been covered)
    • BigQuery
    • Postgres
    • Redshift
    • Snowflake
  • I followed guidelines to ensure that my changes will work on "non-core" adapters by:
    • dispatching any new macro(s) so non-core adapters can also use them (e.g. the star() source)
    • using the limit_zero() macro in place of the literal string: limit 0
    • using dbt.type_* macros instead of explicit datatypes (e.g. dbt.type_timestamp() instead of TIMESTAMP
  • [] I have updated the README.md (if applicable)
  • I have added tests & descriptions to my models (and macros if applicable)
  • I have added an entry to CHANGELOG.md

redshift external tables are not listed in information_schema.tables  but we can extract the same info from svv_external tables and union the results.
also quote database name as redshift allows dashes which require quotes
@joellabes
Copy link
Contributor

Hey @brendan-cook-87, I've had a look at this (sorry for the delay!) and I think that this is actually functionality that should be provided by dbt Core directly. I've opened an issue and will see what they reckon!

@github-actions
Copy link

This PR has been marked as Stale because it has been open with no activity as of late. If you would like the PR to remain open, please comment on the PR or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 31, 2023
@github-actions
Copy link

github-actions bot commented Aug 7, 2023

Although we are closing this PR as stale, it can still be reopened to continue development. Just add a comment to notify the maintainers.

@github-actions github-actions bot closed this Aug 7, 2023
@brendan-cook-87
Copy link
Contributor Author

@joellabes any chance we can still merge this as there is zero traction after 10 months on the other issue raised?

@dataders dataders reopened this Nov 27, 2023
@joellabes
Copy link
Contributor

@brendan-cook-87 native support in core should be coming in 1.8 but yeah let's get this in for now!

@joellabes joellabes added this pull request to the merge queue Nov 27, 2023
Merged via the queue into dbt-labs:main with commit 23ddc9e Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get_tables_by_pattern_sql doesn't work with redshift external tables
3 participants