|
29 | 29 | {% endif %} |
30 | 30 |
|
31 | 31 | {# ── Fallback: compare types-only signatures ── |
32 | | - Snowflake information_schema returns type-only signatures e.g. (VARCHAR) |
33 | | - while dbt parameters may include names and DEFAULT clauses e.g. |
34 | | - "target_timezone VARCHAR DEFAULT 'Pacific/Auckland'". |
| 32 | + Snowflake information_schema may return signatures with param names |
| 33 | + e.g. (TARGET_TIMEZONE VARCHAR) while dbt parameters include names and |
| 34 | + DEFAULT clauses e.g. "target_timezone VARCHAR DEFAULT 'Pacific/Auckland'". |
35 | 35 | Parameters may also contain parenthesised precision e.g. NUMBER(3, 0). |
36 | | - Extract just the types from the dbt side and compare again. #} |
| 36 | + Extract just the types from BOTH sides and compare again. #} |
37 | 37 | {% set dbt_types = [] %} |
38 | 38 | {% set clean_dbt_args = dbt_arguments | trim %} |
39 | 39 | {% if clean_dbt_args | length > 0 %} |
|
45 | 45 | {% endfor %} |
46 | 46 | {% endif %} |
47 | 47 |
|
| 48 | + {# Also extract types-only from the Snowflake side (which may include param names) #} |
| 49 | + {% set sql_types = [] %} |
| 50 | + {% set clean_sql_args = sql_arguments | replace("(", "", 1) %} |
| 51 | + {% if clean_sql_args.endswith(")") %} |
| 52 | + {% set clean_sql_args = clean_sql_args[:-1] %} |
| 53 | + {% endif %} |
| 54 | + {% set clean_sql_args = clean_sql_args | trim %} |
| 55 | + {% if clean_sql_args | length > 0 %} |
| 56 | + {% for param in dbt_dataengineers_utils.split_params(clean_sql_args) %} |
| 57 | + {% set param_type = dbt_dataengineers_utils.extract_param_type(param) %} |
| 58 | + {% if param_type | length > 0 %} |
| 59 | + {% do sql_types.append(param_type) %} |
| 60 | + {% endif %} |
| 61 | + {% endfor %} |
| 62 | + {% endif %} |
| 63 | + |
48 | 64 | {% if name_property == "config.override_name" %} |
49 | 65 | {% set dbt_types_signature = (node.schema ~ "." ~ node_name ~ "(" ~ dbt_types | join(", ") ~ ")") | lower %} |
| 66 | + {% set sql_types_signature = (sql_object_schema ~ "." ~ sql_object_name ~ "(" ~ sql_types | join(", ") ~ ")") | lower %} |
50 | 67 | {% else %} |
51 | 68 | {% set dbt_types_signature = (node.schema ~ "." ~ node.name ~ "(" ~ dbt_types | join(", ") ~ ")") | lower %} |
| 69 | + {% set sql_types_signature = (sql_object_schema ~ "." ~ sql_object_name ~ "(" ~ sql_types | join(", ") ~ ")") | lower %} |
52 | 70 | {% endif %} |
53 | 71 |
|
54 | | - {% if sql_signature == dbt_types_signature %} |
| 72 | + {% if sql_types_signature == dbt_types_signature %} |
55 | 73 | {{ return(true) }} |
56 | 74 | {% endif %} |
57 | 75 | {% endif %} |
|
0 commit comments