Skip to content

Commit cf41fca

Browse files
committed
schema tests now work in Dremio too
1 parent e616d80 commit cf41fca

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

integration_tests/tests/test_schema_changes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
("name", "column_removed"),
2323
]
2424

25-
STRING_JINJA = r"{{ 'STRING' if (target.type == 'bigquery' or target.type == 'databricks') else 'character varying' if target.type == 'redshift' else 'TEXT' }}"
25+
STRING_JINJA = r"{{ 'STRING' if (target.type == 'bigquery' or target.type == 'databricks') else 'character varying' if (target.type == 'redshift' or target.type == 'dremio') else 'TEXT' }}"
2626

2727

2828
def assert_test_results(test_results: List[dict]):

macros/edr/system/system_utils/full_names.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@
102102
{% endmacro %}
103103

104104

105+
{% macro dremio__full_name_split(part_name) %}
106+
{%- if part_name == 'database_name' -%}
107+
trim('"' from split_part(full_table_name,'.',1)) as {{ part_name }}
108+
{%- elif part_name == 'schema_name' -%}
109+
trim('"' from substr(full_table_name, length(split_part(full_table_name,'.',1)) + 2,
110+
length(full_table_name) - length(split_part(full_table_name,'.',1)) - length(split_part(full_table_name,'.',length(full_table_name) - length(replace(full_table_name,'.','')) + 1)) - 2)) as {{ part_name }}
111+
{%- elif part_name == 'table_name' -%}
112+
trim('"' from split_part(full_table_name,'.',length(full_table_name) - length(replace(full_table_name,'.','')) + 1)) as {{ part_name }}
113+
{%- else -%}
114+
{{ return('') }}
115+
{%- endif -%}
116+
{% endmacro %}
117+
118+
105119
{% macro relation_to_full_name(relation) %}
106120
{%- if relation.is_cte %}
107121
{# Ephemeral models don't have db and schema #}

macros/utils/cross_db_utils/datetime_to_sql.sql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
{% macro dremio__edr_datetime_to_sql(dt) %}
1010
{% if dt is string %}
11-
{% set dt = modules.datetime.datetime.fromisoformat(dt) %}
11+
{% if 'T' in dt %}
12+
{% set dt = modules.datetime.datetime.fromisoformat(dt) %}
13+
{% else %}
14+
{% do return(elementary.edr_quote(dt)) %}
15+
{% endif %}
1216
{% endif %}
17+
1318
{% do return(elementary.edr_quote(dt.strftime(elementary.get_time_format()))) %}
1419
{% endmacro %}

macros/utils/table_operations/insert_rows.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
{%- if value is number -%}
167167
{{- value -}}
168168
{%- elif value is string and data_type == 'timestamp' -%}
169-
{{- elementary.edr_cast_as_timestamp(elementary.edr_quote(value)) -}}
169+
{{- elementary.edr_cast_as_timestamp(elementary.edr_datetime_to_sql(value)) -}}
170170
{%- elif value is string -%}
171171
'{{- elementary.escape_special_chars(value) -}}'
172172
{%- elif value is mapping or value is sequence -%}

0 commit comments

Comments
 (0)