Compare commits
4 Commits
master
...
sync/track
Author | SHA1 | Date |
---|---|---|
Ubuntu | dec59c30b0 | |
Ubuntu | f1faad9777 | |
Ubuntu | 1604aa8c9c | |
Ubuntu | efe4c71688 |
1
Makefile
1
Makefile
|
@ -7,4 +7,3 @@ run:
|
|||
dbt deps --profiles-dir=. --project-dir=.
|
||||
#dbt run --profiles-dir=. --project-dir=. --full-refresh
|
||||
dbt run --profiles-dir=. --project-dir=. --full-refresh --select tracking_product_shares
|
||||
|
||||
|
|
|
@ -1,45 +1,29 @@
|
|||
# This file is necessary to install dbt-utils with dbt deps
|
||||
# the content will be overwritten by the transform function
|
||||
|
||||
# Name your package! Package names should contain only lowercase characters
|
||||
# and underscores. A good package name should reflect your organization's
|
||||
# name or the intended use of these models
|
||||
name: "airbyte_utils"
|
||||
version: "1.0"
|
||||
name: airbyte_utils
|
||||
version: '1.0'
|
||||
config-version: 2
|
||||
|
||||
# This setting configures which "profile" dbt uses for this project. Profiles contain
|
||||
# database connection information, and should be configured in the ~/.dbt/profiles.yml file
|
||||
profile: "normalize"
|
||||
|
||||
# These configurations specify where dbt should look for different types of files.
|
||||
# The `model-paths` config, for example, states that source models can be found
|
||||
# in the "models/" directory. You probably won't need to change these!
|
||||
model-paths: ["models"]
|
||||
docs-paths: ["docs"]
|
||||
analysis-paths: ["analysis"]
|
||||
test-paths: ["tests"]
|
||||
seed-paths: ["data"]
|
||||
macro-paths: ["macros"]
|
||||
|
||||
target-path: "../build" # directory which will store compiled SQL files
|
||||
log-path: "../logs" # directory which will store DBT logs
|
||||
packages-install-path: "../dbt" # directory which will store external DBT dependencies
|
||||
|
||||
clean-targets: # directories to be removed by `dbt clean`
|
||||
- "build"
|
||||
- "dbt_modules"
|
||||
|
||||
profile: normalize
|
||||
model-paths:
|
||||
- models
|
||||
docs-paths:
|
||||
- docs
|
||||
analysis-paths:
|
||||
- analysis
|
||||
test-paths:
|
||||
- tests
|
||||
seed-paths:
|
||||
- data
|
||||
macro-paths:
|
||||
- macros
|
||||
target-path: ../build
|
||||
log-path: ../logs
|
||||
packages-install-path: ../dbt
|
||||
clean-targets:
|
||||
- build
|
||||
- dbt_modules
|
||||
quoting:
|
||||
database: true
|
||||
# Temporarily disabling the behavior of the ExtendedNameTransformer on table/schema names, see (issue #1785)
|
||||
# all schemas should be unquoted
|
||||
schema: false
|
||||
identifier: true
|
||||
|
||||
# You can define configurations for models in the `model-paths` directory here.
|
||||
# Using these configurations, you can enable or disable models, change how they
|
||||
# are materialized, and more!
|
||||
models:
|
||||
airbyte_utils:
|
||||
+materialized: table
|
||||
|
@ -57,7 +41,15 @@ models:
|
|||
airbyte_views:
|
||||
+tags: airbyte_internal_views
|
||||
+materialized: view
|
||||
|
||||
dispatch:
|
||||
- macro_namespace: dbt_utils
|
||||
search_order: ["airbyte_utils", "dbt_utils"]
|
||||
- macro_namespace: dbt_utils
|
||||
search_order:
|
||||
- airbyte_utils
|
||||
- dbt_utils
|
||||
vars:
|
||||
json_column: _airbyte_data
|
||||
models_to_source:
|
||||
tracking_product_shares_ab1: unibag._airbyte_raw_tracking_product_shares
|
||||
tracking_product_shares_ab2: unibag._airbyte_raw_tracking_product_shares
|
||||
tracking_product_shares_ab3: unibag._airbyte_raw_tracking_product_shares
|
||||
tracking_product_shares: unibag._airbyte_raw_tracking_product_shares
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,14 @@
|
|||
{%- macro redshift_super_type() -%}
|
||||
{%- if not execute -%}
|
||||
{{ return("") }}
|
||||
{%- endif -%}
|
||||
|
||||
{%- set table_schema, _, table_name = var("models_to_source")[this.identifier].partition(".") -%}
|
||||
|
||||
{%- call statement("get_column_type", fetch_result=True) -%}
|
||||
select data_type from SVV_COLUMNS where table_name = '{{ table_name }}' and column_name = '{{ var("json_column") }}' and table_schema = '{{ table_schema }}';
|
||||
{%- endcall -%}
|
||||
|
||||
{%- set column_type = load_result("get_column_type")["data"][0][0] -%}
|
||||
{{ return(column_type == "super") }}
|
||||
{%- endmacro -%}
|
|
@ -104,8 +104,19 @@
|
|||
|
||||
{% macro default__unnest_cte(from_table, stream_name, column_col) -%}{%- endmacro %}
|
||||
|
||||
{# -- based on https://blog.getdbt.com/how-to-unnest-arrays-in-redshift/ #}
|
||||
{% macro redshift__unnest_cte(from_table, stream_name, column_col) -%}
|
||||
|
||||
{# -- based on https://docs.aws.amazon.com/redshift/latest/dg/query-super.html #}
|
||||
{% if redshift_super_type() -%}
|
||||
with joined as (
|
||||
select
|
||||
table_alias._airbyte_{{ stream_name }}_hashid as _airbyte_hashid,
|
||||
_airbyte_nested_data
|
||||
from {{ from_table }} as table_alias, table_alias.{{ column_col }} as _airbyte_nested_data
|
||||
)
|
||||
{%- else -%}
|
||||
|
||||
{# -- based on https://blog.getdbt.com/how-to-unnest-arrays-in-redshift/ #}
|
||||
{%- if not execute -%}
|
||||
{{ return('') }}
|
||||
{% endif %}
|
||||
|
@ -134,6 +145,7 @@ joined as (
|
|||
-- to the number of items in {{ from_table }}.{{ column_col }}
|
||||
where numbers.generated_number <= json_array_length({{ column_col }}, true)
|
||||
)
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro mysql__unnest_cte(from_table, stream_name, column_col) -%}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{% macro redshift__alter_column_type(relation, column_name, new_column_type) -%}
|
||||
|
||||
{%- set tmp_column = column_name + "__dbt_alter" -%}
|
||||
|
||||
{% call statement('alter_column_type') %}
|
||||
alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};
|
||||
{% if new_column_type.lower() == "super" %}
|
||||
update {{ relation }} set {{ adapter.quote(tmp_column) }} = JSON_PARSE({{ adapter.quote(column_name) }});
|
||||
{% else %}
|
||||
update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};
|
||||
{% endif %}
|
||||
alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;
|
||||
alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}
|
||||
{% endcall %}
|
||||
|
||||
{% endmacro %}
|
|
@ -9,7 +9,11 @@
|
|||
{% endmacro %}
|
||||
|
||||
{%- macro redshift__type_json() -%}
|
||||
{%- if redshift_super_type() -%}
|
||||
super
|
||||
{%- else -%}
|
||||
varchar
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{% macro postgres__type_json() %}
|
||||
|
@ -29,7 +33,7 @@
|
|||
{%- endmacro -%}
|
||||
|
||||
{%- macro sqlserver__type_json() -%}
|
||||
VARCHAR(max)
|
||||
NVARCHAR(max)
|
||||
{%- endmacro -%}
|
||||
|
||||
{% macro clickhouse__type_json() %}
|
||||
|
@ -48,7 +52,7 @@
|
|||
{%- endmacro -%}
|
||||
|
||||
{% macro sqlserver__type_string() %}
|
||||
VARCHAR(max)
|
||||
NVARCHAR(max)
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro clickhouse__type_string() -%}
|
||||
|
@ -150,7 +154,7 @@
|
|||
{%- macro sqlserver__type_timestamp_with_timezone() -%}
|
||||
{#-- in TSQL timestamp is really datetime or datetime2 --#}
|
||||
{#-- https://docs.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver15#DateandTimeDataTypes --#}
|
||||
datetime
|
||||
datetime2
|
||||
{%- endmacro -%}
|
||||
|
||||
{% macro clickhouse__type_timestamp_with_timezone() %}
|
||||
|
|
|
@ -43,11 +43,12 @@
|
|||
{%- endmacro %}
|
||||
|
||||
{% macro redshift__format_json_path(json_path_list) -%}
|
||||
{%- set quote = '"' if redshift_super_type() else "'" -%}
|
||||
{%- set str_list = [] -%}
|
||||
{%- for json_path in json_path_list -%}
|
||||
{%- if str_list.append(json_path.replace("'", "''")) -%} {%- endif -%}
|
||||
{%- if str_list.append(json_path.replace(quote, quote + quote)) -%} {%- endif -%}
|
||||
{%- endfor -%}
|
||||
{{ "'" ~ str_list|join("','") ~ "'" }}
|
||||
{{ quote ~ str_list|join(quote + "," + quote) ~ quote }}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro snowflake__format_json_path(json_path_list) -%}
|
||||
|
@ -114,11 +115,14 @@
|
|||
{%- endmacro %}
|
||||
|
||||
{% macro redshift__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%}
|
||||
{%- if from_table|string() == '' %}
|
||||
{%- if from_table|string() != '' -%}
|
||||
{%- set json_column = from_table|string() + "." + json_column|string() -%}
|
||||
{%- endif -%}
|
||||
{%- if redshift_super_type() -%}
|
||||
case when {{ json_column }}.{{ format_json_path(json_path_list) }} != '' then {{ json_column }}.{{ format_json_path(json_path_list) }} end
|
||||
{%- else -%}
|
||||
case when json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true) != '' then json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true) end
|
||||
{% else %}
|
||||
case when json_extract_path_text({{ from_table }}.{{ json_column }}, {{ format_json_path(json_path_list) }}, true) != '' then json_extract_path_text({{ from_table }}.{{ json_column }}, {{ format_json_path(json_path_list) }}, true) end
|
||||
{% endif -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro snowflake__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%}
|
||||
|
@ -168,7 +172,11 @@
|
|||
{%- endmacro %}
|
||||
|
||||
{% macro redshift__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%}
|
||||
{%- if redshift_super_type() -%}
|
||||
case when {{ json_column }}.{{ format_json_path(json_path_list) }} != '' then {{ json_column }}.{{ format_json_path(json_path_list) }} end
|
||||
{%- else -%}
|
||||
case when json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true) != '' then json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true) end
|
||||
{%- endif -%}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro snowflake__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%}
|
||||
|
@ -210,7 +218,11 @@
|
|||
{%- endmacro %}
|
||||
|
||||
{% macro redshift__json_extract_array(json_column, json_path_list, normalized_json_path) -%}
|
||||
{%- if redshift_super_type() -%}
|
||||
{{ json_column }}.{{ format_json_path(json_path_list) }}
|
||||
{%- else -%}
|
||||
json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true)
|
||||
{%- endif -%}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro snowflake__json_extract_array(json_column, json_path_list, normalized_json_path) -%}
|
||||
|
|
|
@ -33,6 +33,31 @@
|
|||
cast({{ array_column }} as {{dbt_utils.type_string()}})
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro redshift__array_to_string(array_column) -%}
|
||||
{% if redshift_super_type() -%}
|
||||
json_serialize({{array_column}})
|
||||
{%- else -%}
|
||||
{{ array_column }}
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{# object_to_string ------------------------------------------------- #}
|
||||
{% macro object_to_string(object_column) -%}
|
||||
{{ adapter.dispatch('object_to_string')(object_column) }}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro default__object_to_string(object_column) -%}
|
||||
{{ object_column }}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro redshift__object_to_string(object_column) -%}
|
||||
{% if redshift_super_type() -%}
|
||||
json_serialize({{object_column}})
|
||||
{%- else -%}
|
||||
{{ object_column }}
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{# cast_to_boolean ------------------------------------------------- #}
|
||||
{% macro cast_to_boolean(field) -%}
|
||||
{{ adapter.dispatch('cast_to_boolean')(field) }}
|
||||
|
@ -49,7 +74,11 @@
|
|||
|
||||
{# -- Redshift does not support converting string directly to boolean, it must go through int first #}
|
||||
{% macro redshift__cast_to_boolean(field) -%}
|
||||
{% if redshift_super_type() -%}
|
||||
cast({{ field }} as boolean)
|
||||
{%- else -%}
|
||||
cast(decode({{ field }}, 'true', '1', 'false', '0')::integer as boolean)
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{# -- MS SQL Server does not support converting string directly to boolean, it must be casted as bit #}
|
||||
|
@ -70,3 +99,7 @@
|
|||
{%- macro default__empty_string_to_null(field) -%}
|
||||
nullif({{ field }}, '')
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro redshift__empty_string_to_null(field) -%}
|
||||
nullif({{ field }}::varchar, '')
|
||||
{%- endmacro %}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_admin_tags') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['color'], ['color']) }} as color,
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_admin_tags') }} as table_alias
|
||||
-- admin_tags
|
||||
where 1 = 1
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('admin_tags_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }},
|
||||
cast(color as {{ dbt_utils.type_string() }}) as color,
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('admin_tags_ab1') }}
|
||||
-- admin_tags
|
||||
where 1 = 1
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('admin_tags_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('name'),
|
||||
adapter.quote('type'),
|
||||
'color',
|
||||
boolean_to_string('active'),
|
||||
'createdat',
|
||||
'updatedat',
|
||||
'searchstring',
|
||||
]) }} as _airbyte_admin_tags_hashid,
|
||||
tmp.*
|
||||
from {{ ref('admin_tags_ab2') }} tmp
|
||||
-- admin_tags
|
||||
where 1 = 1
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_cash_flows') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['hash'], ['hash']) }} as hash,
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['value'], ['value']) }} as {{ adapter.quote('value') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['action'], ['action']) }} as {{ adapter.quote('action') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['category'], ['category']) }} as category,
|
||||
{{ json_extract_scalar('_airbyte_data', ['targetId'], ['targetId']) }} as targetid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isAudited'], ['isAudited']) }} as isaudited,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['newBalance'], ['newBalance']) }} as newbalance,
|
||||
{{ json_extract_scalar('_airbyte_data', ['oldBalance'], ['oldBalance']) }} as oldbalance,
|
||||
{{ json_extract_scalar('_airbyte_data', ['targetType'], ['targetType']) }} as targettype,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isProcessed'], ['isProcessed']) }} as isprocessed,
|
||||
{{ json_extract_scalar('_airbyte_data', ['processStatus'], ['processStatus']) }} as processstatus,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_cash_flows') }} as table_alias
|
||||
-- cash_flows
|
||||
where 1 = 1
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('cash_flows_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(hash as {{ dbt_utils.type_string() }}) as hash,
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast({{ adapter.quote('value') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('value') }},
|
||||
cast({{ adapter.quote('action') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('action') }},
|
||||
cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }},
|
||||
cast(category as {{ dbt_utils.type_string() }}) as category,
|
||||
cast(targetid as {{ dbt_utils.type_string() }}) as targetid,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
{{ cast_to_boolean('isaudited') }} as isaudited,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(newbalance as {{ dbt_utils.type_float() }}) as newbalance,
|
||||
cast(oldbalance as {{ dbt_utils.type_float() }}) as oldbalance,
|
||||
cast(targettype as {{ dbt_utils.type_string() }}) as targettype,
|
||||
{{ cast_to_boolean('isprocessed') }} as isprocessed,
|
||||
cast(processstatus as {{ dbt_utils.type_string() }}) as processstatus,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('cash_flows_ab1') }}
|
||||
-- cash_flows
|
||||
where 1 = 1
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('cash_flows_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'hash',
|
||||
adapter.quote('user'),
|
||||
adapter.quote('value'),
|
||||
adapter.quote('action'),
|
||||
adapter.quote('options'),
|
||||
'category',
|
||||
'targetid',
|
||||
'createdat',
|
||||
boolean_to_string('isaudited'),
|
||||
'updatedat',
|
||||
'newbalance',
|
||||
'oldbalance',
|
||||
'targettype',
|
||||
boolean_to_string('isprocessed'),
|
||||
'processstatus',
|
||||
]) }} as _airbyte_cash_flows_hashid,
|
||||
tmp.*
|
||||
from {{ ref('cash_flows_ab2') }} tmp
|
||||
-- cash_flows
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_cities') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['slug'], ['slug']) }} as slug,
|
||||
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['tncId'], ['tncId']) }} as tncid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['region'], ['region']) }} as region,
|
||||
{{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['tempId'], ['tempId']) }} as tempid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['tncCode'], ['tncCode']) }} as tnccode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['osirisId'], ['osirisId']) }} as osirisid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_cities') }} as table_alias
|
||||
-- cities
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('cities_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(code as {{ dbt_utils.type_float() }}) as code,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast(slug as {{ dbt_utils.type_string() }}) as slug,
|
||||
cast({{ adapter.quote('order') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('order') }},
|
||||
cast(tncid as {{ dbt_utils.type_float() }}) as tncid,
|
||||
cast(region as {{ dbt_utils.type_string() }}) as region,
|
||||
cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }},
|
||||
cast(tempid as {{ dbt_utils.type_float() }}) as tempid,
|
||||
cast(tnccode as {{ dbt_utils.type_string() }}) as tnccode,
|
||||
cast(osirisid as {{ dbt_utils.type_float() }}) as osirisid,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('cities_ab1') }}
|
||||
-- cities
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('cities_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'code',
|
||||
adapter.quote('name'),
|
||||
'slug',
|
||||
adapter.quote('order'),
|
||||
'tncid',
|
||||
'region',
|
||||
adapter.quote('source'),
|
||||
'tempid',
|
||||
'tnccode',
|
||||
'osirisid',
|
||||
'updatedat',
|
||||
'searchstring',
|
||||
]) }} as _airbyte_cities_hashid,
|
||||
tmp.*
|
||||
from {{ ref('cities_ab2') }} tmp
|
||||
-- cities
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_customers') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['info'], ['info']) }} as info,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['email'], ['email']) }} as email,
|
||||
{{ json_extract_scalar('_airbyte_data', ['phone'], ['phone']) }} as phone,
|
||||
{{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }},
|
||||
{{ json_extract_array('_airbyte_data', ['location'], ['location']) }} as {{ adapter.quote('location') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isDeleted'], ['isDeleted']) }} as isdeleted,
|
||||
{{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_customers') }} as table_alias
|
||||
-- customers
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('customers_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(info as {{ dbt_utils.type_string() }}) as info,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast(email as {{ dbt_utils.type_string() }}) as email,
|
||||
cast(phone as {{ dbt_utils.type_string() }}) as phone,
|
||||
cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }},
|
||||
{{ adapter.quote('location') }},
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
{{ cast_to_boolean('isdeleted') }} as isdeleted,
|
||||
cast(statistic as {{ dbt_utils.type_string() }}) as statistic,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('customers_ab1') }}
|
||||
-- customers
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('customers_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'info',
|
||||
adapter.quote('name'),
|
||||
adapter.quote('user'),
|
||||
'email',
|
||||
'phone',
|
||||
adapter.quote('source'),
|
||||
array_to_string(adapter.quote('location')),
|
||||
'createdat',
|
||||
boolean_to_string('isdeleted'),
|
||||
'statistic',
|
||||
'updatedat',
|
||||
'searchstring',
|
||||
]) }} as _airbyte_customers_hashid,
|
||||
tmp.*
|
||||
from {{ ref('customers_ab2') }} tmp
|
||||
-- customers
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_districts') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['city'], ['city']) }} as city,
|
||||
{{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['slug'], ['slug']) }} as slug,
|
||||
{{ json_extract_scalar('_airbyte_data', ['tncId'], ['tncId']) }} as tncid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['cityId'], ['cityId']) }} as cityid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['tncCode'], ['tncCode']) }} as tnccode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['gidoCode'], ['gidoCode']) }} as gidocode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['osirisId'], ['osirisId']) }} as osirisid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_districts') }} as table_alias
|
||||
-- districts
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('districts_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(city as {{ dbt_utils.type_string() }}) as city,
|
||||
cast(code as {{ dbt_utils.type_float() }}) as code,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast(slug as {{ dbt_utils.type_string() }}) as slug,
|
||||
cast(tncid as {{ dbt_utils.type_float() }}) as tncid,
|
||||
cast(cityid as {{ dbt_utils.type_float() }}) as cityid,
|
||||
cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }},
|
||||
cast(tnccode as {{ dbt_utils.type_string() }}) as tnccode,
|
||||
cast(gidocode as {{ dbt_utils.type_float() }}) as gidocode,
|
||||
cast(osirisid as {{ dbt_utils.type_float() }}) as osirisid,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('districts_ab1') }}
|
||||
-- districts
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('districts_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'city',
|
||||
'code',
|
||||
adapter.quote('name'),
|
||||
'slug',
|
||||
'tncid',
|
||||
'cityid',
|
||||
adapter.quote('source'),
|
||||
'tnccode',
|
||||
'gidocode',
|
||||
'osirisid',
|
||||
'updatedat',
|
||||
'searchstring',
|
||||
]) }} as _airbyte_districts_hashid,
|
||||
tmp.*
|
||||
from {{ ref('districts_ab2') }} tmp
|
||||
-- districts
|
||||
where 1 = 1
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_event_rewards') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['cash'], ['cash']) }} as cash,
|
||||
{{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['event'], ['event']) }} as {{ adapter.quote('event') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedat'], ['updatedat']) }} as updatedat,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_event_rewards') }} as table_alias
|
||||
-- event_rewards
|
||||
where 1 = 1
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('event_rewards_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(cash as {{ dbt_utils.type_float() }}) as cash,
|
||||
cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }},
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast({{ adapter.quote('event') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('event') }},
|
||||
cast(status as {{ dbt_utils.type_string() }}) as status,
|
||||
cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }},
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('event_rewards_ab1') }}
|
||||
-- event_rewards
|
||||
where 1 = 1
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('event_rewards_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'cash',
|
||||
adapter.quote('type'),
|
||||
adapter.quote('user'),
|
||||
adapter.quote('event'),
|
||||
'status',
|
||||
adapter.quote('options'),
|
||||
'createdat',
|
||||
'updatedat',
|
||||
]) }} as _airbyte_event_rewards_hashid,
|
||||
tmp.*
|
||||
from {{ ref('event_rewards_ab2') }} tmp
|
||||
-- event_rewards
|
||||
where 1 = 1
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_events') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['desc'], ['desc']) }} as {{ adapter.quote('desc') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['icon'], ['icon']) }} as icon,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['cover'], ['cover']) }} as cover,
|
||||
{{ json_extract_scalar('_airbyte_data', ['endAt'], ['endAt']) }} as endat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['notice'], ['notice']) }} as notice,
|
||||
{{ json_extract_scalar('_airbyte_data', ['screen'], ['screen']) }} as screen,
|
||||
{{ json_extract_scalar('_airbyte_data', ['article'], ['article']) }} as article,
|
||||
{{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['startAt'], ['startAt']) }} as startat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['segments'], ['segments']) }} as segments,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['groupType'], ['groupType']) }} as grouptype,
|
||||
{{ json_extract_array('_airbyte_data', ['suppliers'], ['suppliers']) }} as suppliers,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_array('_airbyte_data', ['information'], ['information']) }} as information,
|
||||
{{ json_extract_scalar('_airbyte_data', ['displayEndAt'], ['displayEndAt']) }} as displayendat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isApplyForAll'], ['isApplyForAll']) }} as isapplyforall,
|
||||
{{ json_extract_scalar('_airbyte_data', ['displayStartAt'], ['displayStartAt']) }} as displaystartat,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_events') }} as table_alias
|
||||
-- events
|
||||
where 1 = 1
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('events_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('desc') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('desc') }},
|
||||
cast(icon as {{ dbt_utils.type_string() }}) as icon,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }},
|
||||
cast(cover as {{ dbt_utils.type_string() }}) as cover,
|
||||
cast(endat as {{ dbt_utils.type_string() }}) as endat,
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
cast(notice as {{ dbt_utils.type_string() }}) as notice,
|
||||
cast(screen as {{ dbt_utils.type_string() }}) as screen,
|
||||
cast(article as {{ dbt_utils.type_string() }}) as article,
|
||||
cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }},
|
||||
cast(startat as {{ dbt_utils.type_string() }}) as startat,
|
||||
cast(segments as {{ dbt_utils.type_string() }}) as segments,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(grouptype as {{ dbt_utils.type_string() }}) as grouptype,
|
||||
suppliers,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
information,
|
||||
cast(displayendat as {{ dbt_utils.type_string() }}) as displayendat,
|
||||
{{ cast_to_boolean('isapplyforall') }} as isapplyforall,
|
||||
cast(displaystartat as {{ dbt_utils.type_string() }}) as displaystartat,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('events_ab1') }}
|
||||
-- events
|
||||
where 1 = 1
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('events_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('desc'),
|
||||
'icon',
|
||||
adapter.quote('name'),
|
||||
adapter.quote('type'),
|
||||
'cover',
|
||||
'endat',
|
||||
boolean_to_string('active'),
|
||||
'notice',
|
||||
'screen',
|
||||
'article',
|
||||
adapter.quote('options'),
|
||||
'startat',
|
||||
'segments',
|
||||
'createdat',
|
||||
'grouptype',
|
||||
array_to_string('suppliers'),
|
||||
'updatedat',
|
||||
array_to_string('information'),
|
||||
'displayendat',
|
||||
boolean_to_string('isapplyforall'),
|
||||
'displaystartat',
|
||||
]) }} as _airbyte_events_hashid,
|
||||
tmp.*
|
||||
from {{ ref('events_ab2') }} tmp
|
||||
-- events
|
||||
where 1 = 1
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_inventories') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['id'], ['id']) }} as {{ adapter.quote('id') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['slug'], ['slug']) }} as slug,
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['contact'], ['contact']) }} as contact,
|
||||
{{ json_extract_scalar('_airbyte_data', ['partner'], ['partner']) }} as partner,
|
||||
{{ json_extract_scalar('_airbyte_data', ['checksum'], ['checksum']) }} as checksum,
|
||||
{{ json_extract_scalar('_airbyte_data', ['location'], ['location']) }} as {{ adapter.quote('location') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['supplier'], ['supplier']) }} as supplier,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['minimumValue'], ['minimumValue']) }} as minimumvalue,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_scalar('_airbyte_data', ['paymentMethods'], ['paymentMethods']) }} as paymentmethods,
|
||||
{{ json_extract_scalar('_airbyte_data', ['canIssueInvoice'], ['canIssueInvoice']) }} as canissueinvoice,
|
||||
{{ json_extract_array('_airbyte_data', ['deliveryMethods'], ['deliveryMethods']) }} as deliverymethods,
|
||||
{{ json_extract_scalar('_airbyte_data', ['canAutoSendEmail'], ['canAutoSendEmail']) }} as canautosendemail,
|
||||
{{ json_extract_scalar('_airbyte_data', ['invoiceDeliveryMethod'], ['invoiceDeliveryMethod']) }} as invoicedeliverymethod,
|
||||
{{ json_extract_scalar('_airbyte_data', ['doesSupportSellyExpress'], ['doesSupportSellyExpress']) }} as doessupportsellyexpress,
|
||||
{{ json_extract_array('_airbyte_data', ['priorityDeliveryServiceCodes'], ['priorityDeliveryServiceCodes']) }} as prioritydeliveryservicecodes,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_inventories') }} as table_alias
|
||||
-- inventories
|
||||
where 1 = 1
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('inventories_ab1') }}
|
||||
select
|
||||
cast({{ adapter.quote('id') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('id') }},
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(code as {{ dbt_utils.type_float() }}) as code,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast(slug as {{ dbt_utils.type_string() }}) as slug,
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
cast(contact as {{ dbt_utils.type_string() }}) as contact,
|
||||
cast(partner as {{ dbt_utils.type_string() }}) as partner,
|
||||
cast(checksum as {{ dbt_utils.type_string() }}) as checksum,
|
||||
cast({{ adapter.quote('location') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('location') }},
|
||||
cast(supplier as {{ dbt_utils.type_string() }}) as supplier,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(minimumvalue as {{ dbt_utils.type_float() }}) as minimumvalue,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
cast(paymentmethods as {{ dbt_utils.type_string() }}) as paymentmethods,
|
||||
{{ cast_to_boolean('canissueinvoice') }} as canissueinvoice,
|
||||
deliverymethods,
|
||||
{{ cast_to_boolean('canautosendemail') }} as canautosendemail,
|
||||
cast(invoicedeliverymethod as {{ dbt_utils.type_string() }}) as invoicedeliverymethod,
|
||||
{{ cast_to_boolean('doessupportsellyexpress') }} as doessupportsellyexpress,
|
||||
prioritydeliveryservicecodes,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('inventories_ab1') }}
|
||||
-- inventories
|
||||
where 1 = 1
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('inventories_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
adapter.quote('id'),
|
||||
'_id',
|
||||
'code',
|
||||
adapter.quote('name'),
|
||||
'slug',
|
||||
boolean_to_string('active'),
|
||||
'contact',
|
||||
'partner',
|
||||
'checksum',
|
||||
adapter.quote('location'),
|
||||
'supplier',
|
||||
'createdat',
|
||||
'updatedat',
|
||||
'minimumvalue',
|
||||
'searchstring',
|
||||
'paymentmethods',
|
||||
boolean_to_string('canissueinvoice'),
|
||||
array_to_string('deliverymethods'),
|
||||
boolean_to_string('canautosendemail'),
|
||||
'invoicedeliverymethod',
|
||||
boolean_to_string('doessupportsellyexpress'),
|
||||
array_to_string('prioritydeliveryservicecodes'),
|
||||
]) }} as _airbyte_inventories_hashid,
|
||||
tmp.*
|
||||
from {{ ref('inventories_ab2') }} tmp
|
||||
-- inventories
|
||||
where 1 = 1
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_membership') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['color'], ['color']) }} as color,
|
||||
{{ json_extract_scalar('_airbyte_data', ['guide'], ['guide']) }} as guide,
|
||||
{{ json_extract_scalar('_airbyte_data', ['level'], ['level']) }} as {{ adapter.quote('level') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['sales'], ['sales']) }} as sales,
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedat'], ['updatedat']) }} as updatedat_1,
|
||||
{{ json_extract_scalar('_airbyte_data', ['transaction'], ['transaction']) }} as {{ adapter.quote('transaction') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['bonusPercent'], ['bonusPercent']) }} as bonuspercent,
|
||||
{{ json_extract_scalar('_airbyte_data', ['bonuspercent'], ['bonuspercent']) }} as bonuspercent_1,
|
||||
{{ json_extract_scalar('_airbyte_data', ['transactionMinValue'], ['transactionMinValue']) }} as transactionminvalue,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_membership') }} as table_alias
|
||||
-- membership
|
||||
where 1 = 1
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('membership_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast(color as {{ dbt_utils.type_string() }}) as color,
|
||||
cast(guide as {{ dbt_utils.type_string() }}) as guide,
|
||||
cast({{ adapter.quote('level') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('level') }},
|
||||
cast(sales as {{ dbt_utils.type_float() }}) as sales,
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(updatedat_1 as {{ dbt_utils.type_string() }}) as updatedat_1,
|
||||
cast({{ adapter.quote('transaction') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('transaction') }},
|
||||
cast(bonuspercent as {{ dbt_utils.type_float() }}) as bonuspercent,
|
||||
cast(bonuspercent_1 as {{ dbt_utils.type_float() }}) as bonuspercent_1,
|
||||
cast(transactionminvalue as {{ dbt_utils.type_float() }}) as transactionminvalue,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('membership_ab1') }}
|
||||
-- membership
|
||||
where 1 = 1
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('membership_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('name'),
|
||||
'color',
|
||||
'guide',
|
||||
adapter.quote('level'),
|
||||
'sales',
|
||||
boolean_to_string('active'),
|
||||
'createdat',
|
||||
'updatedat',
|
||||
'updatedat_1',
|
||||
adapter.quote('transaction'),
|
||||
'bonuspercent',
|
||||
'bonuspercent_1',
|
||||
'transactionminvalue',
|
||||
]) }} as _airbyte_membership_hashid,
|
||||
tmp.*
|
||||
from {{ ref('membership_ab2') }} tmp
|
||||
-- membership
|
||||
where 1 = 1
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_membership_histories') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['new'], ['new']) }} as {{ adapter.quote('new') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['old'], ['old']) }} as {{ adapter.quote('old') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_membership_histories') }} as table_alias
|
||||
-- membership_histories
|
||||
where 1 = 1
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('membership_histories_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('new') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('new') }},
|
||||
cast({{ adapter.quote('old') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('old') }},
|
||||
cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }},
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('membership_histories_ab1') }}
|
||||
-- membership_histories
|
||||
where 1 = 1
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('membership_histories_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('new'),
|
||||
adapter.quote('old'),
|
||||
adapter.quote('type'),
|
||||
adapter.quote('user'),
|
||||
'createdat',
|
||||
]) }} as _airbyte_membership_histories_hashid,
|
||||
tmp.*
|
||||
from {{ ref('membership_histories_ab2') }} tmp
|
||||
-- membership_histories
|
||||
where 1 = 1
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_membership_orders') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_scalar('_airbyte_data', ['percent'], ['percent']) }} as {{ adapter.quote('percent') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['targetID'], ['targetID']) }} as targetid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['commission'], ['commission']) }} as commission,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isRejected'], ['isRejected']) }} as isrejected,
|
||||
{{ json_extract_scalar('_airbyte_data', ['membershipName'], ['membershipName']) }} as membershipname,
|
||||
{{ json_extract_scalar('_airbyte_data', ['membershipLevel'], ['membershipLevel']) }} as membershiplevel,
|
||||
{{ json_extract_scalar('_airbyte_data', ['membershipPromotion'], ['membershipPromotion']) }} as membershippromotion,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_membership_orders') }} as table_alias
|
||||
-- membership_orders
|
||||
where 1 = 1
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('membership_orders_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast(status as {{ dbt_utils.type_string() }}) as status,
|
||||
cast({{ adapter.quote('percent') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('percent') }},
|
||||
cast(targetid as {{ dbt_utils.type_string() }}) as targetid,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(commission as {{ dbt_utils.type_float() }}) as commission,
|
||||
{{ cast_to_boolean('isrejected') }} as isrejected,
|
||||
cast(membershipname as {{ dbt_utils.type_string() }}) as membershipname,
|
||||
cast(membershiplevel as {{ dbt_utils.type_float() }}) as membershiplevel,
|
||||
cast({{ adapter.quote('membershippromotion') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('membershippromotion') }},
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('membership_orders_ab1') }}
|
||||
-- membership_orders
|
||||
where 1 = 1
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('membership_orders_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('user'),
|
||||
'status',
|
||||
adapter.quote('percent'),
|
||||
'targetid',
|
||||
'createdat',
|
||||
'updatedat',
|
||||
'commission',
|
||||
boolean_to_string('isrejected'),
|
||||
'membershipname',
|
||||
'membershiplevel',
|
||||
'membershippromotion'
|
||||
]) }} as _airbyte_membership_orders_hashid,
|
||||
tmp.*
|
||||
from {{ ref('membership_orders_ab2') }} tmp
|
||||
-- membership_orders
|
||||
where 1 = 1
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_order_deliveries') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code,
|
||||
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['title'], ['title']) }} as title,
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_scalar('_airbyte_data', ['service'], ['service']) }} as service,
|
||||
{{ json_extract_scalar('_airbyte_data', ['customer'], ['customer']) }} as customer,
|
||||
{{ json_extract_scalar('_airbyte_data', ['delivery'], ['delivery']) }} as delivery,
|
||||
{{ json_extract_scalar('_airbyte_data', ['location'], ['location']) }} as {{ adapter.quote('location') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['promotion'], ['promotion']) }} as promotion,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['trackingCode'], ['trackingCode']) }} as trackingcode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['trackingTime'], ['trackingTime']) }} as trackingtime,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isAdminChange'], ['isAdminChange']) }} as isadminchange,
|
||||
{{ json_extract_scalar('_airbyte_data', ['trackingOrderCode'], ['trackingOrderCode']) }} as trackingordercode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['weight'], ['weight']) }} as weight,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_order_deliveries') }} as table_alias
|
||||
-- order_deliveries
|
||||
where 1 = 1
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('order_deliveries_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(code as {{ dbt_utils.type_string() }}) as code,
|
||||
cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }},
|
||||
cast(title as {{ dbt_utils.type_string() }}) as title,
|
||||
cast(status as {{ dbt_utils.type_string() }}) as status,
|
||||
cast(service as {{ dbt_utils.type_string() }}) as service,
|
||||
cast(customer as {{ dbt_utils.type_string() }}) as customer,
|
||||
cast(delivery as {{ dbt_utils.type_string() }}) as delivery,
|
||||
cast({{ adapter.quote('location') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('location') }},
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(promotion as {{ dbt_utils.type_string() }}) as promotion,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(trackingcode as {{ dbt_utils.type_string() }}) as trackingcode,
|
||||
cast(trackingtime as {{ dbt_utils.type_string() }}) as trackingtime,
|
||||
{{ cast_to_boolean('isadminchange') }} as isadminchange,
|
||||
cast(trackingordercode as {{ dbt_utils.type_string() }}) as trackingordercode,
|
||||
cast(weight as {{ dbt_utils.type_string() }}) as weight,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('order_deliveries_ab1') }}
|
||||
-- order_deliveries
|
||||
where 1 = 1
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('order_deliveries_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'code',
|
||||
adapter.quote('order'),
|
||||
'title',
|
||||
'status',
|
||||
'service',
|
||||
'customer',
|
||||
'delivery',
|
||||
adapter.quote('location'),
|
||||
'createdat',
|
||||
'promotion',
|
||||
'updatedat',
|
||||
'trackingcode',
|
||||
'trackingtime',
|
||||
boolean_to_string('isadminchange'),
|
||||
'trackingordercode',
|
||||
'weight',
|
||||
]) }} as _airbyte_order_deliveries_hashid,
|
||||
tmp.*
|
||||
from {{ ref('order_deliveries_ab2') }} tmp
|
||||
-- order_deliveries
|
||||
where 1 = 1
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_order_histories') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['timestamp'], ['timestamp']) }} as {{ adapter.quote('timestamp') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_order_histories') }} as table_alias
|
||||
-- order_histories
|
||||
where 1 = 1
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('order_histories_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }},
|
||||
cast(status as {{ dbt_utils.type_string() }}) as status,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast({{ adapter.quote('timestamp') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('timestamp') }},
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('order_histories_ab1') }}
|
||||
-- order_histories
|
||||
where 1 = 1
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('order_histories_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('order'),
|
||||
'status',
|
||||
'createdat',
|
||||
adapter.quote('timestamp'),
|
||||
'updatedat',
|
||||
]) }} as _airbyte_order_histories_hashid,
|
||||
tmp.*
|
||||
from {{ ref('order_histories_ab2') }} tmp
|
||||
-- order_histories
|
||||
where 1 = 1
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_order_items') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['sku'], ['sku']) }} as sku,
|
||||
{{ json_extract_scalar('_airbyte_data', ['date'], ['date']) }} as {{ adapter.quote('date') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['brand'], ['brand']) }} as brand,
|
||||
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price,
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_scalar('_airbyte_data', ['teamId'], ['teamId']) }} as teamid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['product'], ['product']) }} as product,
|
||||
{{ json_extract_scalar('_airbyte_data', ['voucher'], ['voucher']) }} as voucher,
|
||||
{{ json_extract_scalar('_airbyte_data', ['customer'], ['customer']) }} as customer,
|
||||
{{ json_extract_scalar('_airbyte_data', ['quantity'], ['quantity']) }} as quantity,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['inventory'], ['inventory']) }} as inventory,
|
||||
{{ json_extract_scalar('_airbyte_data', ['totalSell'], ['totalSell']) }} as totalsell,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['cashbackAt'], ['cashbackAt']) }} as cashbackat,
|
||||
{{ json_extract_array('_airbyte_data', ['promotions'], ['promotions']) }} as promotions,
|
||||
{{ json_extract_scalar('_airbyte_data', ['totalPrice'], ['totalPrice']) }} as totalprice,
|
||||
{{ json_extract_scalar('_airbyte_data', ['deliveredAt'], ['deliveredAt']) }} as deliveredat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['teamMemberId'], ['teamMemberId']) }} as teammemberid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isAssignCoupon'], ['isAssignCoupon']) }} as isassigncoupon,
|
||||
{{ json_extract_scalar('_airbyte_data', ['totalPromotion'], ['totalPromotion']) }} as totalpromotion,
|
||||
{{ json_extract_scalar('_airbyte_data', ['inWholesaleRange'], ['inWholesaleRange']) }} as inwholesalerange,
|
||||
{{ json_extract_scalar('_airbyte_data', ['voucherCashTotal'], ['voucherCashTotal']) }} as vouchercashtotal,
|
||||
{{ json_extract_scalar('_airbyte_data', ['wholesaleRangeId'], ['wholesaleRangeId']) }} as wholesalerangeid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['totalWholesaleBonus'], ['totalWholesaleBonus']) }} as totalwholesalebonus,
|
||||
{{ json_extract_scalar('_airbyte_data', ['totalSellyWholesaleBonus'], ['totalSellyWholesaleBonus']) }} as totalsellywholesalebonus,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_order_items') }} as table_alias
|
||||
-- order_items
|
||||
where 1 = 1
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('order_items_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(sku as {{ dbt_utils.type_string() }}) as sku,
|
||||
cast({{ adapter.quote('date') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('date') }},
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast(brand as {{ dbt_utils.type_string() }}) as brand,
|
||||
cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }},
|
||||
cast(price as {{ dbt_utils.type_string() }}) as price,
|
||||
cast(status as {{ dbt_utils.type_string() }}) as status,
|
||||
cast(teamid as {{ dbt_utils.type_string() }}) as teamid,
|
||||
cast(product as {{ dbt_utils.type_string() }}) as product,
|
||||
cast(voucher as {{ dbt_utils.type_string() }}) as voucher,
|
||||
cast(customer as {{ dbt_utils.type_string() }}) as customer,
|
||||
cast(quantity as {{ dbt_utils.type_float() }}) as quantity,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(inventory as {{ dbt_utils.type_string() }}) as inventory,
|
||||
cast(totalsell as {{ dbt_utils.type_float() }}) as totalsell,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(cashbackat as {{ dbt_utils.type_string() }}) as cashbackat,
|
||||
promotions,
|
||||
cast(totalprice as {{ dbt_utils.type_float() }}) as totalprice,
|
||||
cast(deliveredat as {{ dbt_utils.type_string() }}) as deliveredat,
|
||||
cast(teammemberid as {{ dbt_utils.type_string() }}) as teammemberid,
|
||||
{{ cast_to_boolean('isassigncoupon') }} as isassigncoupon,
|
||||
cast(totalpromotion as {{ dbt_utils.type_float() }}) as totalpromotion,
|
||||
{{ cast_to_boolean('inwholesalerange') }} as inwholesalerange,
|
||||
cast(vouchercashtotal as {{ dbt_utils.type_float() }}) as vouchercashtotal,
|
||||
cast(wholesalerangeid as {{ dbt_utils.type_string() }}) as wholesalerangeid,
|
||||
cast(totalwholesalebonus as {{ dbt_utils.type_float() }}) as totalwholesalebonus,
|
||||
cast(totalsellywholesalebonus as {{ dbt_utils.type_float() }}) as totalsellywholesalebonus,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('order_items_ab1') }}
|
||||
-- order_items
|
||||
where 1 = 1
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('order_items_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'sku',
|
||||
adapter.quote('date'),
|
||||
adapter.quote('user'),
|
||||
'brand',
|
||||
adapter.quote('order'),
|
||||
'price',
|
||||
'status',
|
||||
'teamid',
|
||||
'product',
|
||||
'voucher',
|
||||
'customer',
|
||||
'quantity',
|
||||
'createdat',
|
||||
'inventory',
|
||||
'totalsell',
|
||||
'updatedat',
|
||||
'cashbackat',
|
||||
array_to_string('promotions'),
|
||||
'totalprice',
|
||||
'deliveredat',
|
||||
'teammemberid',
|
||||
boolean_to_string('isassigncoupon'),
|
||||
'totalpromotion',
|
||||
boolean_to_string('inwholesalerange'),
|
||||
'vouchercashtotal',
|
||||
'wholesalerangeid',
|
||||
'totalwholesalebonus',
|
||||
'totalsellywholesalebonus',
|
||||
]) }} as _airbyte_order_items_hashid,
|
||||
tmp.*
|
||||
from {{ ref('order_items_ab2') }} tmp
|
||||
-- order_items
|
||||
where 1 = 1
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_orders') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code,
|
||||
{{ json_extract_scalar('_airbyte_data', ['date'], ['date']) }} as {{ adapter.quote('date') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['hour'], ['hour']) }} as {{ adapter.quote('hour') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['note'], ['note']) }} as note,
|
||||
{{ json_extract_array('_airbyte_data', ['tags'], ['tags']) }} as tags,
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price,
|
||||
{{ json_extract_scalar('_airbyte_data', ['banned'], ['banned']) }} as banned,
|
||||
{{ json_extract_scalar('_airbyte_data', ['reason'], ['reason']) }} as reason,
|
||||
{{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_scalar('_airbyte_data', ['teamId'], ['teamId']) }} as teamid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['payment'], ['payment']) }} as payment,
|
||||
{{ json_extract_scalar('_airbyte_data', ['remarks'], ['remarks']) }} as remarks,
|
||||
{{ json_extract_scalar('_airbyte_data', ['customer'], ['customer']) }} as customer,
|
||||
{{ json_extract_scalar('_airbyte_data', ['delivery'], ['delivery']) }} as delivery,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isCalled'], ['isCalled']) }} as iscalled,
|
||||
{{ json_extract_scalar('_airbyte_data', ['merchant'], ['merchant']) }} as merchant,
|
||||
{{ json_extract_scalar('_airbyte_data', ['pickupAt'], ['pickupAt']) }} as pickupat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['supplier'], ['supplier']) }} as supplier,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['inventory'], ['inventory']) }} as inventory,
|
||||
{{ json_extract_scalar('_airbyte_data', ['invoiceId'], ['invoiceId']) }} as invoiceid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isDeleted'], ['isDeleted']) }} as isdeleted,
|
||||
{{ json_extract_scalar('_airbyte_data', ['promotion'], ['promotion']) }} as promotion,
|
||||
{{ json_extract_scalar('_airbyte_data', ['requestId'], ['requestId']) }} as requestid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['restockAt'], ['restockAt']) }} as restockat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['sendEmail'], ['sendEmail']) }} as sendemail,
|
||||
{{ json_extract_scalar('_airbyte_data', ['totalItem'], ['totalItem']) }} as totalitem,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['userAgent'], ['userAgent']) }} as useragent,
|
||||
{{ json_extract_scalar('_airbyte_data', ['wholesale'], ['wholesale']) }} as wholesale,
|
||||
{{ json_extract_scalar('_airbyte_data', ['approvedAt'], ['approvedAt']) }} as approvedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['cashbackAt'], ['cashbackAt']) }} as cashbackat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isPreorder'], ['isPreorder']) }} as ispreorder,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isReviewed'], ['isReviewed']) }} as isreviewed,
|
||||
{{ json_extract_scalar('_airbyte_data', ['rejectedAt'], ['rejectedAt']) }} as rejectedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['deliveredAt'], ['deliveredAt']) }} as deliveredat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['deliveringAt'], ['deliveringAt']) }} as deliveringat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['deliveryCode'], ['deliveryCode']) }} as deliverycode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_scalar('_airbyte_data', ['staffApprove'], ['staffApprove']) }} as staffapprove,
|
||||
{{ json_extract_scalar('_airbyte_data', ['teamMemberId'], ['teamMemberId']) }} as teammemberid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['processStatus'], ['processStatus']) }} as processstatus,
|
||||
{{ json_extract_scalar('_airbyte_data', ['hookTimeLastAt'], ['hookTimeLastAt']) }} as hooktimelastat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isAssignCoupon'], ['isAssignCoupon']) }} as isassigncoupon,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isAutoApproved'], ['isAutoApproved']) }} as isautoapproved,
|
||||
{{ json_extract_scalar('_airbyte_data', ['outboundRequest'], ['outboundRequest']) }} as outboundrequest,
|
||||
{{ json_extract_scalar('_airbyte_data', ['trackingCodeURL'], ['trackingCodeURL']) }} as trackingcodeurl,
|
||||
{{ json_extract_scalar('_airbyte_data', ['trackingCode'], ['trackingcode']) }} as trackingCode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['waitingCancelBy'], ['waitingCancelBy']) }} as waitingcancelby,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isChangeDelivery'], ['isChangeDelivery']) }} as ischangedelivery,
|
||||
{{ json_extract_scalar('_airbyte_data', ['estimateCashbackAt'], ['estimateCashbackAt']) }} as estimatecashbackat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['fromNewActiveBuyer'], ['fromNewActiveBuyer']) }} as fromnewactivebuyer,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isWaitingCancelled'], ['isWaitingCancelled']) }} as iswaitingcancelled,
|
||||
{{ json_extract_scalar('_airbyte_data', ['fromNewActiveSeller'], ['fromNewActiveSeller']) }} as fromnewactiveseller,
|
||||
{{ json_extract_scalar('_airbyte_data', ['waitingCancelReason'], ['waitingCancelReason']) }} as waitingcancelreason,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_orders') }} as table_alias
|
||||
-- orders
|
||||
where 1 = 1
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('orders_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(code as {{ dbt_utils.type_string() }}) as code,
|
||||
cast({{ adapter.quote('date') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('date') }},
|
||||
cast({{ adapter.quote('hour') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('hour') }},
|
||||
cast(note as {{ dbt_utils.type_string() }}) as note,
|
||||
tags,
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast(price as {{ dbt_utils.type_string() }}) as price,
|
||||
{{ cast_to_boolean('banned') }} as banned,
|
||||
cast(reason as {{ dbt_utils.type_string() }}) as reason,
|
||||
cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }},
|
||||
cast(status as {{ dbt_utils.type_string() }}) as status,
|
||||
cast(teamid as {{ dbt_utils.type_string() }}) as teamid,
|
||||
cast(payment as {{ dbt_utils.type_string() }}) as payment,
|
||||
cast(remarks as {{ dbt_utils.type_string() }}) as remarks,
|
||||
cast(customer as {{ dbt_utils.type_string() }}) as customer,
|
||||
cast(delivery as {{ dbt_utils.type_string() }}) as delivery,
|
||||
{{ cast_to_boolean('iscalled') }} as iscalled,
|
||||
cast(merchant as {{ dbt_utils.type_string() }}) as merchant,
|
||||
cast(pickupat as {{ dbt_utils.type_string() }}) as pickupat,
|
||||
cast(supplier as {{ dbt_utils.type_string() }}) as supplier,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(inventory as {{ dbt_utils.type_string() }}) as inventory,
|
||||
cast(invoiceid as {{ dbt_utils.type_string() }}) as invoiceid,
|
||||
{{ cast_to_boolean('isdeleted') }} as isdeleted,
|
||||
cast(promotion as {{ dbt_utils.type_string() }}) as promotion,
|
||||
cast(requestid as {{ dbt_utils.type_string() }}) as requestid,
|
||||
cast(restockat as {{ dbt_utils.type_string() }}) as restockat,
|
||||
cast(sendemail as {{ dbt_utils.type_string() }}) as sendemail,
|
||||
cast(totalitem as {{ dbt_utils.type_float() }}) as totalitem,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(useragent as {{ dbt_utils.type_string() }}) as useragent,
|
||||
{{ cast_to_boolean('wholesale') }} as wholesale,
|
||||
cast(approvedat as {{ dbt_utils.type_string() }}) as approvedat,
|
||||
cast(cashbackat as {{ dbt_utils.type_string() }}) as cashbackat,
|
||||
{{ cast_to_boolean('ispreorder') }} as ispreorder,
|
||||
{{ cast_to_boolean('isreviewed') }} as isreviewed,
|
||||
cast(rejectedat as {{ dbt_utils.type_string() }}) as rejectedat,
|
||||
cast(deliveredat as {{ dbt_utils.type_string() }}) as deliveredat,
|
||||
cast(deliveringat as {{ dbt_utils.type_string() }}) as deliveringat,
|
||||
cast(deliverycode as {{ dbt_utils.type_string() }}) as deliverycode,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
cast(staffapprove as {{ dbt_utils.type_string() }}) as staffapprove,
|
||||
cast(teammemberid as {{ dbt_utils.type_string() }}) as teammemberid,
|
||||
cast(processstatus as {{ dbt_utils.type_string() }}) as processstatus,
|
||||
cast(hooktimelastat as {{ dbt_utils.type_string() }}) as hooktimelastat,
|
||||
{{ cast_to_boolean('isassigncoupon') }} as isassigncoupon,
|
||||
{{ cast_to_boolean('isautoapproved') }} as isautoapproved,
|
||||
cast(outboundrequest as {{ dbt_utils.type_string() }}) as outboundrequest,
|
||||
cast(trackingcodeurl as {{ dbt_utils.type_string() }}) as trackingcodeurl,
|
||||
cast(trackingcode as {{ dbt_utils.type_string() }}) as trackingcode,
|
||||
cast(waitingcancelby as {{ dbt_utils.type_string() }}) as waitingcancelby,
|
||||
{{ cast_to_boolean('ischangedelivery') }} as ischangedelivery,
|
||||
cast(estimatecashbackat as {{ dbt_utils.type_string() }}) as estimatecashbackat,
|
||||
{{ cast_to_boolean('fromnewactivebuyer') }} as fromnewactivebuyer,
|
||||
{{ cast_to_boolean('iswaitingcancelled') }} as iswaitingcancelled,
|
||||
{{ cast_to_boolean('fromnewactiveseller') }} as fromnewactiveseller,
|
||||
cast(waitingcancelreason as {{ dbt_utils.type_string() }}) as waitingcancelreason,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('orders_ab1') }}
|
||||
-- orders
|
||||
where 1 = 1
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('orders_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'code',
|
||||
adapter.quote('date'),
|
||||
adapter.quote('hour'),
|
||||
'note',
|
||||
array_to_string('tags'),
|
||||
adapter.quote('user'),
|
||||
'price',
|
||||
boolean_to_string('banned'),
|
||||
'reason',
|
||||
adapter.quote('source'),
|
||||
'status',
|
||||
'teamid',
|
||||
'payment',
|
||||
'remarks',
|
||||
'customer',
|
||||
'delivery',
|
||||
boolean_to_string('iscalled'),
|
||||
'merchant',
|
||||
'pickupat',
|
||||
'supplier',
|
||||
'createdat',
|
||||
'inventory',
|
||||
'invoiceid',
|
||||
boolean_to_string('isdeleted'),
|
||||
'promotion',
|
||||
'requestid',
|
||||
'restockat',
|
||||
'sendemail',
|
||||
'totalitem',
|
||||
'updatedat',
|
||||
'useragent',
|
||||
boolean_to_string('wholesale'),
|
||||
'approvedat',
|
||||
'cashbackat',
|
||||
boolean_to_string('ispreorder'),
|
||||
boolean_to_string('isreviewed'),
|
||||
'rejectedat',
|
||||
'deliveredat',
|
||||
'deliveringat',
|
||||
'deliverycode',
|
||||
'searchstring',
|
||||
'staffapprove',
|
||||
'teammemberid',
|
||||
'processstatus',
|
||||
'hooktimelastat',
|
||||
boolean_to_string('isassigncoupon'),
|
||||
boolean_to_string('isautoapproved'),
|
||||
'outboundrequest',
|
||||
'trackingcodeurl',
|
||||
'trackingcode',
|
||||
'waitingcancelby',
|
||||
boolean_to_string('ischangedelivery'),
|
||||
'estimatecashbackat',
|
||||
boolean_to_string('fromnewactivebuyer'),
|
||||
boolean_to_string('iswaitingcancelled'),
|
||||
boolean_to_string('fromnewactiveseller'),
|
||||
'waitingcancelreason',
|
||||
]) }} as _airbyte_orders_hashid,
|
||||
tmp.*
|
||||
from {{ ref('orders_ab2') }} tmp
|
||||
-- orders
|
||||
where 1 = 1
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_product_categories') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['icon'], ['icon']) }} as icon,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['color'], ['color']) }} as color,
|
||||
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_array('_airbyte_data', ['covers'], ['covers']) }} as covers,
|
||||
{{ json_extract_scalar('_airbyte_data', ['featured'], ['featured']) }} as featured,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['totalProduct'], ['totalProduct']) }} as totalproduct,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_product_categories') }} as table_alias
|
||||
-- product_categories
|
||||
where 1 = 1
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('product_categories_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(icon as {{ dbt_utils.type_string() }}) as icon,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast(color as {{ dbt_utils.type_string() }}) as color,
|
||||
cast({{ adapter.quote('order') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('order') }},
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
covers,
|
||||
{{ cast_to_boolean('featured') }} as featured,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(totalproduct as {{ dbt_utils.type_float() }}) as totalproduct,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('product_categories_ab1') }}
|
||||
-- product_categories
|
||||
where 1 = 1
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('product_categories_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'icon',
|
||||
adapter.quote('name'),
|
||||
'color',
|
||||
adapter.quote('order'),
|
||||
boolean_to_string('active'),
|
||||
array_to_string('covers'),
|
||||
boolean_to_string('featured'),
|
||||
'createdat',
|
||||
'updatedat',
|
||||
'totalproduct',
|
||||
]) }} as _airbyte_product_categories_hashid,
|
||||
tmp.*
|
||||
from {{ ref('product_categories_ab2') }} tmp
|
||||
-- product_categories
|
||||
where 1 = 1
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_product_sku') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['sku'], ['sku']) }} as sku,
|
||||
{{ json_extract_scalar('_airbyte_data', ['info'], ['info']) }} as info,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['brand'], ['brand']) }} as brand,
|
||||
{{ json_extract_scalar('_airbyte_data', ['cover'], ['cover']) }} as cover,
|
||||
{{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price,
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['author'], ['author']) }} as author,
|
||||
{{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['display'], ['display']) }} as display,
|
||||
{{ json_extract_scalar('_airbyte_data', ['picture'], ['picture']) }} as picture,
|
||||
{{ json_extract_scalar('_airbyte_data', ['product'], ['product']) }} as product,
|
||||
{{ json_extract_scalar('_airbyte_data', ['version'], ['version']) }} as {{ adapter.quote('version') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['groupSku'], ['groupSku']) }} as groupsku,
|
||||
{{ json_extract_scalar('_airbyte_data', ['unitCode'], ['unitCode']) }} as unitcode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['restockAt'], ['restockAt']) }} as restockat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['couponInfo'], ['couponInfo']) }} as couponinfo,
|
||||
{{ json_extract_array('_airbyte_data', ['properties'], ['properties']) }} as properties,
|
||||
{{ json_extract_scalar('_airbyte_data', ['canPreorder'], ['canPreorder']) }} as canpreorder,
|
||||
{{ json_extract_scalar('_airbyte_data', ['supplierSku'], ['supplierSku']) }} as suppliersku,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isOutOfStock'], ['isOutOfStock']) }} as isoutofstock,
|
||||
{{ json_extract_scalar('_airbyte_data', ['pricePercent'], ['pricePercent']) }} as pricepercent,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_scalar('_airbyte_data', ['quantity'], ['quantity']) }} as quantity,
|
||||
{{ json_extract_scalar('_airbyte_data', ['displayInventory'], ['displayInventory']) }} as displayinventory,
|
||||
{{ json_extract_scalar('_airbyte_data', ['showRemainingQuantity'], ['showRemainingQuantity']) }} as showremainingquantity,
|
||||
{{ json_extract_scalar('_airbyte_data', ['quantity_aibyte_transform'], ['quantity_aibyte_transform']) }} as quantity_aibyte_transform,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_product_sku') }} as table_alias
|
||||
-- product_sku
|
||||
where 1 = 1
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('product_sku_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(sku as {{ dbt_utils.type_string() }}) as sku,
|
||||
cast(info as {{ dbt_utils.type_string() }}) as info,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }},
|
||||
cast(brand as {{ dbt_utils.type_string() }}) as brand,
|
||||
cast(cover as {{ dbt_utils.type_string() }}) as cover,
|
||||
cast(price as {{ dbt_utils.type_string() }}) as price,
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
cast(author as {{ dbt_utils.type_string() }}) as author,
|
||||
cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }},
|
||||
{{ cast_to_boolean('display') }} as display,
|
||||
cast(picture as {{ dbt_utils.type_string() }}) as picture,
|
||||
cast(product as {{ dbt_utils.type_string() }}) as product,
|
||||
cast({{ adapter.quote('version') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('version') }},
|
||||
cast(groupsku as {{ dbt_utils.type_string() }}) as groupsku,
|
||||
cast(unitcode as {{ dbt_utils.type_string() }}) as unitcode,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(restockat as {{ dbt_utils.type_string() }}) as restockat,
|
||||
cast(statistic as {{ dbt_utils.type_string() }}) as statistic,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(couponinfo as {{ dbt_utils.type_string() }}) as couponinfo,
|
||||
properties,
|
||||
{{ cast_to_boolean('canpreorder') }} as canpreorder,
|
||||
cast(suppliersku as {{ dbt_utils.type_string() }}) as suppliersku,
|
||||
{{ cast_to_boolean('isoutofstock') }} as isoutofstock,
|
||||
cast(pricepercent as {{ dbt_utils.type_string() }}) as pricepercent,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
{{ cast_to_boolean('displayinventory') }} as displayinventory,
|
||||
{{ cast_to_boolean('showremainingquantity') }} as showremainingquantity,
|
||||
cast(quantity as {{ dbt_utils.type_string() }}) as quantity,
|
||||
cast(quantity_aibyte_transform as {{ dbt_utils.type_string() }}) as quantity_aibyte_transform,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('product_sku_ab1') }}
|
||||
-- product_sku
|
||||
where 1 = 1
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('product_sku_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'sku',
|
||||
'info',
|
||||
adapter.quote('name'),
|
||||
adapter.quote('type'),
|
||||
'brand',
|
||||
'cover',
|
||||
'price',
|
||||
boolean_to_string('active'),
|
||||
'author',
|
||||
adapter.quote('source'),
|
||||
boolean_to_string('display'),
|
||||
'picture',
|
||||
'product',
|
||||
adapter.quote('version'),
|
||||
'groupsku',
|
||||
'unitcode',
|
||||
'createdat',
|
||||
'restockat',
|
||||
'statistic',
|
||||
'updatedat',
|
||||
'couponinfo',
|
||||
array_to_string('properties'),
|
||||
boolean_to_string('canpreorder'),
|
||||
'suppliersku',
|
||||
boolean_to_string('isoutofstock'),
|
||||
'pricepercent',
|
||||
'searchstring',
|
||||
'quantity',
|
||||
boolean_to_string('displayinventory'),
|
||||
boolean_to_string('showremainingquantity'),
|
||||
'quantity_aibyte_transform',
|
||||
]) }} as _airbyte_product_sku_hashid,
|
||||
tmp.*
|
||||
from {{ ref('product_sku_ab2') }} tmp
|
||||
-- product_sku
|
||||
where 1 = 1
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_product_sku_versions') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['sku'], ['sku']) }} as sku,
|
||||
{{ json_extract_scalar('_airbyte_data', ['info'], ['info']) }} as info,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price,
|
||||
{{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['codeSku'], ['codeSku']) }} as codesku,
|
||||
{{ json_extract_scalar('_airbyte_data', ['picture'], ['picture']) }} as picture,
|
||||
{{ json_extract_scalar('_airbyte_data', ['product'], ['product']) }} as product,
|
||||
{{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['version'], ['version']) }} as {{ adapter.quote('version') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_array('_airbyte_data', ['properties'], ['properties']) }} as properties,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_product_sku_versions') }} as table_alias
|
||||
-- product_sku_versions
|
||||
where 1 = 1
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('product_sku_versions_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(sku as {{ dbt_utils.type_string() }}) as sku,
|
||||
cast(info as {{ dbt_utils.type_string() }}) as info,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast(price as {{ dbt_utils.type_string() }}) as price,
|
||||
cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }},
|
||||
cast(codesku as {{ dbt_utils.type_string() }}) as codesku,
|
||||
cast(picture as {{ dbt_utils.type_string() }}) as picture,
|
||||
cast(product as {{ dbt_utils.type_string() }}) as product,
|
||||
cast({{ adapter.quote('version') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('version') }},
|
||||
cast(statistic as {{ dbt_utils.type_string() }}) as statistic,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
properties,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('product_sku_versions_ab1') }}
|
||||
-- product_sku_versions
|
||||
where 1 = 1
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('product_sku_versions_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'sku',
|
||||
'info',
|
||||
adapter.quote('name'),
|
||||
'price',
|
||||
adapter.quote('source'),
|
||||
'codesku',
|
||||
'picture',
|
||||
'product',
|
||||
'statistic',
|
||||
adapter.quote('version'),
|
||||
'createdat',
|
||||
'updatedat',
|
||||
array_to_string('properties'),
|
||||
]) }} as _airbyte_product_sku_versions_hashid,
|
||||
tmp.*
|
||||
from {{ ref('product_sku_versions_ab2') }} tmp
|
||||
-- product_sku_versions
|
||||
where 1 = 1
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_product_sub_categories') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['parent'], ['parent']) }} as parent,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_scalar('_airbyte_data', ['totalProduct'], ['totalProduct']) }} as totalproduct,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_product_sub_categories') }} as table_alias
|
||||
-- product_sub_categories
|
||||
where 1 = 1
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('product_sub_categories_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast({{ adapter.quote('order') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('order') }},
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
cast(parent as {{ dbt_utils.type_string() }}) as parent,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
cast(totalproduct as {{ dbt_utils.type_float() }}) as totalproduct,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('product_sub_categories_ab1') }}
|
||||
-- product_sub_categories
|
||||
where 1 = 1
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('product_sub_categories_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('name'),
|
||||
adapter.quote('order'),
|
||||
boolean_to_string('active'),
|
||||
'parent',
|
||||
'createdat',
|
||||
'updatedat',
|
||||
'searchstring',
|
||||
'totalproduct',
|
||||
]) }} as _airbyte_product_sub_categories_hashid,
|
||||
tmp.*
|
||||
from {{ ref('product_sub_categories_ab2') }} tmp
|
||||
-- product_sub_categories
|
||||
where 1 = 1
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_products') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['desc'], ['desc']) }} as {{ adapter.quote('desc') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['info'], ['info']) }} as info,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['temp'], ['temp']) }} as {{ adapter.quote('temp') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['brand'], ['brand']) }} as brand,
|
||||
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price,
|
||||
{{ json_extract_scalar('_airbyte_data', ['score'], ['score']) }} as score,
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['author'], ['author']) }} as author,
|
||||
{{ json_extract_array('_airbyte_data', ['guides'], ['guides']) }} as guides,
|
||||
{{ json_extract_array('_airbyte_data', ['photos'], ['photos']) }} as photos,
|
||||
{{ json_extract_array('_airbyte_data', ['videos'], ['videos']) }} as videos,
|
||||
{{ json_extract_scalar('_airbyte_data', ['quantity'], ['quantity']) }} as quantity,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_array('_airbyte_data', ['documents'], ['documents']) }} as documents,
|
||||
{{ json_extract_scalar('_airbyte_data', ['shareDesc'], ['shareDesc']) }} as sharedesc,
|
||||
{{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_array('_airbyte_data', ['categories'], ['categories']) }} as categories,
|
||||
{{ json_extract_array('_airbyte_data', ['properties'], ['properties']) }} as properties,
|
||||
{{ json_extract_scalar('_airbyte_data', ['reActiveAt'], ['reActiveAt']) }} as reactiveat,
|
||||
{{ json_extract_array('_airbyte_data', ['inventories'], ['inventories']) }} as inventories,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isOutOfStock'], ['isOutOfStock']) }} as isoutofstock,
|
||||
{{ json_extract_scalar('_airbyte_data', ['pricePercent'], ['pricePercent']) }} as pricepercent,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_array('_airbyte_data', ['subCategories'], ['subCategories']) }} as subcategories,
|
||||
{{ json_extract_scalar('_airbyte_data', ['inactiveReason'], ['inactiveReason']) }} as inactivereason,
|
||||
{{ json_extract_scalar('_airbyte_data', ['propertiesMain'], ['propertiesMain']) }} as propertiesmain,
|
||||
{{ json_extract_scalar('_airbyte_data', ['shareStatistic'], ['shareStatistic']) }} as sharestatistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['canIssueInvoice'], ['canIssueInvoice']) }} as canissueinvoice,
|
||||
{{ json_extract_scalar('_airbyte_data', ['pendingInactive'], ['pendingInactive']) }} as pendinginactive,
|
||||
{{ json_extract_scalar('_airbyte_data', ['reviewStatistic'], ['reviewStatistic']) }} as reviewstatistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['pendingInactiveAt'], ['pendingInactiveAt']) }} as pendinginactiveat,
|
||||
{{ json_extract_array('_airbyte_data', ['highlightProperties'], ['highlightProperties']) }} as highlightproperties,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_products') }} as table_alias
|
||||
-- products
|
||||
where 1 = 1
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('products_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('desc') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('desc') }},
|
||||
cast(info as {{ dbt_utils.type_string() }}) as info,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast({{ adapter.quote('temp') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('temp') }},
|
||||
cast(brand as {{ dbt_utils.type_string() }}) as brand,
|
||||
cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }},
|
||||
cast(price as {{ dbt_utils.type_string() }}) as price,
|
||||
cast(score as {{ dbt_utils.type_string() }}) as score,
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
cast(author as {{ dbt_utils.type_string() }}) as author,
|
||||
guides,
|
||||
photos,
|
||||
videos,
|
||||
cast(quantity as {{ dbt_utils.type_float() }}) as quantity,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
documents,
|
||||
cast(sharedesc as {{ dbt_utils.type_string() }}) as sharedesc,
|
||||
cast(statistic as {{ dbt_utils.type_string() }}) as statistic,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
categories,
|
||||
properties,
|
||||
cast(reactiveat as {{ dbt_utils.type_string() }}) as reactiveat,
|
||||
inventories,
|
||||
{{ cast_to_boolean('isoutofstock') }} as isoutofstock,
|
||||
cast(pricepercent as {{ dbt_utils.type_string() }}) as pricepercent,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
subcategories,
|
||||
cast(inactivereason as {{ dbt_utils.type_string() }}) as inactivereason,
|
||||
cast(propertiesmain as {{ dbt_utils.type_string() }}) as propertiesmain,
|
||||
cast(sharestatistic as {{ dbt_utils.type_string() }}) as sharestatistic,
|
||||
{{ cast_to_boolean('canissueinvoice') }} as canissueinvoice,
|
||||
{{ cast_to_boolean('pendinginactive') }} as pendinginactive,
|
||||
cast(reviewstatistic as {{ dbt_utils.type_string() }}) as reviewstatistic,
|
||||
cast(pendinginactiveat as {{ dbt_utils.type_string() }}) as pendinginactiveat,
|
||||
highlightproperties,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('products_ab1') }}
|
||||
-- products
|
||||
where 1 = 1
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('products_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('desc'),
|
||||
'info',
|
||||
adapter.quote('name'),
|
||||
adapter.quote('temp'),
|
||||
'brand',
|
||||
adapter.quote('order'),
|
||||
'price',
|
||||
'score',
|
||||
boolean_to_string('active'),
|
||||
'author',
|
||||
array_to_string('guides'),
|
||||
array_to_string('photos'),
|
||||
array_to_string('videos'),
|
||||
'quantity',
|
||||
'createdat',
|
||||
array_to_string('documents'),
|
||||
'sharedesc',
|
||||
'statistic',
|
||||
'updatedat',
|
||||
array_to_string('categories'),
|
||||
array_to_string('properties'),
|
||||
'reactiveat',
|
||||
array_to_string('inventories'),
|
||||
boolean_to_string('isoutofstock'),
|
||||
'pricepercent',
|
||||
'searchstring',
|
||||
array_to_string('subcategories'),
|
||||
'inactivereason',
|
||||
'propertiesmain',
|
||||
'sharestatistic',
|
||||
boolean_to_string('canissueinvoice'),
|
||||
boolean_to_string('pendinginactive'),
|
||||
'reviewstatistic',
|
||||
'pendinginactiveat',
|
||||
array_to_string('highlightproperties'),
|
||||
]) }} as _airbyte_products_hashid,
|
||||
tmp.*
|
||||
from {{ ref('products_ab2') }} tmp
|
||||
-- products
|
||||
where 1 = 1
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_promotion_orders') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['title'], ['title']) }} as title,
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_scalar('_airbyte_data', ['supplier'], ['supplier']) }} as supplier,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['promotion'], ['promotion']) }} as promotion,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['cashbackAt'], ['cashbackAt']) }} as cashbackat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['commission'], ['commission']) }} as commission,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isRejected'], ['isRejected']) }} as isrejected,
|
||||
{{ json_extract_scalar('_airbyte_data', ['quantityPromotion'], ['quantityPromotion']) }} as quantitypromotion,
|
||||
{{ json_extract_scalar('_airbyte_data', ['supplierCommission'], ['supplierCommission']) }} as suppliercommission,
|
||||
{{ json_extract_scalar('_airbyte_data', ['supplierCommissionTotal'], ['supplierCommissionTotal']) }} as suppliercommissiontotal,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_promotion_orders') }} as table_alias
|
||||
-- promotion_orders
|
||||
where 1 = 1
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('promotion_orders_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }},
|
||||
cast(title as {{ dbt_utils.type_string() }}) as title,
|
||||
cast(status as {{ dbt_utils.type_string() }}) as status,
|
||||
cast(supplier as {{ dbt_utils.type_string() }}) as supplier,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(promotion as {{ dbt_utils.type_string() }}) as promotion,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(cashbackat as {{ dbt_utils.type_string() }}) as cashbackat,
|
||||
cast(commission as {{ dbt_utils.type_float() }}) as commission,
|
||||
{{ cast_to_boolean('isrejected') }} as isrejected,
|
||||
cast(quantitypromotion as {{ dbt_utils.type_float() }}) as quantitypromotion,
|
||||
cast(supplierCommission as {{ dbt_utils.type_string() }}) as supplierCommission,
|
||||
cast(supplierCommissionTotal as {{ dbt_utils.type_float() }}) as supplierCommissionTotal,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('promotion_orders_ab1') }}
|
||||
-- promotion_orders
|
||||
where 1 = 1
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('promotion_orders_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('user'),
|
||||
adapter.quote('order'),
|
||||
'title',
|
||||
'status',
|
||||
'supplier',
|
||||
'createdat',
|
||||
'promotion',
|
||||
'updatedat',
|
||||
'cashbackat',
|
||||
'commission',
|
||||
boolean_to_string('isrejected'),
|
||||
'quantitypromotion',
|
||||
'supplierCommission',
|
||||
'supplierCommissionTotal',
|
||||
]) }} as _airbyte_promotion_orders_hashid,
|
||||
tmp.*
|
||||
from {{ ref('promotion_orders_ab2') }} tmp
|
||||
-- promotion_orders
|
||||
where 1 = 1
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_promotions') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['rest'], ['rest']) }} as rest,
|
||||
{{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['endAt'], ['endAt']) }} as endat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['title'], ['title']) }} as title,
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['startAt'], ['startAt']) }} as startat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['applyFor'], ['applyFor']) }} as applyfor,
|
||||
{{ json_extract_scalar('_airbyte_data', ['quantity'], ['quantity']) }} as quantity,
|
||||
{{ json_extract_scalar('_airbyte_data', ['articleID'], ['articleID']) }} as articleid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_scalar('_airbyte_data', ['sharePercent'], ['sharePercent']) }} as sharepercent,
|
||||
{{ json_extract_scalar('_airbyte_data', ['conditionForUser'], ['conditionForUser']) }} as conditionforuser,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isUnlimitedQuantity'], ['isUnlimitedQuantity']) }} as isunlimitedquantity,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isApplyForOrderWholesale'], ['isApplyForOrderWholesale']) }} as isapplyfororderwholesale,
|
||||
{{ json_extract_scalar('_airbyte_data', ['supplierCommission'], ['supplierCommission']) }} as suppliercommission,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_promotions') }} as table_alias
|
||||
-- promotions
|
||||
where 1 = 1
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('promotions_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(rest as {{ dbt_utils.type_float() }}) as rest,
|
||||
cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }},
|
||||
cast(endat as {{ dbt_utils.type_string() }}) as endat,
|
||||
cast(title as {{ dbt_utils.type_string() }}) as title,
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }},
|
||||
cast(startat as {{ dbt_utils.type_string() }}) as startat,
|
||||
cast(applyfor as {{ dbt_utils.type_string() }}) as applyfor,
|
||||
cast(quantity as {{ dbt_utils.type_float() }}) as quantity,
|
||||
cast(articleid as {{ dbt_utils.type_string() }}) as articleid,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
cast(sharepercent as {{ dbt_utils.type_string() }}) as sharepercent,
|
||||
cast(conditionforuser as {{ dbt_utils.type_string() }}) as conditionforuser,
|
||||
{{ cast_to_boolean('isunlimitedquantity') }} as isunlimitedquantity,
|
||||
{{ cast_to_boolean('isapplyfororderwholesale') }} as isapplyfororderwholesale,
|
||||
cast(supplierCommission as {{ dbt_utils.type_string() }}) as supplierCommission,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('promotions_ab1') }}
|
||||
-- promotions
|
||||
where 1 = 1
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('promotions_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'rest',
|
||||
adapter.quote('type'),
|
||||
'endat',
|
||||
'title',
|
||||
boolean_to_string('active'),
|
||||
adapter.quote('options'),
|
||||
'startat',
|
||||
'applyfor',
|
||||
'quantity',
|
||||
'articleid',
|
||||
'createdat',
|
||||
'updatedat',
|
||||
'searchstring',
|
||||
'sharepercent',
|
||||
'conditionforuser',
|
||||
boolean_to_string('isunlimitedquantity'),
|
||||
boolean_to_string('isapplyfororderwholesale'),
|
||||
'supplierCommission',
|
||||
]) }} as _airbyte_promotions_hashid,
|
||||
tmp.*
|
||||
from {{ ref('promotions_ab2') }} tmp
|
||||
-- promotions
|
||||
where 1 = 1
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_referrals') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['invitee'], ['invitee']) }} as invitee,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['fromSystem'], ['fromSystem']) }} as fromsystem,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_referrals') }} as table_alias
|
||||
-- referrals
|
||||
where 1 = 1
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('referrals_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast(invitee as {{ dbt_utils.type_string() }}) as invitee,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
{{ cast_to_boolean('fromsystem') }} as fromsystem,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('referrals_ab1') }}
|
||||
-- referrals
|
||||
where 1 = 1
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('referrals_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('user'),
|
||||
'invitee',
|
||||
'createdat',
|
||||
boolean_to_string('fromsystem'),
|
||||
]) }} as _airbyte_referrals_hashid,
|
||||
tmp.*
|
||||
from {{ ref('referrals_ab2') }} tmp
|
||||
-- referrals
|
||||
where 1 = 1
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_social_post_views') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['clientIP'], ['clientIP']) }} as clientip,
|
||||
{{ json_extract_scalar('_airbyte_data', ['lastViewAt'], ['lastViewAt']) }} as lastviewat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['socialPost'], ['socialPost']) }} as socialpost,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_social_post_views') }} as table_alias
|
||||
-- social_post_views
|
||||
where 1 = 1
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('social_post_views_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast(clientip as {{ dbt_utils.type_string() }}) as clientip,
|
||||
cast(lastviewat as {{ dbt_utils.type_string() }}) as lastviewat,
|
||||
cast(socialpost as {{ dbt_utils.type_string() }}) as socialpost,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('social_post_views_ab1') }}
|
||||
-- social_post_views
|
||||
where 1 = 1
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('social_post_views_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('user'),
|
||||
'clientip',
|
||||
'lastviewat',
|
||||
'socialpost',
|
||||
]) }} as _airbyte_social_post_views_hashid,
|
||||
tmp.*
|
||||
from {{ ref('social_post_views_ab2') }} tmp
|
||||
-- social_post_views
|
||||
where 1 = 1
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_social_posts') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_array('_airbyte_data', ['tags'], ['tags']) }} as tags,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isPin'], ['isPin']) }} as ispin,
|
||||
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['title'], ['title']) }} as title,
|
||||
{{ json_extract_scalar('_airbyte_data', ['author'], ['author']) }} as author,
|
||||
{{ json_extract_array('_airbyte_data', ['cities'], ['cities']) }} as cities,
|
||||
{{ json_extract_array('_airbyte_data', ['photos'], ['photos']) }} as photos,
|
||||
{{ json_extract_scalar('_airbyte_data', ['reason'], ['reason']) }} as reason,
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_array('_airbyte_data', ['videos'], ['videos']) }} as videos,
|
||||
{{ json_extract_scalar('_airbyte_data', ['content'], ['content']) }} as {{ adapter.quote('content') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['isTimer'], ['isTimer']) }} as istimer,
|
||||
{{ json_extract_scalar('_airbyte_data', ['startAt'], ['startAt']) }} as startat,
|
||||
{{ json_extract_array('_airbyte_data', ['products'], ['products']) }} as products,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['hasUpdate'], ['hasUpdate']) }} as hasupdate,
|
||||
{{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_array('_airbyte_data', ['categories'], ['categories']) }} as categories,
|
||||
{{ json_extract_scalar('_airbyte_data', ['fromSystem'], ['fromSystem']) }} as fromsystem,
|
||||
{{ json_extract_scalar('_airbyte_data', ['contributor'], ['contributor']) }} as contributor,
|
||||
{{ json_extract_scalar('_airbyte_data', ['publishedAt'], ['publishedAt']) }} as publishedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedCount'], ['updatedCount']) }} as updatedcount,
|
||||
{{ json_extract_scalar('_airbyte_data', ['shareStatistic'], ['shareStatistic']) }} as sharestatistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['enableNotificationForContributor'], ['enableNotificationForContributor']) }} as enablenotificationforcontributor,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_social_posts') }} as table_alias
|
||||
-- social_posts
|
||||
where 1 = 1
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('social_posts_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
tags,
|
||||
{{ cast_to_boolean('ispin') }} as ispin,
|
||||
cast({{ adapter.quote('order') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('order') }},
|
||||
cast(title as {{ dbt_utils.type_string() }}) as title,
|
||||
cast(author as {{ dbt_utils.type_string() }}) as author,
|
||||
cities,
|
||||
photos,
|
||||
cast(reason as {{ dbt_utils.type_string() }}) as reason,
|
||||
cast(status as {{ dbt_utils.type_string() }}) as status,
|
||||
videos,
|
||||
cast({{ adapter.quote('content') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('content') }},
|
||||
{{ cast_to_boolean('istimer') }} as istimer,
|
||||
cast(startat as {{ dbt_utils.type_string() }}) as startat,
|
||||
products,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
{{ cast_to_boolean('hasupdate') }} as hasupdate,
|
||||
cast(statistic as {{ dbt_utils.type_string() }}) as statistic,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
categories,
|
||||
{{ cast_to_boolean('fromsystem') }} as fromsystem,
|
||||
cast(contributor as {{ dbt_utils.type_string() }}) as contributor,
|
||||
cast(publishedat as {{ dbt_utils.type_string() }}) as publishedat,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
cast(updatedcount as {{ dbt_utils.type_float() }}) as updatedcount,
|
||||
cast(sharestatistic as {{ dbt_utils.type_string() }}) as sharestatistic,
|
||||
{{ cast_to_boolean('enablenotificationforcontributor') }} as enablenotificationforcontributor,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('social_posts_ab1') }}
|
||||
-- social_posts
|
||||
where 1 = 1
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('social_posts_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
array_to_string('tags'),
|
||||
boolean_to_string('ispin'),
|
||||
adapter.quote('order'),
|
||||
'title',
|
||||
'author',
|
||||
array_to_string('cities'),
|
||||
array_to_string('photos'),
|
||||
'reason',
|
||||
'status',
|
||||
array_to_string('videos'),
|
||||
adapter.quote('content'),
|
||||
boolean_to_string('istimer'),
|
||||
'startat',
|
||||
array_to_string('products'),
|
||||
'createdat',
|
||||
boolean_to_string('hasupdate'),
|
||||
'statistic',
|
||||
'updatedat',
|
||||
array_to_string('categories'),
|
||||
boolean_to_string('fromsystem'),
|
||||
'contributor',
|
||||
'publishedat',
|
||||
'searchstring',
|
||||
'updatedcount',
|
||||
'sharestatistic',
|
||||
boolean_to_string('enablenotificationforcontributor'),
|
||||
]) }} as _airbyte_social_posts_hashid,
|
||||
tmp.*
|
||||
from {{ ref('social_posts_ab2') }} tmp
|
||||
-- social_posts
|
||||
where 1 = 1
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_suppliers') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['tax'], ['tax']) }} as tax,
|
||||
{{ json_extract_scalar('_airbyte_data', ['bank'], ['bank']) }} as bank,
|
||||
{{ json_extract_scalar('_airbyte_data', ['logo'], ['logo']) }} as logo,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['checkSum'], ['checkSum']) }} as checksum,
|
||||
{{ json_extract_scalar('_airbyte_data', ['checksum'], ['checksum']) }} as checksum_1,
|
||||
{{ json_extract_scalar('_airbyte_data', ['location'], ['location']) }} as {{ adapter.quote('location') }},
|
||||
{{ json_extract_array('_airbyte_data', ['contracts'], ['contracts']) }} as contracts,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_array('_airbyte_data', ['documents'], ['documents']) }} as documents,
|
||||
{{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_array('_airbyte_data', ['categories'], ['categories']) }} as categories,
|
||||
{{ json_extract_array('_airbyte_data', ['inventories'], ['inventories']) }} as inventories,
|
||||
{{ json_extract_scalar('_airbyte_data', ['identifyCode'], ['identifyCode']) }} as identifycode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_scalar('_airbyte_data', ['contractNumber'], ['contractNumber']) }} as contractnumber,
|
||||
{{ json_extract_scalar('_airbyte_data', ['reviewStatistic'], ['reviewStatistic']) }} as reviewstatistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['contractSignedAt'], ['contractSignedAt']) }} as contractsignedat,
|
||||
{{ json_extract_array('_airbyte_data', ['emailForInvoices'], ['emailForInvoices']) }} as emailforinvoices,
|
||||
{{ json_extract_scalar('_airbyte_data', ['contractExpiredAt'], ['contractExpiredAt']) }} as contractexpiredat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['sendInvoiceRequestEveryDay'], ['sendInvoiceRequestEveryDay']) }} as sendinvoicerequesteveryday,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_suppliers') }} as table_alias
|
||||
-- suppliers
|
||||
where 1 = 1
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('suppliers_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(tax as {{ dbt_utils.type_string() }}) as tax,
|
||||
cast(bank as {{ dbt_utils.type_string() }}) as bank,
|
||||
cast(logo as {{ dbt_utils.type_string() }}) as logo,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
cast(checksum as {{ dbt_utils.type_string() }}) as checksum,
|
||||
cast(checksum_1 as {{ dbt_utils.type_string() }}) as checksum_1,
|
||||
cast({{ adapter.quote('location') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('location') }},
|
||||
contracts,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
documents,
|
||||
cast(statistic as {{ dbt_utils.type_string() }}) as statistic,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
categories,
|
||||
inventories,
|
||||
cast(identifycode as {{ dbt_utils.type_float() }}) as identifycode,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
cast(contractnumber as {{ dbt_utils.type_string() }}) as contractnumber,
|
||||
cast(reviewstatistic as {{ dbt_utils.type_string() }}) as reviewstatistic,
|
||||
cast(contractsignedat as {{ dbt_utils.type_string() }}) as contractsignedat,
|
||||
emailforinvoices,
|
||||
cast(contractexpiredat as {{ dbt_utils.type_string() }}) as contractexpiredat,
|
||||
{{ cast_to_boolean('sendinvoicerequesteveryday') }} as sendinvoicerequesteveryday,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('suppliers_ab1') }}
|
||||
-- suppliers
|
||||
where 1 = 1
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('suppliers_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'tax',
|
||||
'bank',
|
||||
'logo',
|
||||
adapter.quote('name'),
|
||||
boolean_to_string('active'),
|
||||
'checksum',
|
||||
'checksum_1',
|
||||
adapter.quote('location'),
|
||||
array_to_string('contracts'),
|
||||
'createdat',
|
||||
array_to_string('documents'),
|
||||
'statistic',
|
||||
'updatedat',
|
||||
array_to_string('categories'),
|
||||
array_to_string('inventories'),
|
||||
'identifycode',
|
||||
'searchstring',
|
||||
'contractnumber',
|
||||
'reviewstatistic',
|
||||
'contractsignedat',
|
||||
array_to_string('emailforinvoices'),
|
||||
'contractexpiredat',
|
||||
boolean_to_string('sendinvoicerequesteveryday'),
|
||||
]) }} as _airbyte_suppliers_hashid,
|
||||
tmp.*
|
||||
from {{ ref('suppliers_ab2') }} tmp
|
||||
-- suppliers
|
||||
where 1 = 1
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_team_activities') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['team'], ['team']) }} as team,
|
||||
{{ json_extract_scalar('_airbyte_data', ['action'], ['action']) }} as {{ adapter.quote('action') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['targetId'], ['targetId']) }} as targetid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdBy'], ['createdBy']) }} as createdby,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_team_activities') }} as table_alias
|
||||
-- team_activities
|
||||
where 1 = 1
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('team_activities_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(team as {{ dbt_utils.type_string() }}) as team,
|
||||
cast({{ adapter.quote('action') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('action') }},
|
||||
cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }},
|
||||
cast(targetid as {{ dbt_utils.type_string() }}) as targetid,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(createdby as {{ dbt_utils.type_string() }}) as createdby,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('team_activities_ab1') }}
|
||||
-- team_activities
|
||||
where 1 = 1
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('team_activities_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'team',
|
||||
adapter.quote('action'),
|
||||
adapter.quote('options'),
|
||||
'targetid',
|
||||
'createdat',
|
||||
'createdby',
|
||||
]) }} as _airbyte_team_activities_hashid,
|
||||
tmp.*
|
||||
from {{ ref('team_activities_ab2') }} tmp
|
||||
-- team_activities
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_team_bonus') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['team'], ['team']) }} as team,
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_scalar('_airbyte_data', ['percent'], ['percent']) }} as {{ adapter.quote('percent') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['targetId'], ['targetId']) }} as targetid,
|
||||
{{ json_extract_scalar('_airbyte_data', ['teamName'], ['teamName']) }} as teamname,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['teamLevel'], ['teamLevel']) }} as teamlevel,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['commission'], ['commission']) }} as commission,
|
||||
{{ json_extract_scalar('_airbyte_data', ['teamMember'], ['teamMember']) }} as teammember,
|
||||
{{ json_extract_scalar('_airbyte_data', ['teamPromotion'], ['teamPromotion']) }} as teampromotion,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_team_bonus') }} as table_alias
|
||||
-- team_bonus
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('team_bonus_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(team as {{ dbt_utils.type_string() }}) as team,
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
cast(status as {{ dbt_utils.type_string() }}) as status,
|
||||
cast({{ adapter.quote('percent') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('percent') }},
|
||||
cast(targetid as {{ dbt_utils.type_string() }}) as targetid,
|
||||
cast(teamname as {{ dbt_utils.type_string() }}) as teamname,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(teamlevel as {{ dbt_utils.type_float() }}) as teamlevel,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(commission as {{ dbt_utils.type_float() }}) as commission,
|
||||
cast(teammember as {{ dbt_utils.type_string() }}) as teammember,
|
||||
cast(teampromotion as {{ dbt_utils.type_string() }}) as teampromotion,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('team_bonus_ab1') }}
|
||||
-- team_bonus
|
||||
where 1 = 1
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('team_bonus_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'team',
|
||||
adapter.quote('user'),
|
||||
'status',
|
||||
adapter.quote('percent'),
|
||||
'targetid',
|
||||
'teamname',
|
||||
'createdat',
|
||||
'teamlevel',
|
||||
'updatedat',
|
||||
'commission',
|
||||
'teammember',
|
||||
'teampromotion',
|
||||
]) }} as _airbyte_team_bonus_hashid,
|
||||
tmp.*
|
||||
from {{ ref('team_bonus_ab2') }} tmp
|
||||
-- team_bonus
|
||||
where 1 = 1
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_team_members') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['role'], ['role']) }} as {{ adapter.quote('role') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['team'], ['team']) }} as team,
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['isLeft'], ['isLeft']) }} as isleft,
|
||||
{{ json_extract_scalar('_airbyte_data', ['leftAt'], ['leftAt']) }} as leftat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['joinedAt'], ['joinedAt']) }} as joinedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['roleCode'], ['roleCode']) }} as rolecode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isRemovedBy'], ['isRemovedBy']) }} as isremovedby,
|
||||
{{ json_extract_scalar('_airbyte_data', ['firstOrderAt'], ['firstOrderAt']) }} as firstorderat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isMemberHomegrown'], ['isMemberHomegrown']) }} as ismemberhomegrown,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_team_members') }} as table_alias
|
||||
-- team_members
|
||||
where 1 = 1
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('team_members_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast({{ adapter.quote('role') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('role') }},
|
||||
cast(team as {{ dbt_utils.type_string() }}) as team,
|
||||
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
|
||||
{{ cast_to_boolean('isleft') }} as isleft,
|
||||
cast(leftat as {{ dbt_utils.type_string() }}) as leftat,
|
||||
cast(joinedat as {{ dbt_utils.type_string() }}) as joinedat,
|
||||
cast(rolecode as {{ dbt_utils.type_float() }}) as rolecode,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(statistic as {{ dbt_utils.type_string() }}) as statistic,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(isremovedby as {{ dbt_utils.type_string() }}) as isremovedby,
|
||||
cast(firstorderat as {{ dbt_utils.type_string() }}) as firstorderat,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
{{ cast_to_boolean('ismemberhomegrown') }} as ismemberhomegrown,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('team_members_ab1') }}
|
||||
-- team_members
|
||||
where 1 = 1
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('team_members_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
adapter.quote('role'),
|
||||
'team',
|
||||
adapter.quote('user'),
|
||||
boolean_to_string('isleft'),
|
||||
'leftat',
|
||||
'joinedat',
|
||||
'rolecode',
|
||||
'createdat',
|
||||
'statistic',
|
||||
'updatedat',
|
||||
'isremovedby',
|
||||
'firstorderat',
|
||||
'searchstring',
|
||||
boolean_to_string('ismemberhomegrown'),
|
||||
]) }} as _airbyte_team_members_hashid,
|
||||
tmp.*
|
||||
from {{ ref('team_members_ab2') }} tmp
|
||||
-- team_members
|
||||
where 1 = 1
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_teams') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code,
|
||||
{{ json_extract_scalar('_airbyte_data', ['desc'], ['desc']) }} as {{ adapter.quote('desc') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['logo'], ['logo']) }} as logo,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['level'], ['level']) }} as {{ adapter.quote('level') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active,
|
||||
{{ json_extract_scalar('_airbyte_data', ['isFull'], ['isFull']) }} as isfull,
|
||||
{{ json_extract_scalar('_airbyte_data', ['cityCode'], ['cityCode']) }} as citycode,
|
||||
{{ json_extract_scalar('_airbyte_data', ['adminUser'], ['adminUser']) }} as adminuser,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['inviteLink'], ['inviteLink']) }} as invitelink,
|
||||
{{ json_extract_scalar('_airbyte_data', ['information'], ['information']) }} as information,
|
||||
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
|
||||
{{ json_extract_scalar('_airbyte_data', ['inactiveReason'], ['inactiveReason']) }} as inactivereason,
|
||||
{{ json_extract_scalar('_airbyte_data', ['changingNameCount'], ['changingNameCount']) }} as changingnamecount,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_teams') }} as table_alias
|
||||
-- teams
|
||||
where 1 = 1
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type
|
||||
-- depends_on: {{ ref('teams_ab1') }}
|
||||
select
|
||||
cast(_id as {{ dbt_utils.type_string() }}) as _id,
|
||||
cast(code as {{ dbt_utils.type_string() }}) as code,
|
||||
cast({{ adapter.quote('desc') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('desc') }},
|
||||
cast(logo as {{ dbt_utils.type_string() }}) as logo,
|
||||
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
|
||||
cast({{ adapter.quote('level') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('level') }},
|
||||
{{ cast_to_boolean('active') }} as active,
|
||||
{{ cast_to_boolean('isfull') }} as isfull,
|
||||
cast(citycode as {{ dbt_utils.type_float() }}) as citycode,
|
||||
cast(adminuser as {{ dbt_utils.type_string() }}) as adminuser,
|
||||
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
|
||||
cast(statistic as {{ dbt_utils.type_string() }}) as statistic,
|
||||
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
|
||||
cast(invitelink as {{ dbt_utils.type_string() }}) as invitelink,
|
||||
cast(information as {{ dbt_utils.type_string() }}) as information,
|
||||
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
|
||||
cast(inactivereason as {{ dbt_utils.type_string() }}) as inactivereason,
|
||||
cast(changingnamecount as {{ dbt_utils.type_float() }}) as changingnamecount,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ ref('teams_ab1') }}
|
||||
-- teams
|
||||
where 1 = 1
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to build a hash column based on the values of this record
|
||||
-- depends_on: {{ ref('teams_ab2') }}
|
||||
select
|
||||
{{ dbt_utils.surrogate_key([
|
||||
'_id',
|
||||
'code',
|
||||
adapter.quote('desc'),
|
||||
'logo',
|
||||
adapter.quote('name'),
|
||||
adapter.quote('level'),
|
||||
boolean_to_string('active'),
|
||||
boolean_to_string('isfull'),
|
||||
'citycode',
|
||||
'adminuser',
|
||||
'createdat',
|
||||
'statistic',
|
||||
'updatedat',
|
||||
'invitelink',
|
||||
'information',
|
||||
'searchstring',
|
||||
'inactivereason',
|
||||
'changingnamecount',
|
||||
]) }} as _airbyte_teams_hashid,
|
||||
tmp.*
|
||||
from {{ ref('teams_ab2') }} tmp
|
||||
-- teams
|
||||
where 1 = 1
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
{{ config(
|
||||
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
|
||||
unique_key = '_airbyte_ab_id',
|
||||
schema = "_airbyte_unibag",
|
||||
tags = [ "top-level-intermediate" ]
|
||||
) }}
|
||||
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
|
||||
-- depends_on: {{ source('unibag', '_airbyte_raw_user_identifications') }}
|
||||
select
|
||||
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
|
||||
{{ json_extract_scalar('_airbyte_data', ['dob'], ['dob']) }} as dob,
|
||||
{{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['note'], ['note']) }} as note,
|
||||
{{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['gender'], ['gender']) }} as gender,
|
||||
{{ json_extract_scalar('_airbyte_data', ['nation'], ['nation']) }} as nation,
|
||||
{{ json_extract_scalar('_airbyte_data', ['number'], ['number']) }} as {{ adapter.quote('number') }},
|
||||
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
|
||||
{{ json_extract_scalar('_airbyte_data', ['address'], ['address']) }} as address,
|
||||
{{ json_extract_scalar('_airbyte_data', ['dobDate'], ['dobDate']) }} as dobdate,
|
||||
{{ json_extract_scalar('_airbyte_data', ['backSide'], ['backSide']) }} as backside,
|
||||
{{ json_extract_scalar('_airbyte_data', ['birthday'], ['birthday']) }} as birthday,
|
||||
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['frontSide'], ['frontSide']) }} as frontside,
|
||||
{{ json_extract_scalar('_airbyte_data', ['issueDate'], ['issueDate']) }} as issuedate,
|
||||
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
|
||||
{{ json_extract_scalar('_airbyte_data', ['expiryDate'], ['expiryDate']) }} as expirydate,
|
||||
{{ json_extract_scalar('_airbyte_data', ['issuePlace'], ['issuePlace']) }} as issueplace,
|
||||
{{ json_extract_scalar('_airbyte_data', ['timeUpdate'], ['timeUpdate']) }} as timeupdate,
|
||||
{{ json_extract_scalar('_airbyte_data', ['detectInformation'], ['detectInformation']) }} as detectinformation,
|
||||
_airbyte_ab_id,
|
||||
_airbyte_emitted_at,
|
||||
{{ current_timestamp() }} as _airbyte_normalized_at
|
||||
from {{ source('unibag', '_airbyte_raw_user_identifications') }} as table_alias
|
||||
-- user_identifications
|
||||
where 1 = 1
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue