Skip to content

Commit

Permalink
Merge pull request #4 from graze/adding_discount_application
Browse files Browse the repository at this point in the history
adding shipping line discount allocations
  • Loading branch information
AaronHagan4 authored Aug 7, 2023
2 parents 7d6d61b + 57cfeaf commit 44bc31c
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
22 changes: 22 additions & 0 deletions macros/get_discount_application_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% macro get_discount_application_columns() %}

{% set columns = [
{"name": "index", "datatype": dbt.type_string()},
{"name": "order_id", "datatype": dbt.type_string},
{"name": "_fivetran_synced", "datatype": dbt.type_timestamp()},
{"name": "allocation_method", "datatype": dbt.type_string},
{"name": "code", "datatype": dbt.type_string},
{"name": "description", "datatype": dbt.type_string},
{"name": "target_selection", "datatype": dbt.type_string},
{"name": "target_type", "datatype": dbt.type_string},
{"name": "title", "datatype": dbt.type_string},
{"name": "type", "datatype": dbt.type_string},
{"name": "value", "datatype": dbt.type_numeric},
{"name": "value_type", "datatype": dbt.type_string}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('customer_pass_through_columns')) }}

{{ return(columns) }}

{% endmacro %}
9 changes: 9 additions & 0 deletions models/stg_shopify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1705,3 +1705,12 @@ models:
- name: order_line_id
- name: source_relation
- name: amount

- name: stg_shopify__discount_application
description: discount_application
columns:
- name: order_id
- name: source_relation
- name: value
- name: value_type,
- name: target_type
41 changes: 41 additions & 0 deletions models/stg_shopify__discount_application.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
with base as (

select *
from {{ ref('stg_shopify__discount_application_tmp') }}

),

fields as (

select

{{
fivetran_utils.fill_staging_columns(
source_columns=adapter.get_columns_in_relation(ref('stg_shopify__discount_application_tmp')),
staging_columns=get_discount_application_columns()
)
}}

{{ fivetran_utils.source_relation(
union_schema_variable='shopify_union_schemas',
union_database_variable='shopify_union_databases')
}}

from base

),

final as (

select
order_id,
source_relation,
value,
value_type,
target_type
from fields

)

select *
from final
12 changes: 12 additions & 0 deletions models/tmp/stg_shopify__discount_application_tmp.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{
fivetran_utils.union_data(
table_identifier='discount_application',
database_variable='shopify_database',
schema_variable='shopify_schema',
default_database=target.database,
default_schema='shopify',
default_variable='discount_applicaton_source',
union_schema_variable='shopify_union_schemas',
union_database_variable='shopify_union_databases'
)
}}

0 comments on commit 44bc31c

Please sign in to comment.