dbt-selly/models/generated/airbyte_ctes/unibag/order_deliveries_ab1.sql

34 lines
2.1 KiB
MySQL
Raw 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 = "_airbyte_unibag",
tags = [ "top-level-intermediate" ]
) }}
-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema
-- depends_on: {{ source('unibag', '_airbyte_raw_order_deliveries') }}
select
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
{{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code,
{{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }},
{{ json_extract_scalar('_airbyte_data', ['title'], ['title']) }} as title,
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
{{ json_extract_scalar('_airbyte_data', ['service'], ['service']) }} as service,
2022-05-11 04:21:03 +00:00
{{ json_extract_scalar('_airbyte_data', ['customer'], ['customer']) }} as customer,
{{ json_extract_scalar('_airbyte_data', ['delivery'], ['delivery']) }} as delivery,
{{ json_extract_scalar('_airbyte_data', ['location'], ['location']) }} as {{ adapter.quote('location') }},
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
2022-05-11 04:21:03 +00:00
{{ json_extract_scalar('_airbyte_data', ['promotion'], ['promotion']) }} as promotion,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
{{ json_extract_scalar('_airbyte_data', ['trackingCode'], ['trackingCode']) }} as trackingcode,
2022-05-11 04:21:03 +00:00
{{ json_extract_scalar('_airbyte_data', ['trackingTime'], ['trackingTime']) }} as trackingtime,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['isAdminChange'], ['isAdminChange']) }} as isadminchange,
{{ json_extract_scalar('_airbyte_data', ['trackingOrderCode'], ['trackingOrderCode']) }} as trackingordercode,
2022-05-11 04:21:03 +00:00
{{ json_extract_scalar('_airbyte_data', ['weight'], ['weight']) }} as weight,
2022-03-22 04:03:52 +00:00
_airbyte_ab_id,
_airbyte_emitted_at,
{{ current_timestamp() }} as _airbyte_normalized_at
from {{ source('unibag', '_airbyte_raw_order_deliveries') }} as table_alias
-- order_deliveries
where 1 = 1