add orders and order deliveries weight

This commit is contained in:
Ubuntu 2022-03-23 13:57:04 +07:00
parent 66db8c2a19
commit 8cf7da2c02
5 changed files with 13 additions and 0 deletions

View File

@ -23,6 +23,7 @@ select
{{ 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

View File

@ -23,6 +23,7 @@ select
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

View File

@ -24,6 +24,7 @@ select
'trackingtime',
boolean_to_string('isadminchange'),
'trackingordercode',
'weight',
]) }} as _airbyte_order_deliveries_hashid,
tmp.*
from {{ ref('order_deliveries_ab2') }} tmp

View File

@ -32,6 +32,11 @@ select
{{ adapter.quote('location') }}::json->>'fullAddress' AS location_full_address,
{{ adapter.quote('customer') }}::json->>'name' AS customer_name,
{{ adapter.quote('customer') }}::json->>'phone' AS customer_phone,
COALESCE(cast({{ adapter.quote('weight') }}::json->>'converted' AS numeric), 0) AS weight_converted,
COALESCE(cast({{ adapter.quote('weight') }}::json->>'convertedWithMultiplier' AS numeric), 0) AS weight_converted_with_multiplier,
COALESCE(cast({{ adapter.quote('weight') }}::json->>'multiplier' AS numeric), 0) AS weight_multiplier,
COALESCE(cast({{ adapter.quote('weight') }}::json->>'real' AS numeric), 0) AS weight_real,
COALESCE(cast({{ adapter.quote('weight') }}::json->>'sent' AS numeric), 0) AS weight_sent,
{{ adapter.quote('order') }} AS order_id,
createdat::timestamp AS created_at,
updatedat::timestamp AS updated_at,

View File

@ -31,6 +31,11 @@ select
cast({{ adapter.quote('price') }}::json->>'weight' AS numeric) AS weight,
{{ adapter.quote('delivery') }}::json->>'_id' AS delivery_id,
cast({{ adapter.quote('delivery') }}::json->>'discountValue' AS numeric) AS delivery_discount_value,
COALESCE(cast({{ adapter.quote('delivery') }}::json->'weight'->>'converted' AS numeric), 0) AS delivery_weight_converted,
COALESCE(cast({{ adapter.quote('delivery') }}::json->'weight'->>'convertedWithMultiplier' AS numeric), 0) AS delivery_weight_converted_with_multiplier,
COALESCE(cast({{ adapter.quote('delivery') }}::json->'weight'->>'multiplier' AS numeric), 0) AS delivery_weight_multiplier,
COALESCE(cast({{ adapter.quote('delivery') }}::json->'weight'->>'real' AS numeric), 0) AS delivery_weight_real,
COALESCE(cast({{ adapter.quote('delivery') }}::json->'weight'->>'sent' AS numeric), 0) AS delivery_weight_sent,
approvedat::timestamp AS approved_at,
rejectedat::timestamp AS rejected_at,
pickupat::timestamp AS pickup_at,