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

Add macro to allow adapter-specific choice of unspecified value #263

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240715-205845.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Added macro to allow adapter-specific choice of unspecified value in unit tests
time: 2024-07-15T20:58:45.587529+02:00
custom:
Author: steffen030
Issue: "10447"
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,11 @@
{% set formatted = column.column.lower() ~ " " ~ data_type %}
{{ return({'name': column.name, 'data_type': data_type, 'formatted': formatted}) }}
{%- endmacro -%}

{% macro render_unspecified_column_value(column_type) %}
{{ return(adapter.dispatch('render_unspecified_column_value', 'dbt') (column_type)) }}
{% endmacro %}

{% macro default__render_unspecified_column_value(column_type) %}
safe_cast('null', {{column_type}})
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{%- endif -%}

{%- for column_name, column_type in column_name_to_data_types.items() -%}
{%- do default_row.update({column_name: (safe_cast("null", column_type) | trim )}) -%}
{%- do default_row.update({column_name: (render_unspecified_column_value(column_type) | trim )}) -%}
{%- endfor -%}

{{ validate_fixture_rows(rows, row_number) }}
Expand Down
Loading