Comments (2)
@ybressler Thanks for opening, and sorry for the delay getting back to you!
Bad solution
As you mention, this would do the trick:
- Clone the entire database
dbt run --select config.materialized:view --threads 100
It's just not the most savory of solutions :)
Better solution
This is exactly the question you raised in dbt-labs/dbt-core#4959. It's possible (and pretty easy) to override ref
to exclude the database
identifier.
Docs: https://docs.getdbt.com/reference/dbt-jinja-functions/builtins
Discourse: https://discourse.getdbt.com/t/performing-a-blue-green-deploy-of-your-dbt-project-on-snowflake/1349
The trade-off is, if you do this all the time, you can't create your objects across multiple databases. I remember working on a project that wanted it both ways, and ended up setting a rule like:
- Views can only select from tables in the same database
- Tables can select from objects in other databases
-- Render identifiers without a database if the current model is materialized as a view.
-- Otherwise, include the database.
{% macro ref(model_name) %}
{% set rel = builtins.ref(model_name) %}
{% set not_a_view = (config.get('materialized') != 'view') %}
{% do return(rel.include(database=not_a_view)) %}
{% endmacro %}
Best solution???
I completely buy the thing you're saying here:
As an aside, Snowflake's zero copy cloning is one of its features which sets it apart from its competitors – it would be incredibly valuable to have a more DBT-native solution available
I think we'll see cloning supported by more databases, and it will be all-the-more important for dbt to support a built-in clone
method/macro that can abstract across their differences.
I've also long wanted to support a "clone" mode of --defer
, rather than just rewriting upstream references: dbt-labs/dbt-core#5095. (This is important for feeding "Slim CI" schemas into BI tools. With traditional --defer
, unbuilt upstream models are totally missing.)
Following that approach, dbt could clone upstream objects "as needed." Cloning a table would look like cloning a table. Cloning a view may look like cloning + rewriting refs, or (much simpler) just running that view.
If you're running hundreds of models, the accumulated time of doing this is probably more than a one-shot create database clone ...
. If you're just running a handful of models, though, you can skip a lot of unneeded cloning. If you've changed a number of models, and you want to inter-weave the running of changed models and the cloning of unchanged models, all in DAG order—such a construct would give dbt the ability to do it.
from dbt-snowflake.
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days.
from dbt-snowflake.
Related Issues (20)
- [Feature] add functional test to cover new cover new custom config for tests.
- [Feature] metadata-based freshness checks for external tables
- [Bug] list_relations_without_caching & proxy & no-populate-cache
- [Bug] `not_null` constraint only has effect when specified at the column level HOT 1
- [Bug] Replace underscores with hyphens in account identifiers
- [Feature] Replace underscores with hyphens in account ids HOT 1
- [Bug] Seed file already exists when I run dbt-build with full refresh model HOT 4
- [Bug] `quoting` config not working with 1.8 HOT 3
- [Feature] Support JWT Authentication
- [Feature] Improve key-pair auth performance HOT 6
- [Tech Debt] Fix DT testing that should be automated
- [Feature] Refresh mode for dynamic tables HOT 4
- [Feature] transient dynamic tables
- [Bug][SPIKE] Investigate flaky test
- [Feature] dynamic tables: support macros in "snowflake_warehouse" config value HOT 4
- [Bug] macro `snowflake__get_columns_in_relation` does not handle VECTOR data types correctly
- [Bug] Use `show ... starts with` instead of `show ... like` in `_show_object_metadata`
- Full refresh on Dynamic table HOT 2
- [Feature] Create relations as case-sensitive by default
- [Feature] Optionally refresh dynamic tables when not rebuilding HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbt-snowflake.