From cac27cb673d685af21480e02f23e82cc706dff73 Mon Sep 17 00:00:00 2001 From: Doug Ivey Date: Mon, 16 Dec 2024 17:22:02 +1100 Subject: [PATCH] Case support for Databricks column names - Allows setting case default for Databricks adapter (Matches Fabric Functionality) --- .../internal/metadata_processing/escape_column_names.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/macros/internal/metadata_processing/escape_column_names.sql b/macros/internal/metadata_processing/escape_column_names.sql index 35501b2c..abe77bd8 100644 --- a/macros/internal/metadata_processing/escape_column_names.sql +++ b/macros/internal/metadata_processing/escape_column_names.sql @@ -192,8 +192,13 @@ {%- set escape_char_left = var('escape_char_left', "") -%} {%- set escape_char_right = var('escape_char_right', "") -%} - {%- set escaped_column_name = escape_char_left ~ column | upper | replace(escape_char_left, '') | replace(escape_char_right, '') | trim ~ escape_char_right | indent(4) -%} + {% set set_casing = var('datavault4dbt.set_casing', none) %} + {% if set_casing|lower in ['upper', 'uppercase'] %} + {%- set escaped_column_name = escape_char_left ~ column | upper | replace(escape_char_left, '') | replace(escape_char_right, '') | trim ~ escape_char_right | indent(4) -%} + {% elif set_casing|lower in ['lower', 'lowercase'] %} + {%- set escaped_column_name = escape_char_left ~ column | lower | replace(escape_char_left, '') | replace(escape_char_right, '') | trim ~ escape_char_right | indent(4) -%} + {% endif %} {%- do return(escaped_column_name) -%} -{%- endmacro -%} \ No newline at end of file +{%- endmacro -%}