dbt-selly-express/models/generated/airbyte_tables/unibag/se_orders.sql

36 lines
1.4 KiB
MySQL
Raw Normal View History

2022-03-21 14:00:47 +00:00
{{ config(
indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}],
unique_key = '_airbyte_ab_id',
2022-03-21 14:08:08 +00:00
schema = "unibag",
2022-03-21 14:00:47 +00:00
tags = [ "top-level" ]
) }}
-- Final base SQL model
-- depends_on: {{ ref('se_orders_ab3') }}
select
{{ adapter.quote('to') }},
_id,
{{ adapter.quote('client') }}::json->>'code' AS client_code,
cast({{ adapter.quote('client') }}::json->'fee'->>'total' AS numeric) AS client_fee_total,
cast({{ adapter.quote('client') }}::json->'fee'->>'shipping' AS numeric) AS client_fee_shipping,
cast({{ adapter.quote('client') }}::json->'fee'->>'other' AS numeric) AS client_fee_other,
{{ adapter.quote('courier') }}::json->>'code' AS courier_code,
cast({{ adapter.quote('courier') }}::json->'fee'->>'total' AS numeric) AS courier_fee_total,
cast({{ adapter.quote('courier') }}::json->'fee'->>'shipping' AS numeric) AS courier_fee_shipping,
cast({{ adapter.quote('courier') }}::json->'fee'->>'other' AS numeric) AS courier_fee_other,
courier,
cast(weight AS numeric) AS weight,
volume,
code,
status,
cast({{ adapter.quote('value') }} AS numeric) AS value,
createdat::timestamp AS created_at,
updatedat::timestamp AS updated_at,
_airbyte_ab_id,
_airbyte_emitted_at,
{{ current_timestamp() }} as _airbyte_normalized_at,
_airbyte_se_orders_hashid
from {{ ref('se_orders_ab3') }}
2022-03-21 14:08:08 +00:00
-- se_orders from {{ source('unibag', '_airbyte_raw_se_orders') }}
2022-03-21 14:00:47 +00:00
where 1 = 1