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

[Bug] Materialized views are executing additional SQL statements during refresh through dbt core #616

Open
2 tasks done
karthickGK4794 opened this issue Jan 15, 2025 · 0 comments
Labels
feature:materialized-views Issues related to materialized views pkg:dbt-redshift Issue affects dbt-redshift type:bug Something isn't working as documented

Comments

@karthickGK4794
Copy link

karthickGK4794 commented Jan 15, 2025

Is this a new bug in dbt-redshift?

  • I believe this is a new bug in dbt-redshift
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

While refreshing the materialized views through dbt core, i see some additional SQL statements are getting executed by dbt such as drop statements of backup and temp tables, view definition and tables svv_table_info, svv_mv_info along with the refresh statement which is taking additional time to refresh the model. Is there a way to avoid running those additional steps to reduce the overall runtime as refresh statement alone is sufficient ?

Expected Behavior

Execution of Refresh materialized view table_name alone

Steps To Reproduce

{{
config({
"materialized":"materialized_view",
"tags": "materialized_Views",
"alias":"table_1"
})
}}

select * from datalake_table

dbt run -s table_1

Relevant log output

select
            tb.database,
            tb.schema,
            tb.table,
            tb.diststyle,
            tb.sortkey1,
            mv.autorefresh
        from svv_table_info tb
        -- svv_mv_info is queryable by Redshift Serverless, but stv_mv_info is not
        left join svv_mv_info mv
            on mv.database_name = tb.database
            and mv.schema_name = tb.schema
            and mv.name = tb.table
        where tb.table ilike 'table_1'
        and tb.schema ilike ''
        and tb.database ilike ''

select
            vw.definition
        from pg_views vw
        where vw.viewname = ''
        and vw.schemaname = ''
        and vw.definition ilike '%create materialized view%'

refresh materialized view table_1

drop materialized view if exists table_1__dbt_backup

drop materialized view if exists table_1__dbt_tmp

Environment

- OS: Windows
- Python:3.9.13
- dbt-core: 1.8.5
- dbt-redshift: 1.8.1

Additional Context

No response

@karthickGK4794 karthickGK4794 changed the title [Bug] <title> Materialized views are executing additional SQL statements during refresh through dbt core [Bug] Materialized views are executing additional SQL statements during refresh through dbt core Jan 15, 2025
@mikealfare mikealfare added pkg:dbt-redshift Issue affects dbt-redshift type:bug Something isn't working as documented feature:materialized-views Issues related to materialized views labels Jan 23, 2025
@mikealfare mikealfare transferred this issue from dbt-labs/dbt-redshift Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:materialized-views Issues related to materialized views pkg:dbt-redshift Issue affects dbt-redshift type:bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

2 participants