323 Dynamic SQL 94831248

Limitations of Dynamic SQL

tools-only Updated 7 repo stars

File contents

Limitations of Dynamic SQL

PROBLEM

Some SQL patterns that work in legacy dbt may not be supported by Fusion's static analysis, such as:

PIVOT(...) FOR column_name IN (ANY)

SOLUTION

The first option is always preferred and should be attempted first, if possible.

option 1: refactor

refactor away any instances of PIVOT(...) FOR column_name IN (ANY) to have hard-coded values.

option 2: disable static analysis

For models with unsupported dynamic SQL:

  1. Add static_analysis = 'off' to the model config:
{{
    config(
        materialized = 'table',
        meta = {
            'static_analysis': 'off'
        }
    )
}}
  1. Or disable static analysis globally for the model in dbt_project.yml

tools-only/X-Skills/tree/main/development/database/323-dynamic_sql_94831248 commit 066129eed8

Frequently asked questions

npx skillmds@latest add tools-only/323-dynamic-sql-94831248