replace file path with original file path

This commit is contained in:
wasilaq
2022-05-12 16:02:22 -04:00
parent e9fe0cbad3
commit 98d2b3b955
7 changed files with 63 additions and 57 deletions

BIN
integration_tests/.DS_Store vendored Normal file

Binary file not shown.

BIN
integration_tests/models/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -7,15 +7,15 @@
{% for node in nodes_list %}
{% set values_line %}
'{{ node.unique_id }}',
'{{ node.name }}',
'{{ node.resource_type }}',
'{{ node.path }}',
cast('{{ is_not_empty_string(node.description) | trim }}'as boolean),
'{{ node.type }}',
'{{ node.maturity}}',
'{{ node.package_name }}',
'{{ node.unique_id }}',
'{{ node.name }}',
'{{ node.resource_type }}',
'{{ node.original_file_path }}',
cast('{{ is_not_empty_string(node.description) | trim }}'as boolean),
'{{ node.type }}',
'{{ node.maturity}}',
'{{ node.package_name }}',
'{{ node.url }}'
{% endset %}

View File

@@ -7,19 +7,19 @@
{% for node in nodes_list %}
{% set values_line %}
'{{ node.unique_id }}',
'{{ node.name }}',
'{{ node.resource_type }}',
'{{ node.path }}',
cast('{{ is_not_empty_string(node.description) | trim }}' as boolean),
'{{ node.type }}',
'{{ node.model.identifier }}',
'{{ node.label }}',
'{{ node.sql }}',
'{{ node.timestamp }}',
'{{ node.unique_id }}',
'{{ node.name }}',
'{{ node.resource_type }}',
'{{ node.original_file_path }}',
cast('{{ is_not_empty_string(node.description) | trim }}' as boolean),
'{{ node.type }}',
'{{ node.model.identifier }}',
'{{ node.label }}',
'{{ node.sql }}',
'{{ node.timestamp }}',
'{{ node.package_name }}'
{% endset %}
{% do values.append(values_line) %}

View File

@@ -7,21 +7,22 @@
{% for node in nodes_list %}
{% set values_line %}
'{{ node.unique_id }}',
'{{ node.name }}',
'{{ node.resource_type }}',
'{{ node.path }}',
cast('{{ node.config.enabled | trim }}' as boolean),
'{{ node.config.materialized }}',
'{{ node.config.on_schema_change}}',
'{{ node.database }}',
'{{ node.schema }}',
'{{ node.package_name }}',
'{{ node.unique_id }}',
'{{ node.name }}',
'{{ node.resource_type }}',
--'{{ node.path }}',
'{{ node.original_file_path }}',
cast('{{ node.config.enabled | trim }}' as boolean),
'{{ node.config.materialized }}',
'{{ node.config.on_schema_change}}',
'{{ node.database }}',
'{{ node.schema }}',
'{{ node.package_name }}',
'{{ node.alias }}',
cast('{{ is_not_empty_string(node.description) | trim }}' as boolean),
'{{ "" if not node.column_name else node.column_name }}'
{% endset %}
{% do values.append(values_line) %}
@@ -32,16 +33,16 @@
select_from_values(
values = values,
column_names = [
'unique_id',
'name',
'resource_type',
'unique_id',
'name',
'resource_type',
'file_path',
'is_enabled',
'materialized',
'on_schema_change',
'database',
'schema',
'package_name',
'is_enabled',
'materialized',
'on_schema_change',
'database',
'schema',
'package_name',
'alias',
'is_described',
'column_name'
@@ -49,4 +50,4 @@
)
) }}
{% endmacro %}
{% endmacro %}

View File

@@ -10,20 +10,20 @@
'{{ node.unique_id }}',
'{{ node.name }}',
'{{ node.path }}',
'{{ node.alias }}',
'{{ node.resource_type }}',
'{{ node.source_name }}',
cast('{{ is_not_empty_string(node.source_description) | trim }}' as boolean),
cast('{{ is_not_empty_string(node.description) | trim }}' as boolean),
cast('{{ node.config.enabled }}' as boolean),
'{{ node.loaded_at_field | replace("'", "_") }}}}',
'{{ node.database }}',
'{{ node.schema }}',
'{{ node.package_name }}',
'{{ node.loader }}',
'{{ node.original_file_path }}',
'{{ node.alias }}',
'{{ node.resource_type }}',
'{{ node.source_name }}',
cast('{{ is_not_empty_string(node.source_description) | trim }}' as boolean),
cast('{{ is_not_empty_string(node.description) | trim }}' as boolean),
cast('{{ node.config.enabled }}' as boolean),
'{{ node.loaded_at_field | replace("'", "_") }}}}',
'{{ node.database }}',
'{{ node.schema }}',
'{{ node.package_name }}',
'{{ node.loader }}',
'{{ node.identifier }}'
{% endset %}
{% do values.append(values_line) %}

View File

@@ -56,7 +56,12 @@ inappropriate_subdirectories_sources as (
inappropriate_subdirectories_staging as (
select distinct -- must do distinct to avoid duplicates when staging model has multiple paths to a given source
child as resource_name,
child_file_path as current_file_path,
case
when {{ dbt_utils.position("'models/'", "child_file_path") }} = 1
then {{ dbt_utils.replace("child_file_path", "'models/'", "''") }}
else child_file_path
end as current_file_path,
'{{ var("staging_folder_name") }}' || '/' || parent_source_name || '/' || child_file_name as change_file_path_to
from staging_models
where child_directory_path not like '%' || parent_source_name || '%'