add orders and order deliveries weight
This commit is contained in:
		
							parent
							
								
									66db8c2a19
								
							
						
					
					
						commit
						8cf7da2c02
					
				| 
						 | 
					@ -23,6 +23,7 @@ select
 | 
				
			||||||
    {{ json_extract_scalar('_airbyte_data', ['trackingTime'], ['trackingTime']) }} as trackingtime,
 | 
					    {{ json_extract_scalar('_airbyte_data', ['trackingTime'], ['trackingTime']) }} as trackingtime,
 | 
				
			||||||
    {{ json_extract_scalar('_airbyte_data', ['isAdminChange'], ['isAdminChange']) }} as isadminchange,
 | 
					    {{ json_extract_scalar('_airbyte_data', ['isAdminChange'], ['isAdminChange']) }} as isadminchange,
 | 
				
			||||||
    {{ json_extract_scalar('_airbyte_data', ['trackingOrderCode'], ['trackingOrderCode']) }} as trackingordercode,
 | 
					    {{ json_extract_scalar('_airbyte_data', ['trackingOrderCode'], ['trackingOrderCode']) }} as trackingordercode,
 | 
				
			||||||
 | 
					    {{ json_extract_scalar('_airbyte_data', ['weight'], ['weight']) }} as weight,
 | 
				
			||||||
    _airbyte_ab_id,
 | 
					    _airbyte_ab_id,
 | 
				
			||||||
    _airbyte_emitted_at,
 | 
					    _airbyte_emitted_at,
 | 
				
			||||||
    {{ current_timestamp() }} as _airbyte_normalized_at
 | 
					    {{ current_timestamp() }} as _airbyte_normalized_at
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,6 +23,7 @@ select
 | 
				
			||||||
    cast(trackingtime as {{ dbt_utils.type_string() }}) as trackingtime,
 | 
					    cast(trackingtime as {{ dbt_utils.type_string() }}) as trackingtime,
 | 
				
			||||||
    {{ cast_to_boolean('isadminchange') }} as isadminchange,
 | 
					    {{ cast_to_boolean('isadminchange') }} as isadminchange,
 | 
				
			||||||
    cast(trackingordercode as {{ dbt_utils.type_string() }}) as trackingordercode,
 | 
					    cast(trackingordercode as {{ dbt_utils.type_string() }}) as trackingordercode,
 | 
				
			||||||
 | 
					    cast(weight as {{ dbt_utils.type_string() }}) as weight,
 | 
				
			||||||
    _airbyte_ab_id,
 | 
					    _airbyte_ab_id,
 | 
				
			||||||
    _airbyte_emitted_at,
 | 
					    _airbyte_emitted_at,
 | 
				
			||||||
    {{ current_timestamp() }} as _airbyte_normalized_at
 | 
					    {{ current_timestamp() }} as _airbyte_normalized_at
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,7 @@ select
 | 
				
			||||||
        'trackingtime',
 | 
					        'trackingtime',
 | 
				
			||||||
        boolean_to_string('isadminchange'),
 | 
					        boolean_to_string('isadminchange'),
 | 
				
			||||||
        'trackingordercode',
 | 
					        'trackingordercode',
 | 
				
			||||||
 | 
					        'weight',
 | 
				
			||||||
    ]) }} as _airbyte_order_deliveries_hashid,
 | 
					    ]) }} as _airbyte_order_deliveries_hashid,
 | 
				
			||||||
    tmp.*
 | 
					    tmp.*
 | 
				
			||||||
from {{ ref('order_deliveries_ab2') }} tmp
 | 
					from {{ ref('order_deliveries_ab2') }} tmp
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,6 +32,11 @@ select
 | 
				
			||||||
    {{ adapter.quote('location') }}::json->>'fullAddress' AS location_full_address,
 | 
					    {{ adapter.quote('location') }}::json->>'fullAddress' AS location_full_address,
 | 
				
			||||||
    {{ adapter.quote('customer') }}::json->>'name' AS customer_name,
 | 
					    {{ adapter.quote('customer') }}::json->>'name' AS customer_name,
 | 
				
			||||||
    {{ adapter.quote('customer') }}::json->>'phone' AS customer_phone,
 | 
					    {{ 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,
 | 
					    {{ adapter.quote('order') }} AS order_id,
 | 
				
			||||||
    createdat::timestamp AS created_at,
 | 
					    createdat::timestamp AS created_at,
 | 
				
			||||||
    updatedat::timestamp AS updated_at,
 | 
					    updatedat::timestamp AS updated_at,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,6 +31,11 @@ select
 | 
				
			||||||
    cast({{ adapter.quote('price') }}::json->>'weight' AS numeric) AS weight,
 | 
					    cast({{ adapter.quote('price') }}::json->>'weight' AS numeric) AS weight,
 | 
				
			||||||
    {{ adapter.quote('delivery') }}::json->>'_id' AS delivery_id,
 | 
					    {{ adapter.quote('delivery') }}::json->>'_id' AS delivery_id,
 | 
				
			||||||
    cast({{ adapter.quote('delivery') }}::json->>'discountValue' AS numeric) AS delivery_discount_value,
 | 
					    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,
 | 
					    approvedat::timestamp AS approved_at,
 | 
				
			||||||
    rejectedat::timestamp AS rejected_at,
 | 
					    rejectedat::timestamp AS rejected_at,
 | 
				
			||||||
    pickupat::timestamp AS pickup_at,
 | 
					    pickupat::timestamp AS pickup_at,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue