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

75 lines
4.3 KiB
MySQL
Raw Permalink 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 cast each column to its adequate SQL type converted from the JSON schema type
-- depends_on: {{ ref('orders_ab1') }}
select
cast(_id as {{ dbt_utils.type_string() }}) as _id,
cast(code as {{ dbt_utils.type_string() }}) as code,
cast({{ adapter.quote('date') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('date') }},
cast({{ adapter.quote('hour') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('hour') }},
cast(note as {{ dbt_utils.type_string() }}) as note,
tags,
cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }},
2022-05-11 04:21:03 +00:00
cast(price as {{ dbt_utils.type_string() }}) as price,
2022-03-22 04:03:52 +00:00
{{ cast_to_boolean('banned') }} as banned,
cast(reason as {{ dbt_utils.type_string() }}) as reason,
cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }},
cast(status as {{ dbt_utils.type_string() }}) as status,
2022-05-11 04:21:03 +00:00
cast(teamid as {{ dbt_utils.type_string() }}) as teamid,
cast(payment as {{ dbt_utils.type_string() }}) as payment,
2022-03-22 04:03:52 +00:00
cast(remarks as {{ dbt_utils.type_string() }}) as remarks,
cast(customer as {{ dbt_utils.type_string() }}) as customer,
2022-05-11 04:21:03 +00:00
cast(delivery as {{ dbt_utils.type_string() }}) as delivery,
{{ cast_to_boolean('iscalled') }} as iscalled,
cast(merchant as {{ dbt_utils.type_string() }}) as merchant,
2022-03-22 04:03:52 +00:00
cast(pickupat as {{ dbt_utils.type_string() }}) as pickupat,
2022-05-11 04:21:03 +00:00
cast(supplier as {{ dbt_utils.type_string() }}) as supplier,
2022-03-22 04:03:52 +00:00
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
2022-05-11 04:21:03 +00:00
cast(inventory as {{ dbt_utils.type_string() }}) as inventory,
cast(invoiceid as {{ dbt_utils.type_string() }}) as invoiceid,
2022-03-22 04:03:52 +00:00
{{ cast_to_boolean('isdeleted') }} as isdeleted,
2022-05-11 04:21:03 +00:00
cast(promotion as {{ dbt_utils.type_string() }}) as promotion,
2022-03-22 04:03:52 +00:00
cast(requestid as {{ dbt_utils.type_string() }}) as requestid,
2022-05-11 04:21:03 +00:00
cast(restockat as {{ dbt_utils.type_string() }}) as restockat,
cast(sendemail as {{ dbt_utils.type_string() }}) as sendemail,
2022-03-22 04:03:52 +00:00
cast(totalitem as {{ dbt_utils.type_float() }}) as totalitem,
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
2022-05-11 04:21:03 +00:00
cast(useragent as {{ dbt_utils.type_string() }}) as useragent,
2022-03-22 04:03:52 +00:00
{{ cast_to_boolean('wholesale') }} as wholesale,
cast(approvedat as {{ dbt_utils.type_string() }}) as approvedat,
cast(cashbackat as {{ dbt_utils.type_string() }}) as cashbackat,
{{ cast_to_boolean('ispreorder') }} as ispreorder,
2022-05-11 04:21:03 +00:00
{{ cast_to_boolean('isreviewed') }} as isreviewed,
2022-03-22 04:03:52 +00:00
cast(rejectedat as {{ dbt_utils.type_string() }}) as rejectedat,
cast(deliveredat as {{ dbt_utils.type_string() }}) as deliveredat,
cast(deliveringat as {{ dbt_utils.type_string() }}) as deliveringat,
cast(deliverycode as {{ dbt_utils.type_string() }}) as deliverycode,
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
cast(staffapprove as {{ dbt_utils.type_string() }}) as staffapprove,
2022-05-11 04:21:03 +00:00
cast(teammemberid as {{ dbt_utils.type_string() }}) as teammemberid,
2022-03-22 04:03:52 +00:00
cast(processstatus as {{ dbt_utils.type_string() }}) as processstatus,
cast(hooktimelastat as {{ dbt_utils.type_string() }}) as hooktimelastat,
2022-05-11 04:21:03 +00:00
{{ cast_to_boolean('isassigncoupon') }} as isassigncoupon,
{{ cast_to_boolean('isautoapproved') }} as isautoapproved,
cast(outboundrequest as {{ dbt_utils.type_string() }}) as outboundrequest,
2022-03-22 04:03:52 +00:00
cast(trackingcodeurl as {{ dbt_utils.type_string() }}) as trackingcodeurl,
2022-05-11 04:21:03 +00:00
cast(trackingcode as {{ dbt_utils.type_string() }}) as trackingcode,
cast(waitingcancelby as {{ dbt_utils.type_string() }}) as waitingcancelby,
2022-03-22 04:03:52 +00:00
{{ cast_to_boolean('ischangedelivery') }} as ischangedelivery,
cast(estimatecashbackat as {{ dbt_utils.type_string() }}) as estimatecashbackat,
2022-05-11 04:21:03 +00:00
{{ cast_to_boolean('fromnewactivebuyer') }} as fromnewactivebuyer,
2022-03-22 04:03:52 +00:00
{{ cast_to_boolean('iswaitingcancelled') }} as iswaitingcancelled,
{{ cast_to_boolean('fromnewactiveseller') }} as fromnewactiveseller,
2022-05-11 04:21:03 +00:00
cast(waitingcancelreason as {{ dbt_utils.type_string() }}) as waitingcancelreason,
2022-03-22 04:03:52 +00:00
_airbyte_ab_id,
_airbyte_emitted_at,
{{ current_timestamp() }} as _airbyte_normalized_at
from {{ ref('orders_ab1') }}
-- orders
where 1 = 1