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

70 lines
5.5 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_orders') }}
select
{{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id,
{{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code,
{{ json_extract_scalar('_airbyte_data', ['date'], ['date']) }} as {{ adapter.quote('date') }},
{{ json_extract_scalar('_airbyte_data', ['hour'], ['hour']) }} as {{ adapter.quote('hour') }},
{{ json_extract_scalar('_airbyte_data', ['note'], ['note']) }} as note,
2022-05-10 14:30:53 +00:00
{{ json_extract_array('_airbyte_data', ['skus'], ['skus']) }} as skus,
2022-03-22 04:03:52 +00:00
{{ json_extract_array('_airbyte_data', ['tags'], ['tags']) }} as tags,
{{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }},
2022-05-10 14:30:53 +00:00
{{ json_extract('table_alias', '_airbyte_data', ['price'], ['price']) }} as price,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['banned'], ['banned']) }} as banned,
{{ json_extract_scalar('_airbyte_data', ['reason'], ['reason']) }} as reason,
{{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }},
{{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status,
2022-05-10 14:30:53 +00:00
{{ json_extract_scalar('_airbyte_data', ['update'], ['update']) }} as {{ adapter.quote('update') }},
{{ json_extract('table_alias', '_airbyte_data', ['payment'], ['payment']) }} as payment,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['remarks'], ['remarks']) }} as remarks,
{{ json_extract_scalar('_airbyte_data', ['customer'], ['customer']) }} as customer,
2022-05-10 14:30:53 +00:00
{{ json_extract('table_alias', '_airbyte_data', ['delivery'], ['delivery']) }} as delivery,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['pickupAt'], ['pickupAt']) }} as pickupat,
2022-05-10 14:30:53 +00:00
{{ json_extract_array('_airbyte_data', ['products'], ['products']) }} as products,
{{ json_extract('table_alias', '_airbyte_data', ['supplier'], ['supplier']) }} as supplier,
{{ json_extract_scalar('_airbyte_data', ['approveAt'], ['approveAt']) }} as approveat,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat,
2022-05-10 14:30:53 +00:00
{{ json_extract('table_alias', '_airbyte_data', ['inventory'], ['inventory']) }} as inventory,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['isDeleted'], ['isDeleted']) }} as isdeleted,
2022-05-10 14:30:53 +00:00
{{ json_extract('table_alias', '_airbyte_data', ['promotion'], ['promotion']) }} as promotion,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['requestId'], ['requestId']) }} as requestid,
2022-05-10 14:30:53 +00:00
{{ json_extract('table_alias', '_airbyte_data', ['sendEmail'], ['sendEmail']) }} as sendemail,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['totalItem'], ['totalItem']) }} as totalitem,
{{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat,
2022-05-10 14:30:53 +00:00
{{ json_extract('table_alias', '_airbyte_data', ['userAgent'], ['userAgent']) }} as useragent,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['wholesale'], ['wholesale']) }} as wholesale,
{{ json_extract_scalar('_airbyte_data', ['approvedAt'], ['approvedAt']) }} as approvedat,
{{ json_extract_scalar('_airbyte_data', ['cashbackAt'], ['cashbackAt']) }} as cashbackat,
2022-05-10 14:30:53 +00:00
{{ json_extract_scalar('_airbyte_data', ['codeOsiris'], ['codeOsiris']) }} as codeosiris,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['isPreorder'], ['isPreorder']) }} as ispreorder,
2022-05-10 14:30:53 +00:00
{{ json_extract_scalar('_airbyte_data', ['membership'], ['membership']) }} as membership,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['rejectedAt'], ['rejectedAt']) }} as rejectedat,
{{ json_extract_scalar('_airbyte_data', ['deliveredAt'], ['deliveredAt']) }} as deliveredat,
{{ json_extract_scalar('_airbyte_data', ['deliveringAt'], ['deliveringAt']) }} as deliveringat,
{{ json_extract_scalar('_airbyte_data', ['deliveryCode'], ['deliveryCode']) }} as deliverycode,
{{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring,
{{ json_extract_scalar('_airbyte_data', ['staffApprove'], ['staffApprove']) }} as staffapprove,
2022-05-10 14:30:53 +00:00
{{ json_extract_scalar('_airbyte_data', ['trackingCode'], ['trackingCode']) }} as trackingcode,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['processStatus'], ['processStatus']) }} as processstatus,
{{ json_extract_scalar('_airbyte_data', ['hookTimeLastAt'], ['hookTimeLastAt']) }} as hooktimelastat,
{{ json_extract_scalar('_airbyte_data', ['trackingCodeURL'], ['trackingCodeURL']) }} as trackingcodeurl,
2022-05-10 14:30:53 +00:00
{{ json_extract_scalar('_airbyte_data', ['approvePaymentAt'], ['approvePaymentAt']) }} as approvepaymentat,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['isChangeDelivery'], ['isChangeDelivery']) }} as ischangedelivery,
2022-05-10 14:30:53 +00:00
{{ json_extract_scalar('_airbyte_data', ['trackingOrderCode'], ['trackingOrderCode']) }} as trackingordercode,
2022-03-22 04:03:52 +00:00
{{ json_extract_scalar('_airbyte_data', ['estimateCashbackAt'], ['estimateCashbackAt']) }} as estimatecashbackat,
{{ json_extract_scalar('_airbyte_data', ['isWaitingCancelled'], ['isWaitingCancelled']) }} as iswaitingcancelled,
{{ json_extract_scalar('_airbyte_data', ['fromNewActiveSeller'], ['fromNewActiveSeller']) }} as fromnewactiveseller,
_airbyte_ab_id,
_airbyte_emitted_at,
{{ current_timestamp() }} as _airbyte_normalized_at
from {{ source('unibag', '_airbyte_raw_orders') }} as table_alias
-- orders
where 1 = 1