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

[Feature] Provide option to only update specific columns in incremental model #31

Closed
viplazylmht opened this issue Jul 13, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@viplazylmht
Copy link

Describe the Feature

When building data models using dbt-oracle, currently for an incremental model, there is no optional way to update only the columns I want. The adapter will update all columns except unique_keys. (I just checked out the code and found it, so if it has been satisfied before, please let me know).

For example, my data model follows the Fact-Dimension model, and here is an example Dimension table:
Table: D_MODEL
Columns: ID, MODEL_NAME, UPDATED_DATE

As we can see, the unique_key ID in the Dimension table is just used to join the Fact table. But, the merge on columns is MODEL_NAME, it is not the primary key of Dimension tables.

So, in this case, I only want to update the column UPDATED_DATE, but there is no config to finalize them. Dbt-oracle update column ID and UPDATE_DATE, and the whole Fact-Dim model seem broken because it can not join again.

Describe alternatives you've considered

Recently, I have worked with dbt-bigquery and they have the option merge_update_columns docs to update only columns they want.

I also read the merge_update_columns source code and found they customized the BaseConfig with BigqueryConfig, then use them on Jinja code too to filter out targeted columns.

So, our problem can be resolved by just creating an additional argument and logic, seem easy!

Who will this benefit?

I thought it is very useful for a lot of users who built special data models with unexpected behavior and make dbt-oracle more fluently.

Anything else?

Maybe if I have time, I will experiment on them. Also, can I create a pull request, or contribute to this project?

@viplazylmht viplazylmht added the enhancement New feature or request label Jul 13, 2022
@aosingh aosingh self-assigned this Jul 13, 2022
@aosingh
Copy link
Member

aosingh commented Jul 15, 2022

Thank you @viplazylmht for raising this feature request. This is now addressed in dbt-oracle==1.1.1
You can use the config merge_update_columns in incremental models

{{config(materialized='incremental', 
         unique_key='user_id',
         merge_update_columns=['user_name', 'income', 'last_login_date'])}}
SELECT * FROM {{ ref('seed') }}
{% if is_incremental() %}
    WHERE last_login_date > (SELECT max(last_login_date) FROM {{ this }})
{% endif %}

Please test this with dbt-oracle==1.1.1 and let me know if you have any questions.

If you want to check the changes please review the PR #35

@aosingh aosingh closed this as completed Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants