{{ config( indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], schema = "_airbyte_unibag", tags = [ "nested-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: {{ ref('users') }} select _airbyte_users_hashid, {{ json_extract_scalar('statistic', ['cashTotal'], ['cashTotal']) }} as cashtotal, {{ json_extract_scalar('statistic', ['cashPending'], ['cashPending']) }} as cashpending, {{ json_extract_scalar('statistic', ['cashCashback'], ['cashCashback']) }} as cashcashback, {{ json_extract_scalar('statistic', ['cashGiveGift'], ['cashGiveGift']) }} as cashgivegift, {{ json_extract_scalar('statistic', ['cashRejected'], ['cashRejected']) }} as cashrejected, {{ json_extract_scalar('statistic', ['taxTotalCash'], ['taxTotalCash']) }} as taxtotalcash, {{ json_extract_scalar('statistic', ['totalGiftBox'], ['totalGiftBox']) }} as totalgiftbox, {{ json_extract_scalar('statistic', ['totalTickets'], ['totalTickets']) }} as totaltickets, {{ json_extract_scalar('statistic', ['cashCancelled'], ['cashCancelled']) }} as cashcancelled, {{ json_extract_scalar('statistic', ['cashDelivered'], ['cashDelivered']) }} as cashdelivered, {{ json_extract_scalar('statistic', ['cashRemaining'], ['cashRemaining']) }} as cashremaining, {{ json_extract_scalar('statistic', ['customerTotal'], ['customerTotal']) }} as customertotal, {{ json_extract_scalar('statistic', ['totalCartItem'], ['totalCartItem']) }} as totalcartitem, {{ json_extract_scalar('statistic', ['withdrawTotal'], ['withdrawTotal']) }} as withdrawtotal, {{ json_extract_scalar('statistic', ['cashDelivering'], ['cashDelivering']) }} as cashdelivering, {{ json_extract_scalar('statistic', ['taxCashPending'], ['taxCashPending']) }} as taxcashpending, {{ json_extract_scalar('statistic', ['withdrawPending'], ['withdrawPending']) }} as withdrawpending, {{ json_extract_scalar('statistic', ['withdrawSuccess'], ['withdrawSuccess']) }} as withdrawsuccess, {{ json_extract_scalar('statistic', ['revenueLastMonth'], ['revenueLastMonth']) }} as revenuelastmonth, {{ json_extract_scalar('statistic', ['totalSaleSuccess'], ['totalSaleSuccess']) }} as totalsalesuccess, {{ json_extract_scalar('statistic', ['transactionTotal'], ['transactionTotal']) }} as transactiontotal, {{ json_extract_scalar('statistic', ['withdrawRejected'], ['withdrawRejected']) }} as withdrawrejected, {{ json_extract_scalar('statistic', ['cashWithdrawTotal'], ['cashWithdrawTotal']) }} as cashwithdrawtotal, {{ json_extract_scalar('statistic', ['cashWaitingApprove'], ['cashWaitingApprove']) }} as cashwaitingapprove, {{ json_extract_scalar('statistic', ['transactionPending'], ['transactionPending']) }} as transactionpending, {{ json_extract_scalar('statistic', ['transactionSuccess'], ['transactionSuccess']) }} as transactionsuccess, {{ json_extract_scalar('statistic', ['cashWithdrawPending'], ['cashWithdrawPending']) }} as cashwithdrawpending, {{ json_extract_scalar('statistic', ['cashWithdrawSuccess'], ['cashWithdrawSuccess']) }} as cashwithdrawsuccess, {{ json_extract_scalar('statistic', ['highestMonthlySales'], ['highestMonthlySales']) }} as highestmonthlysales, {{ json_extract_scalar('statistic', ['transactionRejected'], ['transactionRejected']) }} as transactionrejected, {{ json_extract_scalar('statistic', ['cashWithdrawRejected'], ['cashWithdrawRejected']) }} as cashwithdrawrejected, {{ json_extract_scalar('statistic', ['teamBonusPendingCash'], ['teamBonusPendingCash']) }} as teambonuspendingcash, {{ json_extract_scalar('statistic', ['teamBonusSuccessCash'], ['teamBonusSuccessCash']) }} as teambonussuccesscash, {{ json_extract_scalar('statistic', ['transactionDelivered'], ['transactionDelivered']) }} as transactiondelivered, {{ json_extract_scalar('statistic', ['cashPaymentProcessing'], ['cashPaymentProcessing']) }} as cashpaymentprocessing, {{ json_extract_scalar('statistic', ['transactionDelivering'], ['transactionDelivering']) }} as transactiondelivering, {{ json_extract_scalar('statistic', ['eventRewardPendingCash'], ['eventRewardPendingCash']) }} as eventrewardpendingcash, {{ json_extract_scalar('statistic', ['eventRewardSuccessCash'], ['eventRewardSuccessCash']) }} as eventrewardsuccesscash, {{ json_extract_scalar('statistic', ['transactionCashPending'], ['transactionCashPending']) }} as transactioncashpending, {{ json_extract_scalar('statistic', ['voucherBonusPendingCash'], ['voucherBonusPendingCash']) }} as voucherbonuspendingcash, {{ json_extract_scalar('statistic', ['voucherBonusSuccessCash'], ['voucherBonusSuccessCash']) }} as voucherbonussuccesscash, {{ json_extract_scalar('statistic', ['eventReferralPendingCash'], ['eventReferralPendingCash']) }} as eventreferralpendingcash, {{ json_extract_scalar('statistic', ['eventReferralSuccessCash'], ['eventReferralSuccessCash']) }} as eventreferralsuccesscash, {{ json_extract_scalar('statistic', ['promotionBonusPendingCash'], ['promotionBonusPendingCash']) }} as promotionbonuspendingcash, {{ json_extract_scalar('statistic', ['promotionBonusSuccessCash'], ['promotionBonusSuccessCash']) }} as promotionbonussuccesscash, {{ json_extract_scalar('statistic', ['transactionWaitingApprove'], ['transactionWaitingApprove']) }} as transactionwaitingapprove, {{ json_extract_scalar('statistic', ['commissionTransactionTotal'], ['commissionTransactionTotal']) }} as commissiontransactiontotal, {{ json_extract_scalar('statistic', ['membershipBonusPendingCash'], ['membershipBonusPendingCash']) }} as membershipbonuspendingcash, {{ json_extract_scalar('statistic', ['membershipBonusSuccessCash'], ['membershipBonusSuccessCash']) }} as membershipbonussuccesscash, {{ json_extract_scalar('statistic', ['commissionTransactionPending'], ['commissionTransactionPending']) }} as commissiontransactionpending, {{ json_extract_scalar('statistic', ['transactionPaymentProcessing'], ['transactionPaymentProcessing']) }} as transactionpaymentprocessing, {{ json_extract_scalar('statistic', ['commissionTransactionCashback'], ['commissionTransactionCashback']) }} as commissiontransactioncashback, {{ json_extract_scalar('statistic', ['commissionTransactionRejected'], ['commissionTransactionRejected']) }} as commissiontransactionrejected, {{ json_extract_scalar('statistic', ['commissionTransactionDelivered'], ['commissionTransactionDelivered']) }} as commissiontransactiondelivered, {{ json_extract_scalar('statistic', ['commissionTransactionDelivering'], ['commissionTransactionDelivering']) }} as commissiontransactiondelivering, {{ json_extract_scalar('statistic', ['revenueThisMonth_aibyte_transform'], ['revenueThisMonth_aibyte_transform']) }} as revenuethismonth_aibyte_transform, _airbyte_ab_id, _airbyte_emitted_at, {{ current_timestamp() }} as _airbyte_normalized_at from {{ ref('users') }} as table_alias -- statistic at users/statistic where 1 = 1 and statistic is not null