dbt-selly/models/generated/airbyte_tables/unibag/promotion_orders.sql

35 lines
1.4 KiB
MySQL
Raw Permalink Normal View History

2022-03-22 04:03:52 +00:00
{{ config(
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
unique_key = '_airbyte_ab_id',
schema = "unibag",
tags = [ "top-level" ]
) }}
-- Final base SQL model
-- depends_on: {{ ref('promotion_orders_ab3') }}
select
_id,
{{ adapter.quote('user') }} AS seller_id,
{{ adapter.quote('order') }} AS order_id,
promotion AS promotion_id,
commission,
status,
title,
createdat::timestamp AS created_at,
updatedat::timestamp AS updated_at,
-- cast({{ adapter.quote('sharepercent') }}::json->>'supplier' AS numeric) AS share_percent_supplier,
-- cast({{ adapter.quote('sharepercent') }}::json->>'selly' AS numeric) AS share_percent_selly,
{{ adapter.quote('supplier') }}::json->>'_id' AS supplier_id,
{{ adapter.quote('supplier') }}::json->>'name' AS supplier_name,
2022-04-07 03:03:41 +00:00
{{ adapter.quote('suppliercommission') }}::json->>'type' AS supplier_commission_type,
cast({{ adapter.quote('suppliercommission') }}::json->>'value' AS numeric) AS supplier_commission_value,
cast({{ adapter.quote('suppliercommissiontotal') }} AS numeric) AS supplier_commission_total,
2022-03-22 04:03:52 +00:00
_airbyte_ab_id,
_airbyte_emitted_at,
{{ current_timestamp() }} as _airbyte_normalized_at,
_airbyte_promotion_orders_hashid
from {{ ref('promotion_orders_ab3') }}
-- promotion_orders from {{ source('unibag', '_airbyte_raw_promotion_orders') }}
where 1 = 1