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

42 lines
1.9 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('users_ab1') }}
select
cast(_id as {{ dbt_utils.type_string() }}) as _id,
cast(code as {{ dbt_utils.type_string() }}) as code,
2022-05-10 14:30:53 +00:00
cast(info as {{ type_json() }}) as info,
2022-03-22 04:03:52 +00:00
cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }},
2022-05-10 14:30:53 +00:00
cast(team as {{ type_json() }}) as team,
cast(zalo as {{ type_json() }}) as zalo,
cast(email as {{ type_json() }}) as email,
cast(phone as {{ type_json() }}) as phone,
cast(avatar as {{ type_json() }}) as avatar,
2022-03-22 04:03:52 +00:00
{{ cast_to_boolean('banned') }} as banned,
cast(segment as {{ dbt_utils.type_string() }}) as segment,
2022-05-10 14:30:53 +00:00
cast(facebook as {{ type_json() }}) as facebook,
2022-03-22 04:03:52 +00:00
{{ cast_to_boolean('hasorder') }} as hasorder,
2022-05-10 14:30:53 +00:00
cast(referral as {{ type_json() }}) as referral,
2022-03-22 04:03:52 +00:00
segments,
cast(createdat as {{ dbt_utils.type_string() }}) as createdat,
2022-05-10 14:30:53 +00:00
cast(statistic as {{ type_json() }}) as statistic,
2022-03-22 04:03:52 +00:00
cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat,
2022-05-10 14:30:53 +00:00
cast(membership as {{ type_json() }}) as membership,
2022-03-22 04:03:52 +00:00
cast(registerfrom as {{ dbt_utils.type_string() }}) as registerfrom,
cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring,
{{ cast_to_boolean('isupdatedinfo') }} as isupdatedinfo,
2022-05-10 14:30:53 +00:00
cast(identification as {{ type_json() }}) as identification,
2022-03-22 04:03:52 +00:00
cast(lastactivatedat as {{ dbt_utils.type_string() }}) as lastactivatedat,
cast(lastviewnotificationat as {{ dbt_utils.type_string() }}) as lastviewnotificationat,
_airbyte_ab_id,
_airbyte_emitted_at,
{{ current_timestamp() }} as _airbyte_normalized_at
from {{ ref('users_ab1') }}
-- users
where 1 = 1