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

support "with no schema binding" on redshift views #523

Closed
drewbanin opened this issue Sep 1, 2017 · 15 comments
Closed

support "with no schema binding" on redshift views #523

drewbanin opened this issue Sep 1, 2017 · 15 comments
Assignees
Labels
enhancement New feature or request redshift
Milestone

Comments

@drewbanin
Copy link
Contributor

http://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_VIEW.html

This should almost certainly be the default in production, but there may be some benefit to turning it off in development. It's convenient that view creation currently fails if a nonexistent column/table is referenced

@drewbanin drewbanin added enhancement New feature or request redshift labels Sep 1, 2017
@drewbanin drewbanin self-assigned this Sep 1, 2017
@drewbanin
Copy link
Contributor Author

There is currently a bug in with no schema binding that causes views creation to fail if the view sql contains CTEs. Bug Report

@izdi
Copy link

izdi commented Sep 22, 2017

Hey @drewbanin, this is a nice feature to add.
Is it currently in development ?

@drewbanin
Copy link
Contributor Author

hey @izdi - it looks like there's a bug on Amazon's side, and they'll be fixing it in the next couple of weeks. More info here

We can add this to dbt in pretty short order once the bug is fixed

@HarlanH
Copy link

HarlanH commented Oct 3, 2017

Just a note -- I'm experimenting using Spectrum to reference external data with dbt. It turns out that you can't create VIEWs in Redshift that reference Spectrum tables unless with no schema binding is supplied. (CTEs are not the issue.) If I force the models to be materialized tables, it works great, but in this case, I'd rather have them be views. It would be great to support this, at least as a non-default option, sooner rather than later!

@drewbanin
Copy link
Contributor Author

@HarlanH totally on the same page here - we just created this issue to investigate Spectrum in dbt. I think this should be relatively easy to add to the materialization.

At this point, we really want to get 0.9.0 out, then I think it makes sense to turn our attention to features like this for an 0.9.1 release shortly thereafter.

Another compelling idea is to instead add this materialization to the redshift package. This would allow us to iterate on the Redshift view materialization (and build other spectrum helpers) without needing to do a full-fledged release of dbt. I'll have a chat with @cmcarthur, but know that this is definitely on our radar.

@drewbanin drewbanin added this to the 0.9.1 milestone Nov 10, 2017
@jthandy
Copy link
Member

jthandy commented Nov 17, 2017

FYI, this redshift bug should be fixed in a coming-soon release:

https://forums.aws.amazon.com/ann.jspa?annID=5149

*Support for a WITH clause subquery in late binding views

@drewbanin
Copy link
Contributor Author

This is pretty close to being done... Waiting for our Redshift cluster to be patched with the latest release to do some testing!

@izdi
Copy link

izdi commented Dec 18, 2017

Hey guys, what's an ETA for the fix ?
Thanks!

@drewbanin
Copy link
Contributor Author

Hey @izdi - the code for this is written here: #614

We're planning on releasing 0.9.1 this week, but this particular PR should be merged in the next ~24 hours. We'd love it if you could install from development tomorrow and give it a spin before the prod release :)

@izdi
Copy link

izdi commented Dec 19, 2017

Hey @drewbanin, I'd like to help, installed from the development branch.
Is adding bind: false on a project level (dbt_project.yml) going be enough ?

For the record -- I usually do not specify any config in my views, so it's a plain SQL query wrapped later in a view with the help of your tool.
Is there any way to tell if it's a view with no schema binding besides altering parent tables ?

@drewbanin
Copy link
Contributor Author

@izdi this hasn't been merged yet (but will be today -- cc @cmcarthur). When that happens, you'll be able to use bind: false exactly how you've specified here!

The compiled code in target/run/{project_name}/.../model.sql should look like:

create view model as (
  select ...
) with no schema binding;

To see a list of the late-binding views in your Redshift cluster, you can use this query:

select distinct view_schema, view_name
from pg_get_late_binding_view_cols()
cols(view_schema name, view_name name, col_name name, col_type varchar, col_num int)

@drewbanin
Copy link
Contributor Author

This is going out in 0.9.1, closing

@izdi
Copy link

izdi commented Jan 3, 2018

Release ETA ?

@drewbanin
Copy link
Contributor Author

Hey @izdi - we had a bit of a delay over the holiday. All 0.9.1 PRs are merged into development (including this one) at this point. We're doing some final testing, and we're planning to release this Friday. We'd love it if you could install from development and give it a spin! You can find the new docs for this feature here: https://docs.getdbt.com/docs/warehouse-specific-configurations#section-late-binding-views

@drewbanin
Copy link
Contributor Author

@izdi dbt 0.9.1 was released to pypi today. We're building the homebrew and conda releases presently, and they should be available sometime over the weekend. Feel free to test them out with pip install dbt :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request redshift
Projects
None yet
Development

No branches or pull requests

4 participants