Fivetran Stripe

We display the source tables from the data warehouses to model.

account_data (first 100 rows)

id _fivetran_synced business_profile_mcc business_profile_name business_profile_product_description business_profile_support_address_city business_profile_support_address_country business_profile_support_address_line_1 business_profile_support_address_line_2 business_profile_support_address_postal_code business_profile_support_address_state business_profile_support_email business_profile_support_phone business_profile_support_url business_profile_url business_type capabilities_afterpay_clearpay_payments capabilities_au_becs_debit_payments capabilities_bacs_debit_payments capabilities_bancontact_payments capabilities_card_issuing capabilities_card_payments capabilities_cartes_bancaires_payments capabilities_eps_payments capabilities_fpx_payments capabilities_giropay_payments capabilities_grabpay_payments capabilities_ideal_payments capabilities_jcb_payments capabilities_legacy_payments capabilities_oxxo_payments capabilities_p_24_payments capabilities_platform_payments capabilities_sepa_debit_payments capabilities_sofort_payments capabilities_tax_reporting_us_1099_k capabilities_tax_reporting_us_1099_misc capabilities_transfers charges_enabled company_address_city company_address_country company_address_kana_city company_address_kana_country company_address_kana_line_1 company_address_kana_line_2 company_address_kana_postal_code company_address_kana_state company_address_kana_town company_address_kanji_city company_address_kanji_country company_address_kanji_line_1 company_address_kanji_line_2 company_address_kanji_postal_code company_address_kanji_state company_address_kanji_town company_address_line_1 company_address_line_2 company_address_postal_code company_address_state company_directors_provided company_executives_provided company_name company_name_kana company_name_kanji company_owners_provided company_phone company_structure company_tax_id_provided company_tax_id_registrar company_vat_id_provided company_verification_document_back company_verification_document_details company_verification_document_details_code company_verification_document_front country created default_currency details_submitted email individual_id is_deleted metadata payouts_enabled requirements_current_deadline requirements_currently_due requirements_disabled_reason requirements_errors requirements_eventually_due requirements_past_due requirements_pending_verification settings_branding_icon settings_branding_logo settings_branding_primary_color settings_card_payments_decline_on_avs_failure settings_card_payments_decline_on_cvc_failure settings_card_payments_statement_descriptor_prefix settings_dashboard_display_name settings_dashboard_timezone settings_payments_statement_descriptor settings_payments_statement_descriptor_kana settings_payments_statement_descriptor_kanji settings_payouts_debit_negative_balances settings_payouts_schedule_delay_days settings_payouts_schedule_interval settings_payouts_schedule_monthly_anchor settings_payouts_schedule_weekly_anchor settings_payouts_statement_descriptor tos_acceptance_date tos_acceptance_ip tos_acceptance_user_agent type
0 1234 2022-12-06 14:19:07 737 Hogwarts School of Witchcraft and Wizardry NaN Hogwarts US 123 Street Apt 123 12345 CA severus@hogwarts.com NaN https://www.wizardingworld.com/ https://www.wizardingworld.com/ NaN active NaN NaN active NaN active NaN active NaN active NaN active NaN NaN NaN active active active active NaN NaN NaN True NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN US NaN usd True dumbledore@hogwarts.com NaN False NaN True NaN NaN NaN NaN NaN NaN NaN NaN file_asdfasgas #0030ff NaN NaN NaN Hogwarts Inc. America/Los_Angeles hogwarts.com NaN NaN True 7 daily NaN NaN NaN NaN NaN NaN standard

balance_transaction_data (first 100 rows)

id _fivetran_synced amount available_on connected_account_id created currency description exchange_rate fee net source status type payout_id
0 txn_0IV4rIig6peNXzgDK3XAFbaN 2021-03-15 02:21:18 -18759 2021-03-16 00:00:00 NaN 2021-03-15 01:04:36 usd f39657a1847db73d9a2abb0bad3d31ae NaN 0 -18759 po_0IV4rIig6peNXzgD51VFKdaB pending payout po_0IV4rIig6peNXzgD51VFKdaB
1 txn_0IDYgiig6peNXzgDuNvLeoLR 2021-01-31 02:21:08 2040000 2021-02-01 00:00:00 NaN 2021-01-25 17:17:15 usd d267c9d09a2d1e50f12635bd2b56ed29 NaN 59190 1980810 ch_0IDYghig6peNXzgDhuOFKdTS pending charge po_0IFUKBig6peNXzgDZQM7WPAo
2 txn_0IG5fvig6peNXzgD8jemrxAp 2021-02-07 02:21:12 117524 2021-02-08 00:00:00 NaN 2021-02-01 16:54:54 usd 0662d6089789e1fabd56c6d55e91ef09 NaN 3438 114086 ch_0IG5fuig6peNXzgDzZkrO949 pending charge po_0II1gGig6peNXzgD4BxKEJJJ
3 txn_0ILGCbig6peNXzgDqjp7xaaX 2021-02-21 02:21:08 7239375 2021-02-22 00:00:00 NaN 2021-02-15 23:09:59 usd 612942eb1230077a0b1d066de5aba0db NaN 209972 7029403 ch_0ILGCZig6peNXzgDw4eVbq0v pending charge po_0IN6L6ig6peNXzgDu7m6fhRI
4 txn_0IO6DWig6peNXzgDF8qNjZNX 2021-03-01 02:21:13 255360 2021-03-02 00:00:00 NaN 2021-02-23 19:06:41 usd b8de27e00022f92981c965125c15c22d NaN 7435 247925 ch_0IO6DVig6peNXzgDgTOGtdeD pending charge po_0IQ08Sig6peNXzgDC6UG0Oxc
5 txn_0IROZoig6peNXzgDRsBjph8K 2021-03-10 02:21:13 438750 2021-03-11 00:00:00 NaN 2021-03-04 21:19:18 usd d3c18c425369d3c6b26126b7f791cf3f NaN 12754 425996 ch_0IROZmig6peNXzgDwohSYaPj pending charge po_0ITGUHig6peNXzgD78pmjvio
6 txn_0IT7uhig6peNXzgDolTgmiUJ 2021-03-15 02:21:18 19350 2021-03-16 00:00:00 NaN 2021-03-09 15:56:02 usd a29cfd524867f29bd7eddcb21fdf6e3b NaN 591 18759 ch_0IT7ugig6peNXzgDh9iGZed7 pending charge po_0IV4rIig6peNXzgD51VFKdaB
7 txn_0IUBwDig6peNXzgDCYCHC7gd 2021-03-13 14:21:36 3519960 2021-03-19 00:00:00 NaN 2021-03-12 14:26:00 usd e8be2b872cd9d14ddf3b5cd89860d551 NaN 137308 3382652 ch_0IUBwCig6peNXzgDTOTEw24B pending charge None
8 txn_0IUIaVig6peNXzgDoGvsNC17 2021-03-13 14:21:36 7499999 2021-03-19 00:00:00 NaN 2021-03-12 21:32:01 usd 9b8159d008204266ff7f2df19843d5b4 NaN 217530 7282469 ch_0IUIaTig6peNXzgDhyoZBxWv pending charge None

card_data (first 100 rows)

id _fivetran_synced account_id address_city address_country address_line_1 address_line_1_check address_line_2 address_state address_zip address_zip_check brand connected_account_id country created currency customer_id cvc_check dynamic_last_4 exp_month exp_year fingerprint funding is_deleted last_4 name network recipient tokenization_method metadata
0 pm_0IB5RYig6peNXzgDEpJNTma5 2021-01-24 20:21:25 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN SG 2021-02-12 02:21:07 usd NaN pass NaN 12 2024 dBtxWQhL5E69vKaA credit False 6002 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {}
1 pm_0ICE3kig6peNXzgDaIknpelY 2021-01-24 20:21:25 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN US 2021-02-12 02:21:07 usd NaN pass NaN 6 2025 8zjMKolROJb2DOfU credit False 1019 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {"external_id":"80755622-45b3-40a6-9544-55485215151"}
2 pm_0IBsCaig6peNXzgDJizDwm5N 2021-01-24 20:21:25 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN US 2021-02-12 02:21:07 usd NaN pass NaN 12 2023 vPwaBFU1Wv1CQqVm credit False 1101 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {}
3 pm_0IB5SCig6peNXzgDnoOeWOM2 2021-01-24 20:21:25 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN SG 2021-02-12 02:21:07 usd NaN pass NaN 12 2024 dBtxWQhL5E69vKaA credit False 6002 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {}
4 pm_0ICQWNig6peNXzgDdRO1sgVD 2021-01-24 20:21:25 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN US 2021-02-12 02:21:07 usd NaN pass NaN 5 2022 4Z2iVx6VARCRpNa1 credit False 1074 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {}
5 pm_0IDYghig6peNXzgDayKTgvhk 2021-01-25 20:21:09 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN US 2021-02-12 02:21:07 usd NaN pass NaN 6 2021 kfKa2SdMc7wknRvo credit False 7029 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {}
6 pm_0IEiyEig6peNXzgDQKMy0e9r 2021-01-29 02:21:11 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN US 2021-02-12 02:21:07 usd NaN pass NaN 11 2024 0RngWb400WEDhlk0 credit False 1003 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {}
7 pm_0IEj3Nig6peNXzgDca8CkzmS 2021-01-29 02:21:11 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN US 2021-02-12 02:21:07 usd NaN pass NaN 10 2025 tfeM21vlpK28vge1 credit False 7001 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {"external_id":"80755622-45b3-40a6-9544-44455582c"}
8 pm_0IOPFAig6peNXzgDe1tz420v 2021-02-24 20:21:16 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN US 2021-02-12 02:21:07 usd NaN pass NaN 3 2021 SHqULdMTagzWt3dY credit False 65 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {}
9 pm_0IOsAdig6peNXzgDvt1wyFWD 2021-02-26 02:21:09 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN SG 2021-02-12 02:21:07 usd NaN pass NaN 12 2024 dBtxWQhL5E69vKaA credit False 6002 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {}
10 pm_0IRmpUig6peNXzgDiWmECRTW 2021-03-06 02:21:12 NaN NaN NaN NaN NaN NaN NaN NaN NaN 553f65f270c86a4a05c964dc20e8cc70 NaN AU 2021-02-12 02:21:07 usd NaN pass NaN 3 2024 CbPvCaPZuJyEx9Fl credit False 1006 NaN 553f65f270c86a4a05c964dc20e8cc70 NaN NaN {"external_id":"80755622-45b3-40a6-9544-25554515"}

charge_data (first 100 rows)

id _fivetran_synced amount amount_refunded application application_fee_amount balance_transaction_id bank_account_id captured card_id connected_account_id created currency customer_id description destination failure_code failure_message fraud_details_stripe_report fraud_details_user_report invoice_id livemode metadata on_behalf_of outcome_network_status outcome_reason outcome_risk_level outcome_risk_score outcome_seller_message outcome_type paid payment_intent_id receipt_email receipt_number receipt_url refunded shipping_address_city shipping_address_country shipping_address_line_1 shipping_address_line_2 shipping_address_postal_code shipping_address_state shipping_carrier shipping_name shipping_phone shipping_tracking_number source_id source_transfer statement_descriptor status transfer_data_destination transfer_group transfer_id calculated_statement_descriptor
0 ch_0IMDAfig6peNXzgDJYQKfT3B 2021-02-18 14:21:50 3293232 0 None NaN NaN NaN False pm_0Hr3Oyig6peNXzgDkOfs9Dqm NaN 2021-02-18 14:07:57 usd cus_IRb688lkE0TnTM 068dfcec35b4d2eb8e5655783b40608e NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDAfig6peNXzgDnE8UotlM 32beaaeef4e37a5d19f8bafc1a1631c2 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
1 ch_0IMDAVig6peNXzgDHlr1zyyW 2021-02-18 14:21:50 2040000 0 None NaN NaN NaN False pm_0Hj3Mhig6peNXzgDeAoKLH7U NaN 2021-02-18 14:07:47 usd cus_IHmGn2733l3GK6 403e2c77a9041c677cb45b09d65a2636 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDAVig6peNXzgDJXuKVLtD e9e8ea6013cb5c982f71b5247c98be65 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
2 ch_0IMD9Yig6peNXzgDUvMKMSla 2021-02-18 14:21:50 4071 0 None NaN NaN NaN False pm_0HfVlUig6peNXzgDvnqkgdRQ NaN 2021-02-18 14:06:48 usd cus_IEXWsmR0hA8iGL d36f9f0f170bb3069a9b1d7055c8b412 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMD9Yig6peNXzgDtgkX3pjH ab11bebc20a2f74af38dc1f84d33e759 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
3 ch_0IMDGtig6peNXzgD1jdR6t7Y 2021-02-18 20:21:08 197391 0 None NaN NaN NaN False pm_0I3Nemig6peNXzgDdDSfZXb9 NaN 2021-02-18 14:14:23 usd cus_IegzSpQ6V9deOW f794a8544921fbec51dd986d00a443f8 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDGtig6peNXzgDCuzBH6xK 24a64fea88592b8a7bb9783eeb93f4c5 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
4 ch_0IMDLjig6peNXzgDQ0WJ7OtY 2021-02-18 20:21:09 15000 0 None NaN NaN NaN False pm_0Hw4QGig6peNXzgDCwWwFnh0 NaN 2021-02-18 14:19:23 usd cus_IX8c0jeM4yuzDn cda6649904149ac57765d9deac2263e6 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDLjig6peNXzgDppN3qSTF eb27183b771710ba705cc3d1f10be3fd NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
5 ch_0IMD9Wig6peNXzgDHxwWBPEZ 2021-02-18 14:21:50 183000 0 None NaN NaN NaN False pm_0HnC5mig6peNXzgDXSNeK1Bu NaN 2021-02-18 14:06:46 usd cus_INy1KScKAog1uS 3944b9f788ae4e71b100786be80205de NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMD9Vig6peNXzgDQxQe1FHT 6e05435f9bf429c0fb659a54fd7529b8 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
6 ch_0IMDDQig6peNXzgDah11dNBN 2021-02-18 14:21:50 243500 0 None NaN NaN NaN False pm_0HnC5mig6peNXzgDXSNeK1Bu NaN 2021-02-18 14:10:48 usd cus_INy1KScKAog1uS dd43606ef2262a592ebf62590c9d4df5 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDDQig6peNXzgDaC9Gjkx0 6e05435f9bf429c0fb659a54fd7529b8 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
7 ch_0IMDDUig6peNXzgDyqDvLubr 2021-02-18 14:21:50 2786 0 None NaN NaN NaN False pm_0HfVlUig6peNXzgDvnqkgdRQ NaN 2021-02-18 14:10:52 usd cus_IEXWsmR0hA8iGL 7ae43df98d8720a8f8fa6cc2d7987552 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDDUig6peNXzgDsuEhnuAl ab11bebc20a2f74af38dc1f84d33e759 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
8 ch_0IMDEuig6peNXzgDkP5uU3im 2021-02-18 20:21:07 73650 0 None NaN NaN NaN False pm_0Hpc71ig6peNXzgDy1i9s6en NaN 2021-02-18 14:12:20 usd cus_IQT24DskOLZ2yF 95175f4654496b92456b626a93b7ac33 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDEuig6peNXzgDqEn5B1gv 9cad6f0e0c1dff3dd27a98ee7fa4ff40 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
9 ch_0IMDJ3ig6peNXzgD5HDCXZGY 2021-02-18 20:21:08 25600 0 None NaN NaN NaN False pm_0I6fuwig6peNXzgDpmJZOcbj NaN 2021-02-18 14:16:37 usd cus_I5NJ6elPyrZHfj a4a3c49803b2e7ab42c1f6de44197126 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDJ3ig6peNXzgDjJpHOesH 5eb7cf4a91f5aadf5a52479989bc55ed NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
10 ch_0IMD9pig6peNXzgD5E7v2nk3 2021-02-18 14:21:50 69750 0 None NaN NaN NaN False pm_0Hpc71ig6peNXzgDy1i9s6en NaN 2021-02-18 14:07:05 usd cus_IQT24DskOLZ2yF 0b3c44516e5462c35367b3bed49b4a4d NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMD9oig6peNXzgD8rGMNoRL 9cad6f0e0c1dff3dd27a98ee7fa4ff40 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
11 ch_0IMD9dig6peNXzgD3i6CTeP6 2021-02-18 14:21:50 160700 0 None NaN NaN NaN False pm_0Hnu2tig6peNXzgDeQNHwzSV NaN 2021-02-18 14:06:53 usd cus_IOhGAHpVOsOV99 d871ea4e3c6b57da4750add9e8da62ae NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMD9dig6peNXzgDSLNX3MAL 9bd8e73d66d10af5cb18588b9e7c3872 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
12 ch_0IMDH8ig6peNXzgDku6HtBcQ 2021-02-18 20:21:08 24592 0 None NaN NaN NaN False pm_0I3saBig6peNXzgDVgYNcLHV NaN 2021-02-18 14:14:38 usd cus_IfCy5uUXv2MDT0 e1f0c035dbb83e796ffac9c71d94b138 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDH7ig6peNXzgD3IFw1Ss8 a5548420ede4e57b3e2fe16a984f851d NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
13 ch_0IMDA2ig6peNXzgDU9JZdY1J 2021-02-18 14:21:50 109800 0 None NaN NaN NaN False pm_0Hj3Mhig6peNXzgDeAoKLH7U NaN 2021-02-18 14:07:18 usd cus_IHmGn2733l3GK6 ed23dd0d8e2a65a9980b08d23c73360d NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDA2ig6peNXzgDDcfY1N2L e9e8ea6013cb5c982f71b5247c98be65 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
14 ch_0IMDJyig6peNXzgDngzT0dAy 2021-02-18 20:21:09 117100 0 None NaN NaN NaN False pm_0Hj3Mhig6peNXzgDeAoKLH7U NaN 2021-02-18 14:17:34 usd cus_IHmGn2733l3GK6 75b420f296d4874b1fd7c70eb3630cfa NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDJyig6peNXzgD4Ghvs0zF e9e8ea6013cb5c982f71b5247c98be65 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb
15 ch_0IGmOVig6peNXzgDFYDv1XdZ 2021-02-03 20:21:21 117524 0 ca_8Spi8Y6vQsJEmSegXeWoWPihihlqB3kC NaN NaN NaN False card_Gti5RQklrpVVJ2 NaN 2021-02-03 14:31:47 usd cus_F4zOnlDjqyZKdP 61721ad6e321cf891a91d20b397a4fd4 NaN card_declined Your card was declined. NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} NaN declined_by_network do_not_honor normal NaN The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IGmOVig6peNXzgDoFcKFzqx bd6a239ac7909ad0fe72d99b6d464a24 NaN NaN False NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN failed NaN NaN NaN 6f867b34cbc9bf57509503b3123a2ecb

credit_note_data (first 100 rows)

id amount created currency discount_amount subtotal total livemode memo metadata number pdf reason status type voided_at customer_balance_transaction_id invoice_id refund_id _fivetran_synced
0 cn_89hUNfs 50 2021-06-30 10:04:03.000 usd 0 50 50 True NaN {} E89505E-0024-CN-01 https://pay.stripe.com/credit_notes/acct_test/cnst_test/pdf NaN issued post_payment NaN NaN in_1J7DINLdeVo re_1J82INYKl7x 2021-06-30 12:28:54
1 cn_Jg3Jf0s 100 2021-03-15 17:44:14.000 usd 0 100 100 False NaN {} 450DS21-0034-CN-01 https://pay.stripe.com/credit_notes/acct_test2/cnst_test2/pdf NaN issued post_payment NaN NaN in_1IPp7kCLA0Q re_1IKhINvmkAi 2021-04-12 17:18:50

credit_note_line_item_data (first 100 rows)

credit_note_id id amount discount_amount description livemode quantity type unit_amount unit_amount_decimal _fivetran_synced
0 cn_89hUNfs cnli_H7kCLAE 50 0 description_here True 10 custom_line_item 5 494 2021-04-12 17:18:50
1 cn_Jg3Jf0s cnli_1HuHLafV 100 0 description_here False 1 invoice_line_item 100 1000 2021-04-12 17:18:50

customer_data (first 100 rows)

id _fivetran_synced account_balance address_city address_country address_line_1 address_line_2 address_postal_code address_state balance bank_account_id created currency default_card_id delinquent description email invoice_prefix invoice_settings_default_payment_method invoice_settings_footer is_deleted livemode name phone shipping_address_city shipping_address_country shipping_address_line_1 shipping_address_line_2 shipping_address_postal_code shipping_address_state shipping_carrier shipping_name shipping_phone shipping_tracking_number source_id tax_exempt tax_info_tax_id tax_info_type tax_info_verification_status tax_info_verification_verified_name
0 cus_ImVzJQmSlYHjZL 2021-01-24 20:21:16 0 NaN NaN NaN NaN NaN NaN 0 None 2021-01-18 12:35:30 NaN NaN False NaN NaN 8311D827 NaN NaN False True a0d47e7c5acc1069de81fd0ac370d10f NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
1 cus_IzaB1l1LWzI6DZ 2021-02-22 14:21:04 0 NaN NaN NaN NaN NaN NaN 0 None 2021-02-22 09:48:04 NaN NaN False NaN NaN 79EDFB49 NaN NaN False True 0d080bf0b4e2e0cce69b285046962a7b NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
2 cus_J2eHEreSmx1eAe 2021-03-02 20:21:09 0 NaN NaN NaN NaN NaN NaN 0 None 2021-03-02 14:13:25 NaN NaN False NaN NaN B3530880 NaN NaN False True fc48fc29ca836fb38f6d81a99fa4204e NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
3 cus_IxqxnofljLKmqa 2021-02-17 20:21:10 0 NaN NaN NaN NaN NaN NaN 0 None 2021-02-17 18:59:27 NaN NaN False NaN NaN 612C196A NaN NaN False True 37bac6dce4f46277d89bfa3003e2e39b NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
4 cus_J66nsZHMTFup1P 2021-03-11 20:21:13 0 NaN NaN NaN NaN NaN NaN 0 None 2021-03-11 19:53:45 NaN NaN False NaN NaN 446D4207 NaN NaN False True b65dc7a76139fc06725caccf229004c2 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
5 cus_IvSD6mXKJ1pZeW 2021-02-11 14:21:12 0 NaN NaN NaN NaN NaN NaN 0 None 2021-02-11 09:18:04 NaN NaN False NaN NaN 89291D20 NaN NaN False True 6025a593946d5965fdf7c7365e25c33f NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
6 cus_IrpAwGHpPSwzWv 2021-02-01 20:21:17 0 NaN NaN NaN NaN NaN NaN 0 None 2021-02-01 16:45:09 NaN NaN False NaN NaN F0F08B37 NaN NaN False True dcddf44d3df6437334f3491ed8c52bf2 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
7 cus_IpSJ4exzUAFTHX 2021-01-26 14:21:03 0 NaN NaN NaN NaN NaN NaN 0 None 2021-01-26 08:59:52 NaN NaN False NaN NaN B761C599 NaN NaN False True 93f783b4d19fb35f9522de6fef236d98 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
8 cus_IvcMWh1c3qNhie 2021-02-11 20:22:51 0 NaN NaN NaN NaN NaN NaN 0 None 2021-02-11 19:46:48 NaN NaN False NaN NaN 08D6093C NaN NaN False True c31eed413e5e7ea16023bcfa3a4e5e55 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
9 cus_J2lfqeIO1HDfEy 2021-03-03 08:21:17 0 NaN NaN NaN NaN NaN NaN 0 None 2021-03-02 21:51:56 NaN NaN False NaN NaN 934E47FE NaN NaN False True e6fe1559d8fe8d56ec8e4b58bde4916e NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
10 cus_J0nHRNKalyp1TX 2021-02-25 20:21:08 0 NaN NaN NaN NaN NaN NaN 0 None 2021-02-25 15:23:42 NaN NaN False NaN NaN 3D83A36A NaN NaN False True 6ff9f4444ac481652f4412b5e1623846 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN
11 cus_IuKuZJLG9mNRn2 2021-02-08 14:21:18 0 NaN NaN NaN NaN NaN NaN 0 ab5568 2021-02-08 09:40:39 NaN NaN False NaN NaN 94FA9348 NaN NaN True True 37a6259cc0c1dae299a7866489dff0bd NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN none NaN NaN NaN NaN

dispute_data (first 100 rows)

id _fivetran_synced amount balance_transaction charge_id connected_account_id created currency evidence_access_activity_log evidence_billing_address evidence_cancellation_policy evidence_cancellation_policy_disclosure evidence_cancellation_rebuttal evidence_customer_communication evidence_customer_email_address evidence_customer_name evidence_customer_purchase_ip evidence_customer_signature evidence_details_due_by evidence_details_has_evidence evidence_details_past_due evidence_details_submission_count evidence_duplicate_charge_documentation evidence_duplicate_charge_explanation evidence_duplicate_charge_id evidence_product_description evidence_receipt evidence_refund_policy evidence_refund_policy_disclosure evidence_refund_refusal_explanation evidence_service_date evidence_service_documentation evidence_shipping_address evidence_shipping_carrier evidence_shipping_date evidence_shipping_documentation evidence_shipping_tracking_number evidence_uncategorized_file evidence_uncategorized_text is_charge_refundable livemode metadata reason status
0 du_0MmTsrig6peNXzgD4bsS3XWF 2023-06-02 08:23:57 1234 txn_0MmTt4ig6peNXzgDDEp8wsKh ch_2MZdKRig6peNXzgD0EygIk7l NaN 2023-03-17 03:23:13 usd NaN None NaN NaN NaN NaN None None None NaN 2023-04-26 23:59:59.000000 UTC True False 1 NaN NaN NaN NaN None NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN True True "{"netsuite_credit_memo_id":"3324234","netsuite_credit_memo_link":"https://en.wikipedia.org/wiki/Brave_New_World","netsuite_customer_refund_id":"3524872","netsuite_customer_refund_link":"https://en.wikipedia.org/wiki/Aldous_Huxley"}" product_unacceptable won
1 du_0Lvivfig6peNXzgD33SIekHq 2022-12-21 20:19:05 3333 txn_0LviwVig6peNXzgDkSPS1Y1C ch_2LqbkJig6peNXzgD1jG4Xy7z NaN 2022-10-22 14:44:03 usd NaN None NaN NaN NaN NaN None None None NaN 2022-11-17 23:59:59.000000 UTC False False 1 NaN NaN NaN NaN None NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN True True None general won
2 du_0KHowkig6peNXzgDyhndDHOe 2022-09-23 00:00:24 3331 txn_0KHoxcig6peNXzgDKWarDbF0 ch_2JtdoJig6peNXzgD1lCAvXwG NaN 2022-01-14 12:31:58 usd NaN 1600 Pennsylvania Avenue NW, Washington, DC 20500 NaN NaN NaN NaN hello@bravenewworld.com Aldous Huxley 68.1.21.555 NaN 2022-02-09 23:59:59.000000 UTC False False 1 NaN NaN NaN NaN file_0KHowoig6peNXzgDyeDmylk3 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN True True None general won
3 du_0M9SJTig6peNXzgD58OLM8Mz 2022-12-12 20:19:03 1099 txn_0M9SKaig6peNXzgDlb5cqlBg ch_2M2d6mig6peNXzgD03nrNVYZ NaN 2022-11-29 11:49:23 usd NaN None NaN NaN NaN NaN None None None NaN 2022-12-25 23:59:59.000000 UTC False False 0 NaN NaN NaN NaN None NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN False True None subscription_canceled lost
4 du_0LuGYgig6peNXzgDM8lPBTFC 2022-11-14 14:21:25 1222 txn_0LuGZyig6peNXzgDLgWzetHo ch_2LUt28ig6peNXzgD0RdFu0qW NaN 2022-10-18 14:14:18 usd NaN None NaN NaN NaN NaN None None None NaN 2022-11-13 23:59:59.000000 UTC False False 0 NaN NaN NaN NaN None NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN False True None subscription_canceled lost
5 du_0LyvFuig6peNXzgDyBMCjDi6 2022-11-27 14:20:24 221244 txn_0LyvHhig6peNXzgDg5LanDAq ch_2Lqdeuig6peNXzgD0sA3iBuH NaN 2022-10-31 10:30:10 usd NaN None NaN NaN NaN NaN None None None NaN 2022-11-26 23:59:59.000000 UTC False False 0 NaN NaN NaN NaN None NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN False True None subscription_canceled lost
6 du_0LiAl6ig6peNXzgDEejs24CE 2022-11-13 20:20:09 432532 txn_0Lumheig6peNXzgDSp1KIXph ch_2LVoJuig6peNXzgD1DvyohjD NaN 2022-09-15 05:37:08 usd NaN None NaN NaN NaN NaN None None None NaN 2022-11-12 23:59:59.000000 UTC False False 0 NaN NaN NaN NaN None NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN False True None general lost
7 du_0M9ScVig6peNXzgDkfd7tUNb 2022-12-12 20:19:03 1400 txn_0M9SdPig6peNXzgDgpb4aJDQ ch_2LqcRzig6peNXzgD06FImTqU NaN 2022-11-29 12:09:03 usd NaN None NaN NaN NaN NaN None None None NaN 2022-12-25 23:59:59.000000 UTC False False 0 NaN NaN NaN NaN None NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN False True None subscription_canceled lost
8 du_0LuGd7ig6peNXzgDUxXx85wF 2022-11-14 14:21:25 1400 txn_0LuGe5ig6peNXzgD7PMfTzJ6 ch_2LfkHjig6peNXzgD1e9ltqQt NaN 2022-10-18 14:18:53 usd NaN None NaN NaN NaN NaN None None None NaN 2022-11-13 23:59:59.000000 UTC False False 0 NaN NaN NaN NaN None NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN False True None subscription_canceled lost
9 du_0LuGbbig6peNXzgDjHA4RfoT 2022-11-14 14:21:25 700 txn_0LuGcrig6peNXzgDKP5y95T9 ch_2LLwgKig6peNXzgD0Sr5X6kL NaN 2022-10-18 14:17:19 usd NaN None NaN NaN NaN NaN None None None NaN 2022-11-13 23:59:59.000000 UTC False False 0 NaN NaN NaN NaN None NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN False True None subscription_canceled lost

fee_data (first 100 rows)

balance_transaction_id index_ _fivetran_synced amount application connected_account_id currency description type
0 txn_0IC7txig6peNXzgD0BI1c5fq 0 2021-01-24 20:21:24 9281 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
1 txn_0IC9dPig6peNXzgDaOTwBq8B 0 2021-01-24 20:21:24 22215 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
2 txn_0IC7bOig6peNXzgDE6EeCW6p 0 2021-01-24 20:21:24 99 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
3 txn_0ICQWOig6peNXzgD2Cn5HdMK 0 2021-01-24 20:21:24 9456 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
4 txn_0ICE3lig6peNXzgDvwFP6Cgz 0 2021-01-24 20:21:24 10484 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
5 txn_0IC5tfig6peNXzgDxCGsg0DR 0 2021-01-24 20:21:24 10535 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
6 txn_0IBsCcig6peNXzgDEDePzZOD 0 2021-01-24 20:21:24 3117 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
7 txn_0IBJOlig6peNXzgDgRlNX2UI 0 2021-01-24 20:21:24 99480 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
8 txn_0IBoyeig6peNXzgDkINDi0wS 0 2021-01-24 20:21:24 88409 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
9 txn_0IBT4Oig6peNXzgDWT3wbNp1 0 2021-01-24 20:21:24 25405 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
10 txn_0IBm5Yig6peNXzgDk1LI4JCA 0 2021-01-24 20:21:24 25405 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
11 txn_0IBtOoig6peNXzgDbrhw4CcH 0 2021-01-24 20:21:24 17430 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
12 txn_0IBft3ig6peNXzgDoG5KpDGo 0 2021-01-24 20:21:24 19605 NaN NaN usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4

invoice_data (first 100 rows)

id _fivetran_synced amount currency customer_id date_ description discountable invoice_id is_deleted livemode period_end period_start proration quantity subscription_id subscription_item_id unit_amount
0 ab1111 2021-02-18 14:16:37 45 usd sdgfs84854 NaN description_here True sdg545641 False True 2021-02-19 14:16:37 2021-02-18 14:16:37 True 45 sdkhg54645 kdshg455 5
1 si8jo54 2021-02-18 14:16:37 22 usd dfd54654 NaN description_here True dgjksg6486 False False 2021-02-19 14:16:37 2021-02-18 14:16:37 False 55 dghisd165748 sgdfs5464 6

invoice_line_item_data (first 100 rows)

id invoice_id _fivetran_synced amount currency description discountable livemode period_end period_start plan_id proration quantity subscription_id subscription_item_id type unique_id metadata
0 ad1111 ab1111 2021-02-18 14:16:37 21 usd description_here False True 2021-02-19 14:16:37 2021-02-18 14:16:37 sg555 True 5 sg888 sdm99 NaN gg665 {}
1 ba222 bd665 2021-02-18 14:16:37 65 usd description_here True True 2021-02-19 14:16:37 2021-02-18 14:16:37 sdgf5575 False 4 dfs8645 sdgjk5489 NaN dsgjnik978 {"external_id":"1111111-2222-3333-4444-55555555"}

payment_intent_data (first 100 rows)

id _fivetran_synced amount amount_capturable amount_received application application_fee_amount canceled_at cancellation_reason capture_method confirmation_method created currency customer_id description last_payment_error_charge_id last_payment_error_code last_payment_error_decline_code last_payment_error_doc_url last_payment_error_message last_payment_error_param last_payment_error_source_id last_payment_error_type livemode on_behalf_of payment_method_id receipt_email source_id statement_descriptor status transfer_data_destination transfer_group
0 pi_0IEpzwig6peNXzgDxFY8plfJ 2021-01-29 08:21:13 67845 0 67845 None NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-01-29 05:58:24 usd cus_I0JJf8lbCaJBZS f1df1d3d813e93b0093ada118723aa23 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IEij1ig6peNXzgDQeigpAeH None NaN NaN succeeded NaN NaN
1 pi_0IEq0wig6peNXzgD0BPTgrg3 2021-01-29 08:21:13 14154 0 14154 None NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-01-29 05:59:26 usd cus_I0JJf8lbCaJBZS f1df1d3d813e93b0093ada118723aa23 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IEij1ig6peNXzgDQeigpAeH None NaN NaN succeeded NaN NaN
2 pi_0IEq1qig6peNXzgDlfK6CSfM 2021-01-29 08:21:13 11976 0 11976 None NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-01-29 06:00:22 usd cus_I0JJf8lbCaJBZS f1df1d3d813e93b0093ada118723aa23 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IEij1ig6peNXzgDQeigpAeH None NaN NaN succeeded NaN NaN
3 pi_0IJbnkig6peNXzgD0yXQHZac 2021-02-11 14:21:14 60000 0 60000 None NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-02-11 09:49:32 usd cus_IrzdXtpzmRAOIT f1df1d3d813e93b0093ada118723aa23 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IGFjsig6peNXzgDBI2hCfL5 None NaN NaN succeeded NaN NaN
4 pi_0IJboeig6peNXzgD2wQr6zRO 2021-02-11 14:21:14 32300 0 32300 None NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-02-11 09:50:28 usd cus_IrzdXtpzmRAOIT f1df1d3d813e93b0093ada118723aa23 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IGFjsig6peNXzgDBI2hCfL5 None NaN NaN succeeded NaN NaN
5 pi_0IJbq9ig6peNXzgD66itql9S 2021-02-11 14:21:14 2700 0 2700 None NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-02-11 09:52:01 usd cus_IrzdXtpzmRAOIT f1df1d3d813e93b0093ada118723aa23 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IGFjsig6peNXzgDBI2hCfL5 None NaN NaN succeeded NaN NaN
6 pi_0IJbpHig6peNXzgDIcI1DH9B 2021-02-11 14:21:14 7600 0 7600 None NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-02-11 09:51:07 usd cus_IrzdXtpzmRAOIT f1df1d3d813e93b0093ada118723aa23 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IGFjsig6peNXzgDBI2hCfL5 None NaN NaN succeeded NaN NaN
7 pi_0IB5RYig6peNXzgDaRjzw1rZ 2021-01-24 20:21:20 190800 0 190800 ca_8Spi8Y6vQsJEmSegXeWoWPihihlqB3kC NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-01-18 21:39:24 usd None c76e09d8a163526a171f372fce170129 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IB5RYig6peNXzgDEpJNTma5 222a0f40559271ab98c3046c9d03f2da NaN NaN succeeded NaN NaN
8 pi_0IB5SCig6peNXzgDsyG4fPpk 2021-01-24 20:21:20 148500 0 148500 ca_8Spi8Y6vQsJEmSegXeWoWPihihlqB3kC NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-01-18 21:40:04 usd None c76e09d8a163526a171f372fce170129 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IB5SCig6peNXzgDnoOeWOM2 222a0f40559271ab98c3046c9d03f2da NaN NaN succeeded NaN NaN
9 pi_0IBJOjig6peNXzgDfdxPzsoh 2021-01-24 20:21:20 2550000 0 2550000 ca_8Spi8Y6vQsJEmSegXeWoWPihihlqB3kC NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-01-19 12:33:25 usd None c76e09d8a163526a171f372fce170129 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IBJOjig6peNXzgDrwox8suf 1d256ae8550cb70df1cf19978c900874 NaN NaN succeeded NaN NaN
10 pi_0IBm5Xig6peNXzgDfbem16Ks 2021-01-24 20:21:20 875000 0 875000 ca_8Spi8Y6vQsJEmSegXeWoWPihihlqB3kC NaN 2021-02-12 02:21:07 NaN automatic automatic 2021-01-20 19:11:31 usd None c76e09d8a163526a171f372fce170129 NaN NaN NaN NaN NaN NaN NaN NaN True NaN pm_0IBm5Xig6peNXzgDkUtpXzZT a665a3fbf734bdacfa4f6212f4ec2dcb NaN NaN succeeded NaN NaN

payment_method_card_data (first 100 rows)

payment_method_id _fivetran_synced brand charge_id description fingerprint funding type wallet_type
0 pm_0ISrBXig6peNXzgD6hYaUH2Z 2021-03-09 02:21:10 553f65f270c86a4a05c964dc20e8cc70 NaN NaN iVwXZtKtbkTtJpN0 credit NaN NaN
1 pm_0IStqWig6peNXzgDEGg3esc8 2021-03-09 02:21:10 553f65f270c86a4a05c964dc20e8cc70 NaN NaN PBYmzFcBM1pwHfTQ credit NaN NaN
2 pm_0ISornig6peNXzgDOeZ25NDW 2021-03-08 20:21:08 553f65f270c86a4a05c964dc20e8cc70 NaN NaN fqtU9wYRQpmzlc4A credit NaN NaN
3 pm_0ITGJgig6peNXzgDdqU3vem1 2021-03-10 02:21:09 553f65f270c86a4a05c964dc20e8cc70 NaN NaN t1Z14pQbLsAtxb3N credit NaN NaN
4 pm_0ITo6Eig6peNXzgDSGO9wikO 2021-03-11 14:21:21 553f65f270c86a4a05c964dc20e8cc70 NaN NaN k2VOC54Kv0y6ju1j credit NaN NaN
5 pm_0ITpNsig6peNXzgD6eKsQGnb 2021-03-11 20:21:11 553f65f270c86a4a05c964dc20e8cc70 NaN NaN Dd3yZ5fegTpHhPvk credit NaN NaN
6 pm_0ITr6jig6peNXzgDA6dTn2KI 2021-03-11 20:21:15 553f65f270c86a4a05c964dc20e8cc70 NaN NaN JEtovVIKPa7HmNlB credit NaN NaN
7 card_0IUBw6ig6peNXzgDLOJ0s9oJ 2021-03-12 20:21:05 553f65f270c86a4a05c964dc20e8cc70 NaN NaN GnaMObYOxVfGvuVC credit NaN NaN
8 pm_0IUGRYig6peNXzgDeUWYzAZx 2021-03-12 20:21:07 553f65f270c86a4a05c964dc20e8cc70 NaN NaN HkQVKOdMfx7OQGlz credit NaN NaN
9 pm_0IHlxQig6peNXzgDPbBTz3wN 2021-02-06 14:21:10 553f65f270c86a4a05c964dc20e8cc70 NaN NaN xt3IXBWUo94YvvyJ credit NaN NaN
10 pm_0IQaNxig6peNXzgDjLiWdPq7 2021-03-02 20:21:11 553f65f270c86a4a05c964dc20e8cc70 NaN NaN 3okrxlVqFJe4eFLP credit NaN NaN

payment_method_data (first 100 rows)

id _fivetran_synced billing_detail_address_city billing_detail_address_country billing_detail_address_line_1 billing_detail_address_line_2 billing_detail_address_postal_code billing_detail_address_state billing_detail_email billing_detail_name billing_detail_phone created customer_id livemode type
0 pm_0IT7ufig6peNXzgDtFEUcWQq 2021-03-09 20:21:14 NaN NaN NaN NaN fbed5cdfc14c8acab8bfc6fc608b57f3 NaN 29074c94bcd7496666c2516bdb84464a 29074c94bcd7496666c2516bdb84464a NaN 2021-03-09 15:56:01 None True card
1 card_0IDuzgig6peNXzgDiedW46Fs 2021-01-26 20:22:37 NaN NaN NaN NaN 61ee93b89af4fccf77f604ddbdbfc508 NaN None 00b659ac6a3cdb5afc520be084f0810a NaN 2021-01-26 17:06:20 cus_IITpWhRKEpP8oQ True card
2 card_0IC7trig6peNXzgDuVtbBvrq 2021-01-24 20:21:14 NaN NaN NaN NaN 37a6259cc0c1dae299a7866489dff0bd NaN None af5da2c2d7e449fe0cff743e114893d9 NaN 2021-01-21 18:28:55 cus_GrTE2lUSyzG85x True card
3 card_GQxHpPyKWUVsRS 2021-03-06 20:21:06 NaN NaN NaN NaN f55e51631ea375b777ec380d7d6804b8 NaN None 75b77af238c31ba9b1b89e29a3a81053 NaN 2021-03-06 17:46:13 cus_GQxHnIOOpXDmHp True card
4 card_0IHGUUig6peNXzgD2fQWkF2H 2021-02-05 02:21:07 NaN NaN NaN NaN 8f84fb5cdc0dd814d6aeb4e78fc41845 NaN None 00e1c9acc02a44880a725c24482a2bb9 NaN 2021-02-04 22:39:58 cus_It2ZjcDAnrL4fN True card
5 card_0IO6DQig6peNXzgDzSyyQxed 2021-02-23 20:21:15 NaN NaN NaN NaN 94472fbf2a4233129e7eb05c77f3321e NaN None 201636b0ecc8bf4962b2426d7b292c34 NaN 2021-02-23 19:06:36 cus_J06QWm1jiY7XUw True card
6 card_0IO8mGig6peNXzgD05gU9Nea 2021-02-24 02:21:09 NaN NaN NaN NaN 37a6259cc0c1dae299a7866489dff0bd NaN None 564048e93b6096f5cb8db8ed73d3dcab NaN 2021-02-23 21:50:44 cus_J0940I34bEZxFW True card
7 card_HC20VgUIY5YKcR 2021-02-05 20:21:13 NaN NaN NaN NaN 489981404dd301a023c9f75abed505f3 NaN None 845b3e75a0227dddd8e1f0e08c1c5aaf NaN 2021-02-05 17:22:10 cus_HC20s92vymipWS True card
8 card_0IK2uDig6peNXzgDYgtvZhx1 2021-02-12 20:21:08 NaN NaN NaN NaN 44fdc5ad1a08aace32d53264bc95a4b7 NaN None 63b43b7208989dbc6450746a34160a0c NaN 2021-02-12 14:46:01 cus_IvujSQV90Rsk6P True card
9 card_0IBT4Hig6peNXzgD2UDI98rg 2021-01-24 20:21:11 NaN NaN NaN NaN 65e512403849d438dc08889bf6461073 NaN None a665a3fbf734bdacfa4f6212f4ec2dcb NaN 2021-01-19 22:52:57 cus_In3AMjd2X4TLgj True card
10 card_0IUBw6ig6peNXzgDLOJ0s9oJ 2021-03-12 20:21:05 NaN NaN NaN NaN 4674554ec907d598a620d5b131a9f685 NaN None ae369c63d0f28eb65c99d8dccd3e5e6b NaN 2021-03-12 14:25:54 cus_J6OjltyC6E9zos True card
11 pm_0HWPPYig6peNXzgDYaytTYRk 2021-02-12 02:21:07 NaN NaN NaN NaN 4674554ec907d598a620d5b131a9f685 NaN 6601a62d87cfb0d57bad7610e7d3db63 6601a62d87cfb0d57bad7610e7d3db63 NaN 2020-09-28 16:41:12 None True card
12 pm_0I1Bvcig6peNXzgDj0JyN58m 2021-02-12 02:21:07 NaN NaN NaN NaN d41d8cd98f00b204e9800998ecf8427e NaN 6601a62d87cfb0d57bad7610e7d3db63 6601a62d87cfb0d57bad7610e7d3db63 NaN 2020-12-22 14:33:32 None True card

payout_data (first 100 rows)

id _fivetran_synced amount arrival_date automatic balance_transaction_id connected_account_id created currency description destination_bank_account_id destination_card_id failure_balance_transaction_id failure_code failure_message livemode metadata method source_type statement_descriptor status type
0 po_0IB8cXig6peNXzgDJWLvHBB7 2021-01-24 20:21:25 3029432 2021-01-20 00:00:00 True txn_0IB8cXig6peNXzgDppfO2tfk NaN 2021-01-19 01:02:57 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN paid bank_account
1 po_0IBrZLig6peNXzgD7Q0he6QN 2021-01-24 20:21:25 326282 2021-01-22 00:00:00 True txn_0IBrZLig6peNXzgDfFANob1M NaN 2021-01-21 01:02:39 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN paid bank_account
2 po_0ICwzpig6peNXzgDqW5S9QbF 2021-01-24 20:21:26 326007 2021-01-25 00:00:00 True txn_0ICwzpig6peNXzgDhkqfC7lv NaN 2021-01-24 01:02:29 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
3 po_0IDJVZig6peNXzgDCa4dLDjL 2021-01-25 02:21:53 3300115 2021-01-26 00:00:00 True txn_0IDJVZig6peNXzgD8oPNqfSe NaN 2021-01-25 01:04:45 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
4 po_0IDfx4ig6peNXzgD2NiVJ5ld 2021-01-26 02:21:12 4464139 2021-01-27 00:00:00 True txn_0IDfx4ig6peNXzgDOvqZCzzq NaN 2021-01-26 01:02:38 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
5 po_0IE2QFig6peNXzgDCoJMX6xo 2021-01-27 02:21:10 -833651 2021-01-28 00:00:00 True txn_0IE2QFig6peNXzgDr5Rvjm1t NaN 2021-01-27 01:02:15 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
6 po_0IEOwcig6peNXzgDLErzeeJU 2021-01-28 02:21:11 174685 2021-01-29 00:00:00 True txn_0IEOwcig6peNXzgDQKcXjNLh NaN 2021-01-28 01:05:10 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
7 po_0IFUKBig6peNXzgDZQM7WPAo 2021-01-31 02:21:08 1980810 2021-02-01 00:00:00 True txn_0IFUKBig6peNXzgDrDgkiAOI NaN 2021-01-31 01:01:59 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
8 po_0IFqn3ig6peNXzgDJ7KVXGLY 2021-02-01 02:21:12 270636 2021-02-02 00:00:00 True txn_0IFqn3ig6peNXzgDgLPJeYJh NaN 2021-02-01 01:01:17 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
9 po_0IGZkNig6peNXzgDKn9LrliN 2021-02-03 02:21:15 1813268 2021-02-04 00:00:00 True txn_0IGZkNig6peNXzgDHrcegNwS NaN 2021-02-03 01:01:31 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
10 po_0IGwErig6peNXzgDEGgZ8lu3 2021-02-04 02:21:10 39668 2021-02-05 00:00:00 True txn_0IGwErig6peNXzgDiZ6nFXFL NaN 2021-02-04 01:02:29 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
11 po_0II1gGig6peNXzgD4BxKEJJJ 2021-02-07 02:21:12 2849353 2021-02-08 00:00:00 True txn_0II1gGig6peNXzgDFFGOaKud NaN 2021-02-07 01:03:16 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
12 po_0IIOASig6peNXzgDiKGtfbo9 2021-02-08 02:21:11 775006 2021-02-09 00:00:00 True txn_0IIOASig6peNXzgDk2yRKDOz NaN 2021-02-08 01:03:56 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
13 po_0IIkbpig6peNXzgDs1u3xoyq 2021-02-09 02:21:20 2593997 2021-02-10 00:00:00 True txn_0IIkbpig6peNXzgDPUQ4T1Hd NaN 2021-02-09 01:01:41 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account
14 po_0IJ74Lig6peNXzgD2WboJcUe 2021-02-10 02:21:16 361777 2021-02-11 00:00:00 True txn_0IJ74Lig6peNXzgD4IuGp8d3 NaN 2021-02-10 01:00:37 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN NaN NaN True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} standard card NaN in_transit bank_account

plan_data (first 100 rows)

id _fivetran_synced active aggregate_usage amount billing_scheme created currency interval_ interval_count is_deleted livemode nickname product_id tiers_mode transform_usage_divide_by transform_usage_round trial_period_days usage_type
0 zb1 2021-03-15 14:21:13 True NaN 150000 per_unit 2017-05-10 18:50:13 usd month 1 False True NaN prod_BUZaPcD5jIhqAG NaN NaN NaN NaN licensed
1 ab2 2021-03-15 14:21:13 True NaN 150000 per_unit 2017-05-05 16:56:44 usd month 1 False True NaN prod_BUqcov3uJTssuQ NaN NaN NaN NaN licensed
2 5gh 2021-03-15 14:21:13 True NaN 150000 per_unit 2017-05-15 18:53:55 usd month 6 False True NaN prod_BTzAZ8EnmwNUqW NaN NaN NaN NaN licensed
3 3gf 2021-03-15 14:21:13 True NaN 180000 per_unit 2017-06-15 16:01:06 usd month 6 False True NaN prod_BUonomUNsdG3qx NaN NaN NaN NaN licensed
4 214gfdg 2021-03-15 14:21:13 True NaN 264030 per_unit 2017-08-04 16:29:13 usd month 3 False True NaN prod_BUo1nHP2vIrVtF NaN NaN NaN NaN licensed
5 fgds754 2021-03-15 14:21:13 True NaN 45000 per_unit 2017-06-21 16:23:32 usd month 1 False True NaN prod_BUBtgJBLlTGcy9 NaN NaN NaN NaN licensed
6 dfgdw576 2021-03-15 14:21:13 True NaN 20000 per_unit 2015-05-28 01:08:05 usd month 1 False True NaN prod_BV5IFAOt2EwqSl NaN NaN NaN NaN licensed
7 rhsdr456 2021-03-15 14:21:13 True NaN 100 per_unit 2015-05-28 01:10:13 usd month 1 False True NaN prod_BU23UCziUM7ezw NaN NaN NaN NaN licensed
8 3gds 2021-03-15 14:21:13 True NaN 50000 per_unit 2015-10-23 21:23:35 usd month 1 False True NaN prod_BTXZakZKkKlf6g NaN NaN NaN NaN licensed
9 234rtgh 2021-03-15 14:21:13 True NaN 40000 per_unit 2015-12-01 21:06:02 usd month 1 False True NaN prod_BUrKq3BcaxvjkU NaN NaN NaN NaN licensed
10 658jfgh 2021-03-15 14:21:13 True NaN 15000 per_unit 2015-11-16 22:42:15 usd month 1 False True NaN prod_BUaE6AwT15sLSX NaN NaN NaN NaN licensed
11 hfdstrt345 2021-03-15 14:21:13 True NaN 11500 per_unit 2016-01-06 16:58:21 usd month 1 False True NaN prod_BTN1m9rU6ivOBN NaN NaN NaN NaN licensed
12 634mfh 2021-03-15 14:21:13 True NaN 89000 per_unit 2016-03-09 23:16:21 usd month 1 False True NaN prod_BTNNlwDZ0nGHYp NaN NaN NaN NaN licensed

price_data (first 100 rows)

id _fivetran_synced active billing_scheme created currency invoice_item_id is_deleted livemode lookup_key metadata nickname product_id recurring_aggregate_usage recurring_interval recurring_interval_count recurring_usage_type tiers_mode transform_quantity_divide_by transform_quantity_round type unit_amount unit_amount_decimal
0 price_1 2022-09-22 23:49:02 True per_unit 2020-05-02 19:21:44 usd ii_FYFJSuzUa5YRk False True NaN {} NaN prod_HCqb8lm6kfYk NaN NaN NaN NaN NaN NaN NaN one_time 100000 100000

refund_data (first 100 rows)

id _fivetran_synced amount balance_transaction_id charge_id created currency description failure_balance_transaction_id failure_reason metadata reason receipt_number status
0 re_0IMJuLig6peNXzgDSLN6dNzl 2021-03-03 02:21:03 675000 txn_0IMJuMig6peNXzgD8geSKVTA ch_0IBft2ig6peNXzgDv3vdM6nM 2021-02-18 21:19:33 usd NaN NaN NaN {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} duplicate 5555-555 succeeded
1 re_0INhCiig6peNXzgDWw7VVan8 2021-02-22 20:21:22 13650 txn_0INhCiig6peNXzgDZSsC5kGs ch_0IMD9sig6peNXzgDoUawu0L1 2021-02-22 16:24:12 usd NaN NaN NaN {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} requested_by_customer 5555-555 succeeded
2 re_0IMKOqig6peNXzgDKcwfyQvJ 2021-02-19 02:21:10 1541221 txn_0IMKOqig6peNXzgDwl0qbnLD ch_0IMDADig6peNXzgDLUgpgKRp 2021-02-18 21:51:04 usd NaN NaN NaN {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} requested_by_customer 5555-555 succeeded
3 re_0ISmXVig6peNXzgDtw7Hev23 2021-03-08 20:21:10 161550 txn_0ISmXVig6peNXzgDO3k6vo6d ch_0IMDKoig6peNXzgDec7KCChy 2021-03-08 17:06:41 usd NaN NaN NaN {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} requested_by_customer 5555-555 succeeded

subscription_data (first 100 rows)

id _fivetran_synced application_fee_percent billing billing_cycle_anchor billing_threshold_amount_gte billing_threshold_reset_billing_cycle_anchor cancel_at cancel_at_period_end canceled_at created current_period_end current_period_start customer_id days_until_due default_source_id ended_at livemode metadata quantity start_date status tax_percent trial_end trial_start
0 sdgfs4536 2021-02-18 14:16:37 5 fdfjk 2021-02-18 14:16:37 9 False 2021-02-19 14:16:37 True 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 2021-02-18 14:16:37 sdf6547 4 dfa543 2021-02-19 14:16:37 True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 4 2021-02-18 14:16:37 active 5 2021-02-19 14:16:37 2021-02-18 14:16:37
1 sfjytkyu876 2021-02-18 14:16:37 6 fdsiew 2021-02-18 14:16:37 5 False 2021-02-19 14:16:37 True 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 2021-02-18 14:16:37 123fsdf 5 764rhgf 2021-02-19 14:16:37 True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 5 2021-02-18 14:16:37 active 6 2021-02-19 14:16:37 2021-02-18 14:16:37

subscription_history_data (first 100 rows)

id _fivetran_synced _fivetran_active application_fee_percent billing billing_cycle_anchor billing_threshold_amount_gte billing_threshold_reset_billing_cycle_anchor cancel_at cancel_at_period_end canceled_at created current_period_end current_period_start customer_id days_until_due default_source_id ended_at livemode metadata quantity start_date status tax_percent trial_end trial_start
0 sdgfs4536 2021-02-18 14:16:37 True 5 fdfjk 2021-02-18 14:16:37 9 False 2021-02-19 14:16:37 True 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 2021-02-18 14:16:37 sdf6547 4 dfa543 2021-02-19 14:16:37 True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 4 2021-02-18 14:16:37 active 5 2021-02-19 14:16:37 2021-02-18 14:16:37
1 sfjytkyu876 2021-02-18 14:16:37 False 6 fdsiew 2021-02-18 14:16:37 5 False 2021-02-19 14:16:37 True 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 2021-02-18 14:16:37 123fsdf 5 764rhgf 2021-02-19 14:16:37 True {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 5 2021-02-18 14:16:37 active 6 2021-02-19 14:16:37 2021-02-18 14:16:37

transfer_data (first 100 rows)

id _fivetran_synced amount amount_reversed balance_transaction_id created currency description destination destination_payment destination_payment_id livemode metadata reversed source_transaction source_transaction_id source_type transfer_group
0 po_0Njtvzig6peNXzgD6RPBasht 2023-08-29 02:19:08 1447318 0 txn_0Njtw0ig6peNXzgDXY3mJGwC 2023-08-28 01:08:03 usd STRIPE PAYOUT ba_0MkB7Nig6peNXzgDBFL0SIgk NaN NaN True "{"netsuite_deposit_id":"3975560","netsuite_deposit_link":"https://en.wikipedia.org/wiki/Beyonc%C3%A9"}" False NaN NaN card NaN
1 po_0NjXKxig6peNXzgDgn8MqQuZ 2023-08-28 08:20:02 2660278 0 txn_0NjXKyig6peNXzgDbmNVE84K 2023-08-27 01:00:19 usd STRIPE PAYOUT ba_0MkB7Nig6peNXzgDBFL0SIgk NaN NaN True None False NaN NaN card NaN
2 po_0NkGNTig6peNXzgDJWfkSimX 2023-08-30 02:19:14 760313 0 txn_0NkGNTig6peNXzgDTsXXisyE 2023-08-29 01:05:55 usd STRIPE PAYOUT ba_0MkB7Nig6peNXzgDBFL0SIgk NaN NaN True None False NaN NaN card NaN
3 po_0NkcrHig6peNXzgDwoDFU4Yi 2023-08-30 02:19:14 1944407 0 txn_0NkcrHig6peNXzgD7eFO2jc7 2023-08-30 01:06:11 usd STRIPE PAYOUT ba_0MkB7Nig6peNXzgDBFL0SIgk NaN NaN True None False NaN NaN card NaN
4 po_0Mbvvvig6peNXzgDNH6Wf3ha 2023-02-17 01:15:32 7251977 0 txn_0Mbvvvig6peNXzgDJAGJCdpN 2023-02-16 01:06:47 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN True None False NaN NaN card NaN
5 po_0LunJvig6peNXzgD41QBrw1m 2022-10-21 08:21:56 -1426166 0 txn_0LunJwig6peNXzgDCnBflWPl 2022-10-20 01:13:15 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN True None False NaN NaN card NaN
6 po_0MRQ1gig6peNXzgD138jhQS7 2023-01-19 02:19:35 7332491 0 txn_0MRQ1gig6peNXzgDchKTwIPQ 2023-01-18 01:01:16 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN True None False NaN NaN card NaN
7 po_0MRmW1ig6peNXzgDUPQSnmYw 2023-01-20 02:19:18 6108653 0 txn_0MRmW1ig6peNXzgDFqR0yaFa 2023-01-19 01:02:05 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN True None False NaN NaN card NaN
8 po_0MJ5C6ig6peNXzgDyic22YlD 2022-12-27 02:19:05 3456033 0 txn_0MJ5C7ig6peNXzgDfWTszRUw 2022-12-26 01:09:34 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN True None False NaN NaN card NaN
9 po_0MDe3Sig6peNXzgDJHinDGmA 2022-12-12 02:18:56 3330213 0 txn_0MDe3Tig6peNXzgDSyxtRpRH 2022-12-11 01:10:10 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU NaN NaN True None False NaN NaN card NaN
Source tables may have typos, unclear names, incorrect column types, etc. We clean these tables.

stg_dispute_data (first 100 rows)

dispute_id dispute_transaction_id charge_id currency evidence_billing_address evidence_customer_email evidence_customer_name evidence_purchase_ip has_evidence evidence_past_due evidence_submission_count evidence_receipt is_refundable is_live dispute_reason dispute_status additional_data connected_account_id dispute_created_at disputed_amount evidence_access_log evidence_cancellation_disclosure evidence_cancellation_policy evidence_cancellation_rebuttal evidence_carrier evidence_customer_signature evidence_due_date evidence_duplicate_charge_docs evidence_duplicate_charge_explanation evidence_duplicate_charge_id evidence_ship_date evidence_ship_docs evidence_tracking
0 du_0MmTsrig6peNXzgD4bsS3XWF txn_0MmTt4ig6peNXzgDDEp8wsKh ch_2MZdKRig6peNXzgD0EygIk7l usd None None None None True False 1 None True True product_unacceptable won {"netsuite_credit_memo_id":"3324234","netsuite_credit_memo_link":"https://en.wikipedia.org/wiki/Brave_New_World","netsuite_customer_refund_id":"3524872","netsuite_customer_refund_link":"https://en.wikipedia.org/wiki/Aldous_Huxley"} None 2023-03-17 03:23:13 1234.0 None None None None None None 2023-04-26 23:59:59 None None None None None None
1 du_0Lvivfig6peNXzgD33SIekHq txn_0LviwVig6peNXzgDkSPS1Y1C ch_2LqbkJig6peNXzgD1jG4Xy7z usd None None None None False False 1 None True True general won None None 2022-10-22 14:44:03 3333.0 None None None None None None 2022-11-17 23:59:59 None None None None None None
2 du_0KHowkig6peNXzgDyhndDHOe txn_0KHoxcig6peNXzgDKWarDbF0 ch_2JtdoJig6peNXzgD1lCAvXwG usd 1600 Pennsylvania Avenue NW, Washington, DC 20500 hello@bravenewworld.com Aldous Huxley 68.1.21.555 False False 1 file_0KHowoig6peNXzgDyeDmylk3 True True general won None None 2022-01-14 12:31:58 3331.0 None None None None None None 2022-02-09 23:59:59 None None None None None None
3 du_0M9SJTig6peNXzgD58OLM8Mz txn_0M9SKaig6peNXzgDlb5cqlBg ch_2M2d6mig6peNXzgD03nrNVYZ usd None None None None False False 0 None False True subscription_canceled lost None None 2022-11-29 11:49:23 1099.0 None None None None None None 2022-12-25 23:59:59 None None None None None None
4 du_0LuGYgig6peNXzgDM8lPBTFC txn_0LuGZyig6peNXzgDLgWzetHo ch_2LUt28ig6peNXzgD0RdFu0qW usd None None None None False False 0 None False True subscription_canceled lost None None 2022-10-18 14:14:18 1222.0 None None None None None None 2022-11-13 23:59:59 None None None None None None
5 du_0LyvFuig6peNXzgDyBMCjDi6 txn_0LyvHhig6peNXzgDg5LanDAq ch_2Lqdeuig6peNXzgD0sA3iBuH usd None None None None False False 0 None False True subscription_canceled lost None None 2022-10-31 10:30:10 221244.0 None None None None None None 2022-11-26 23:59:59 None None None None None None
6 du_0LiAl6ig6peNXzgDEejs24CE txn_0Lumheig6peNXzgDSp1KIXph ch_2LVoJuig6peNXzgD1DvyohjD usd None None None None False False 0 None False True general lost None None 2022-09-15 05:37:08 432532.0 None None None None None None 2022-11-12 23:59:59 None None None None None None
7 du_0M9ScVig6peNXzgDkfd7tUNb txn_0M9SdPig6peNXzgDgpb4aJDQ ch_2LqcRzig6peNXzgD06FImTqU usd None None None None False False 0 None False True subscription_canceled lost None None 2022-11-29 12:09:03 1400.0 None None None None None None 2022-12-25 23:59:59 None None None None None None
8 du_0LuGd7ig6peNXzgDUxXx85wF txn_0LuGe5ig6peNXzgD7PMfTzJ6 ch_2LfkHjig6peNXzgD1e9ltqQt usd None None None None False False 0 None False True subscription_canceled lost None None 2022-10-18 14:18:53 1400.0 None None None None None None 2022-11-13 23:59:59 None None None None None None
9 du_0LuGbbig6peNXzgDjHA4RfoT txn_0LuGcrig6peNXzgDKP5y95T9 ch_2LLwgKig6peNXzgD0Sr5X6kL usd None None None None False False 0 None False True subscription_canceled lost None None 2022-10-18 14:17:19 700.0 None None None None None None 2022-11-13 23:59:59 None None None None None None

stg_dispute_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"dispute_data_projected" AS (
    -- Projection: Selecting 43 out of 44 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "amount",
        "balance_transaction",
        "charge_id",
        "connected_account_id",
        "created",
        "currency",
        "evidence_access_activity_log",
        "evidence_billing_address",
        "evidence_cancellation_policy",
        "evidence_cancellation_policy_disclosure",
        "evidence_cancellation_rebuttal",
        "evidence_customer_communication",
        "evidence_customer_email_address",
        "evidence_customer_name",
        "evidence_customer_purchase_ip",
        "evidence_customer_signature",
        "evidence_details_due_by",
        "evidence_details_has_evidence",
        "evidence_details_past_due",
        "evidence_details_submission_count",
        "evidence_duplicate_charge_documentation",
        "evidence_duplicate_charge_explanation",
        "evidence_duplicate_charge_id",
        "evidence_product_description",
        "evidence_receipt",
        "evidence_refund_policy",
        "evidence_refund_policy_disclosure",
        "evidence_refund_refusal_explanation",
        "evidence_service_date",
        "evidence_service_documentation",
        "evidence_shipping_address",
        "evidence_shipping_carrier",
        "evidence_shipping_date",
        "evidence_shipping_documentation",
        "evidence_shipping_tracking_number",
        "evidence_uncategorized_file",
        "evidence_uncategorized_text",
        "is_charge_refundable",
        "livemode",
        "metadata",
        "reason",
        "status"
    FROM "dispute_data"
),

"dispute_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> dispute_id
    -- amount -> disputed_amount
    -- balance_transaction -> dispute_transaction_id
    -- created -> dispute_created_at
    -- evidence_access_activity_log -> evidence_access_log
    -- evidence_cancellation_policy_disclosure -> evidence_cancellation_disclosure
    -- evidence_customer_email_address -> evidence_customer_email
    -- evidence_customer_purchase_ip -> evidence_purchase_ip
    -- evidence_details_due_by -> evidence_due_date
    -- evidence_details_has_evidence -> has_evidence
    -- evidence_details_past_due -> evidence_past_due
    -- evidence_details_submission_count -> evidence_submission_count
    -- evidence_duplicate_charge_documentation -> evidence_duplicate_charge_docs
    -- evidence_refund_policy_disclosure -> evidence_refund_disclosure
    -- evidence_refund_refusal_explanation -> evidence_refund_refusal_reason
    -- evidence_shipping_address -> evidence_address
    -- evidence_shipping_carrier -> evidence_carrier
    -- evidence_shipping_date -> evidence_ship_date
    -- evidence_shipping_documentation -> evidence_ship_docs
    -- evidence_shipping_tracking_number -> evidence_tracking
    -- evidence_uncategorized_file -> evidence_misc_file
    -- evidence_uncategorized_text -> evidence_misc_text
    -- is_charge_refundable -> is_refundable
    -- livemode -> is_live
    -- metadata -> additional_data
    -- reason -> dispute_reason
    -- status -> dispute_status
    SELECT 
        "id" AS "dispute_id",
        "amount" AS "disputed_amount",
        "balance_transaction" AS "dispute_transaction_id",
        "charge_id",
        "connected_account_id",
        "created" AS "dispute_created_at",
        "currency",
        "evidence_access_activity_log" AS "evidence_access_log",
        "evidence_billing_address",
        "evidence_cancellation_policy",
        "evidence_cancellation_policy_disclosure" AS "evidence_cancellation_disclosure",
        "evidence_cancellation_rebuttal",
        "evidence_customer_communication",
        "evidence_customer_email_address" AS "evidence_customer_email",
        "evidence_customer_name",
        "evidence_customer_purchase_ip" AS "evidence_purchase_ip",
        "evidence_customer_signature",
        "evidence_details_due_by" AS "evidence_due_date",
        "evidence_details_has_evidence" AS "has_evidence",
        "evidence_details_past_due" AS "evidence_past_due",
        "evidence_details_submission_count" AS "evidence_submission_count",
        "evidence_duplicate_charge_documentation" AS "evidence_duplicate_charge_docs",
        "evidence_duplicate_charge_explanation",
        "evidence_duplicate_charge_id",
        "evidence_product_description",
        "evidence_receipt",
        "evidence_refund_policy",
        "evidence_refund_policy_disclosure" AS "evidence_refund_disclosure",
        "evidence_refund_refusal_explanation" AS "evidence_refund_refusal_reason",
        "evidence_service_date",
        "evidence_service_documentation",
        "evidence_shipping_address" AS "evidence_address",
        "evidence_shipping_carrier" AS "evidence_carrier",
        "evidence_shipping_date" AS "evidence_ship_date",
        "evidence_shipping_documentation" AS "evidence_ship_docs",
        "evidence_shipping_tracking_number" AS "evidence_tracking",
        "evidence_uncategorized_file" AS "evidence_misc_file",
        "evidence_uncategorized_text" AS "evidence_misc_text",
        "is_charge_refundable" AS "is_refundable",
        "livemode" AS "is_live",
        "metadata" AS "additional_data",
        "reason" AS "dispute_reason",
        "status" AS "dispute_status"
    FROM "dispute_data_projected"
),

"dispute_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- evidence_purchase_ip: The problem is that the IP address 68.1.21.555 is not a valid IPv4 address. In IPv4, each octet (the numbers between the dots) can only range from 0 to 255. The last octet in this IP address is 555, which exceeds this range. The correct value should have the last octet within the valid range. 
    SELECT
        "dispute_id",
        "disputed_amount",
        "dispute_transaction_id",
        "charge_id",
        "connected_account_id",
        "dispute_created_at",
        "currency",
        "evidence_access_log",
        "evidence_billing_address",
        "evidence_cancellation_policy",
        "evidence_cancellation_disclosure",
        "evidence_cancellation_rebuttal",
        "evidence_customer_communication",
        "evidence_customer_email",
        "evidence_customer_name",
        CASE
            WHEN "evidence_purchase_ip" = '''68.1.21.555''' THEN '''68.1.21.255'''
            ELSE "evidence_purchase_ip"
        END AS "evidence_purchase_ip",
        "evidence_customer_signature",
        "evidence_due_date",
        "has_evidence",
        "evidence_past_due",
        "evidence_submission_count",
        "evidence_duplicate_charge_docs",
        "evidence_duplicate_charge_explanation",
        "evidence_duplicate_charge_id",
        "evidence_product_description",
        "evidence_receipt",
        "evidence_refund_policy",
        "evidence_refund_disclosure",
        "evidence_refund_refusal_reason",
        "evidence_service_date",
        "evidence_service_documentation",
        "evidence_address",
        "evidence_carrier",
        "evidence_ship_date",
        "evidence_ship_docs",
        "evidence_tracking",
        "evidence_misc_file",
        "evidence_misc_text",
        "is_refundable",
        "is_live",
        "additional_data",
        "dispute_reason",
        "dispute_status"
    FROM "dispute_data_projected_renamed"
),

"dispute_data_projected_renamed_cleaned_casted" AS (
    -- Column Type Casting: 
    -- additional_data: from VARCHAR to JSON
    -- connected_account_id: from DECIMAL to VARCHAR
    -- dispute_created_at: from VARCHAR to TIMESTAMP
    -- disputed_amount: from INT to DECIMAL
    -- evidence_access_log: from DECIMAL to VARCHAR
    -- evidence_address: from DECIMAL to VARCHAR
    -- evidence_cancellation_disclosure: from DECIMAL to VARCHAR
    -- evidence_cancellation_policy: from DECIMAL to VARCHAR
    -- evidence_cancellation_rebuttal: from DECIMAL to VARCHAR
    -- evidence_carrier: from DECIMAL to VARCHAR
    -- evidence_customer_communication: from DECIMAL to VARCHAR
    -- evidence_customer_signature: from DECIMAL to VARCHAR
    -- evidence_due_date: from VARCHAR to TIMESTAMP
    -- evidence_duplicate_charge_docs: from DECIMAL to VARCHAR
    -- evidence_duplicate_charge_explanation: from DECIMAL to VARCHAR
    -- evidence_duplicate_charge_id: from DECIMAL to VARCHAR
    -- evidence_misc_file: from DECIMAL to VARCHAR
    -- evidence_misc_text: from DECIMAL to VARCHAR
    -- evidence_product_description: from DECIMAL to VARCHAR
    -- evidence_refund_disclosure: from DECIMAL to VARCHAR
    -- evidence_refund_policy: from DECIMAL to VARCHAR
    -- evidence_refund_refusal_reason: from DECIMAL to VARCHAR
    -- evidence_service_date: from DECIMAL to VARCHAR
    -- evidence_service_documentation: from DECIMAL to VARCHAR
    -- evidence_ship_date: from DECIMAL to VARCHAR
    -- evidence_ship_docs: from DECIMAL to VARCHAR
    -- evidence_tracking: from DECIMAL to VARCHAR
    SELECT
        "dispute_id",
        "dispute_transaction_id",
        "charge_id",
        "currency",
        "evidence_billing_address",
        "evidence_customer_email",
        "evidence_customer_name",
        "evidence_purchase_ip",
        "has_evidence",
        "evidence_past_due",
        "evidence_submission_count",
        "evidence_receipt",
        "is_refundable",
        "is_live",
        "dispute_reason",
        "dispute_status",
        CAST(TRIM("additional_data", '"') AS JSON) AS "additional_data",
        CAST("connected_account_id" AS VARCHAR) AS "connected_account_id",
        CAST("dispute_created_at" AS TIMESTAMP) AS "dispute_created_at",
        CAST("disputed_amount" AS DECIMAL) AS "disputed_amount",
        CAST("evidence_access_log" AS VARCHAR) AS "evidence_access_log",
        CAST("evidence_address" AS VARCHAR) AS "evidence_address",
        CAST("evidence_cancellation_disclosure" AS VARCHAR) AS "evidence_cancellation_disclosure",
        CAST("evidence_cancellation_policy" AS VARCHAR) AS "evidence_cancellation_policy",
        CAST("evidence_cancellation_rebuttal" AS VARCHAR) AS "evidence_cancellation_rebuttal",
        CAST("evidence_carrier" AS VARCHAR) AS "evidence_carrier",
        CAST("evidence_customer_communication" AS VARCHAR) AS "evidence_customer_communication",
        CAST("evidence_customer_signature" AS VARCHAR) AS "evidence_customer_signature",
        CAST("evidence_due_date" AS TIMESTAMP) AS "evidence_due_date",
        CAST("evidence_duplicate_charge_docs" AS VARCHAR) AS "evidence_duplicate_charge_docs",
        CAST("evidence_duplicate_charge_explanation" AS VARCHAR) AS "evidence_duplicate_charge_explanation",
        CAST("evidence_duplicate_charge_id" AS VARCHAR) AS "evidence_duplicate_charge_id",
        CAST("evidence_misc_file" AS VARCHAR) AS "evidence_misc_file",
        CAST("evidence_misc_text" AS VARCHAR) AS "evidence_misc_text",
        CAST("evidence_product_description" AS VARCHAR) AS "evidence_product_description",
        CAST("evidence_refund_disclosure" AS VARCHAR) AS "evidence_refund_disclosure",
        CAST("evidence_refund_policy" AS VARCHAR) AS "evidence_refund_policy",
        CAST("evidence_refund_refusal_reason" AS VARCHAR) AS "evidence_refund_refusal_reason",
        CAST("evidence_service_date" AS VARCHAR) AS "evidence_service_date",
        CAST("evidence_service_documentation" AS VARCHAR) AS "evidence_service_documentation",
        CAST("evidence_ship_date" AS VARCHAR) AS "evidence_ship_date",
        CAST("evidence_ship_docs" AS VARCHAR) AS "evidence_ship_docs",
        CAST("evidence_tracking" AS VARCHAR) AS "evidence_tracking"
    FROM "dispute_data_projected_renamed_cleaned"
),

"dispute_data_projected_renamed_cleaned_casted_missing_handled" AS (
    -- Handling missing values: There are 16 columns with unacceptable missing values
    -- additional_data has 90.0 percent missing. Strategy: 🔄 Unchanged
    -- evidence_address has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- evidence_billing_address has 90.0 percent missing. Strategy: 🔄 Unchanged
    -- evidence_customer_communication has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- evidence_customer_email has 90.0 percent missing. Strategy: 🔄 Unchanged
    -- evidence_customer_name has 90.0 percent missing. Strategy: 🔄 Unchanged
    -- evidence_misc_file has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- evidence_misc_text has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- evidence_product_description has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- evidence_purchase_ip has 90.0 percent missing. Strategy: 🔄 Unchanged
    -- evidence_receipt has 90.0 percent missing. Strategy: 🔄 Unchanged
    -- evidence_refund_disclosure has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- evidence_refund_policy has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- evidence_refund_refusal_reason has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- evidence_service_date has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- evidence_service_documentation has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "dispute_id",
        "dispute_transaction_id",
        "charge_id",
        "currency",
        "evidence_billing_address",
        "evidence_customer_email",
        "evidence_customer_name",
        "evidence_purchase_ip",
        "has_evidence",
        "evidence_past_due",
        "evidence_submission_count",
        "evidence_receipt",
        "is_refundable",
        "is_live",
        "dispute_reason",
        "dispute_status",
        "additional_data",
        "connected_account_id",
        "dispute_created_at",
        "disputed_amount",
        "evidence_access_log",
        "evidence_cancellation_disclosure",
        "evidence_cancellation_policy",
        "evidence_cancellation_rebuttal",
        "evidence_carrier",
        "evidence_customer_signature",
        "evidence_due_date",
        "evidence_duplicate_charge_docs",
        "evidence_duplicate_charge_explanation",
        "evidence_duplicate_charge_id",
        "evidence_ship_date",
        "evidence_ship_docs",
        "evidence_tracking"
    FROM "dispute_data_projected_renamed_cleaned_casted"
)

-- COCOON BLOCK END
SELECT * FROM "dispute_data_projected_renamed_cleaned_casted_missing_handled"

stg_dispute_data.yml (Document the table)

version: 2
models:
- name: stg_dispute_data
  description: The table is about dispute data for charges. It includes details like
    dispute ID, amount, charge ID, currency, and dispute status. Evidence fields store
    information provided for the dispute. Metadata contains additional references.
    Key fields are reason for dispute, status (won/lost), and whether the charge is
    refundable. The table tracks dispute lifecycles from creation to resolution.
  columns:
  - name: dispute_id
    description: Unique identifier for the dispute
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column is a unique identifier for each dispute. For this table,
        each row represents a distinct dispute, and dispute_id is unique across rows.
  - name: dispute_transaction_id
    description: Transaction ID for the dispute
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the transaction ID for each dispute. It appears
        to be unique for each dispute in the given sample, but it's possible that
        multiple disputes could theoretically be related to the same transaction in
        some cases.
  - name: charge_id
    description: Unique identifier for the disputed charge
    tests:
    - not_null
  - name: currency
    description: Currency of the disputed amount
    tests:
    - not_null
  - name: evidence_billing_address
    description: Billing address provided as evidence
    tests:
    - not_null
  - name: evidence_customer_email
    description: Customer email address provided as evidence
    tests:
    - not_null
  - name: evidence_customer_name
    description: Customer name provided as evidence
    tests:
    - not_null
  - name: evidence_purchase_ip
    description: Customer's IP address at purchase as evidence
    tests:
    - not_null
  - name: has_evidence
    description: Indicates if evidence has been submitted
    tests:
    - not_null
  - name: evidence_past_due
    description: Indicates if evidence submission is past due
    tests:
    - not_null
  - name: evidence_submission_count
    description: Number of evidence submissions
    tests:
    - not_null
  - name: evidence_receipt
    description: Receipt provided as evidence
    tests:
    - not_null
  - name: is_refundable
    description: Indicates if the charge can be refunded
    tests:
    - not_null
  - name: is_live
    description: Indicates if the dispute is in live mode
    tests:
    - not_null
  - name: dispute_reason
    description: Reason for the dispute
    tests:
    - not_null
    - accepted_values:
        values:
        - subscription_canceled
        - general
        - product_unacceptable
        - fraudulent_charge
        - duplicate_charge
        - product_not_received
        - incorrect_amount
        - unauthorized_charge
        - service_unsatisfactory
        - refund_not_processed
        - subscription_unwanted
        - quality_issue
        - shipping_issue
  - name: dispute_status
    description: Current status of the dispute
    tests:
    - not_null
    - accepted_values:
        values:
        - lost
        - won
        - pending
        - settled
        - withdrawn
  - name: additional_data
    description: Additional data related to the dispute
    tests:
    - not_null
  - name: connected_account_id
    description: ID of the connected account
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not involving connected accounts
  - name: dispute_created_at
    description: Date and time when the dispute was created
    tests:
    - not_null
  - name: disputed_amount
    description: Disputed charge amount
    tests:
    - not_null
  - name: evidence_access_log
    description: Access activity log provided as evidence
    cocoon_meta:
      missing_acceptable: Not applicable if no evidence access occurred
  - name: evidence_cancellation_disclosure
    description: Disclosure of cancellation policy as evidence
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not related to cancellations
  - name: evidence_cancellation_policy
    description: Cancellation policy provided as evidence
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not related to cancellations
  - name: evidence_cancellation_rebuttal
    description: Rebuttal to cancellation claim as evidence
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not related to cancellations
  - name: evidence_carrier
    description: Shipping carrier used for the order
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not involving shipping
  - name: evidence_customer_signature
    description: Customer signature provided as evidence
    cocoon_meta:
      missing_acceptable: Not applicable if customer signature wasn't required
  - name: evidence_due_date
    description: Due date for submitting evidence
    tests:
    - not_null
  - name: evidence_duplicate_charge_docs
    description: Documentation for duplicate charge claim
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not about duplicate charges
  - name: evidence_duplicate_charge_explanation
    description: Explanation for duplicate charge claim
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not about duplicate charges
  - name: evidence_duplicate_charge_id
    description: ID of the duplicate charge
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not about duplicate charges
  - name: evidence_ship_date
    description: Date the order was shipped
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not involving shipping
  - name: evidence_ship_docs
    description: Documentation related to shipping
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not involving shipping
  - name: evidence_tracking
    description: Tracking number for the shipped order
    cocoon_meta:
      missing_acceptable: Not applicable for disputes not involving shipping

stg_invoice_data (first 100 rows)

line_item_id currency customer_id description is_discountable invoice_id is_deleted is_live_transaction is_prorated quantity subscription_id subscription_item_id amount billing_period_end billing_period_start transaction_date unit_price
0 ab1111 usd sdgfs84854 description_here True sdg545641 False True True 45 sdkhg54645 kdshg455 45.0 2021-02-19 14:16:37 2021-02-18 14:16:37 NaT 5.0
1 si8jo54 usd dfd54654 description_here True dgjksg6486 False False False 55 dghisd165748 sgdfs5464 22.0 2021-02-19 14:16:37 2021-02-18 14:16:37 NaT 6.0

stg_invoice_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"invoice_data_projected" AS (
    -- Projection: Selecting 17 out of 18 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "amount",
        "currency",
        "customer_id",
        "date_",
        "description",
        "discountable",
        "invoice_id",
        "is_deleted",
        "livemode",
        "period_end",
        "period_start",
        "proration",
        "quantity",
        "subscription_id",
        "subscription_item_id",
        "unit_amount"
    FROM "invoice_data"
),

"invoice_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> line_item_id
    -- date_ -> transaction_date
    -- discountable -> is_discountable
    -- livemode -> is_live_transaction
    -- period_end -> billing_period_end
    -- period_start -> billing_period_start
    -- proration -> is_prorated
    -- unit_amount -> unit_price
    SELECT 
        "id" AS "line_item_id",
        "amount",
        "currency",
        "customer_id",
        "date_" AS "transaction_date",
        "description",
        "discountable" AS "is_discountable",
        "invoice_id",
        "is_deleted",
        "livemode" AS "is_live_transaction",
        "period_end" AS "billing_period_end",
        "period_start" AS "billing_period_start",
        "proration" AS "is_prorated",
        "quantity",
        "subscription_id",
        "subscription_item_id",
        "unit_amount" AS "unit_price"
    FROM "invoice_data_projected"
),

"invoice_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- description: The problem is that 'description_here' is a placeholder value and not actual descriptive content. It appears to be the only value present in the description column, which suggests that real descriptions are missing. The correct values should be actual, meaningful descriptions of the items or entities being described. However, since we don't have access to the real descriptions, we can't provide them. 
    SELECT
        "line_item_id",
        "amount",
        "currency",
        "customer_id",
        "transaction_date",
        CASE
            WHEN "description" = '''description_here''' THEN ''''
            ELSE "description"
        END AS "description",
        "is_discountable",
        "invoice_id",
        "is_deleted",
        "is_live_transaction",
        "billing_period_end",
        "billing_period_start",
        "is_prorated",
        "quantity",
        "subscription_id",
        "subscription_item_id",
        "unit_price"
    FROM "invoice_data_projected_renamed"
),

"invoice_data_projected_renamed_cleaned_casted" AS (
    -- Column Type Casting: 
    -- amount: from INT to DECIMAL
    -- billing_period_end: from VARCHAR to TIMESTAMP
    -- billing_period_start: from VARCHAR to TIMESTAMP
    -- transaction_date: from DECIMAL to DATE
    -- unit_price: from INT to DECIMAL
    SELECT
        "line_item_id",
        "currency",
        "customer_id",
        "description",
        "is_discountable",
        "invoice_id",
        "is_deleted",
        "is_live_transaction",
        "is_prorated",
        "quantity",
        "subscription_id",
        "subscription_item_id",
        CAST("amount" AS DECIMAL) AS "amount",
        CAST("billing_period_end" AS TIMESTAMP) AS "billing_period_end",
        CAST("billing_period_start" AS TIMESTAMP) AS "billing_period_start",
        CAST("transaction_date" AS DATE) AS "transaction_date",
        CAST("unit_price" AS DECIMAL) AS "unit_price"
    FROM "invoice_data_projected_renamed_cleaned"
)

-- COCOON BLOCK END
SELECT * FROM "invoice_data_projected_renamed_cleaned_casted"

stg_invoice_data.yml (Document the table)

version: 2
models:
- name: stg_invoice_data
  description: The table is about invoice data. It contains details such as invoice
    ID, amount, currency, customer ID, date, description, and subscription information.
    The table includes fields for discounts, proration, quantity, and unit amount.
    It also tracks whether the invoice is deleted or in livemode. The data seems to
    represent individual line items on invoices, with information about the associated
    subscription and billing period.
  columns:
  - name: line_item_id
    description: Unique identifier for the line item
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each line item. For
        this table, each row represents a single line item on an invoice. line_item_id
        is likely to be unique across rows.
  - name: currency
    description: Currency of the amount charged
    tests:
    - not_null
    - accepted_values:
        values:
        - usd
        - eur
        - gbp
        - jpy
        - cad
        - aud
        - chf
        - cny
        - hkd
        - nzd
        - krw
        - sgd
        - inr
        - mxn
        - brl
        - sek
        - nok
        - dkk
        - pln
        - zar
        - thb
        - rub
        - try
  - name: customer_id
    description: Unique identifier for the customer
    tests:
    - not_null
  - name: description
    description: Description of the line item
    tests:
    - not_null
  - name: is_discountable
    description: Whether the item is eligible for discounts
    tests:
    - not_null
  - name: invoice_id
    description: Unique identifier for the invoice
    tests:
    - not_null
  - name: is_deleted
    description: Indicates if the item has been deleted
    tests:
    - not_null
  - name: is_live_transaction
    description: Indicates if the transaction is live or test
    tests:
    - not_null
  - name: is_prorated
    description: Indicates if the amount is prorated
    tests:
    - not_null
  - name: quantity
    description: Quantity of the item
    tests:
    - not_null
  - name: subscription_id
    description: Unique identifier for the subscription
    tests:
    - not_null
  - name: subscription_item_id
    description: Unique identifier for the subscription item
    tests:
    - not_null
  - name: amount
    description: Amount charged for the line item
    tests:
    - not_null
  - name: billing_period_end
    description: End date of the billing period
    tests:
    - not_null
  - name: billing_period_start
    description: Start date of the billing period
    tests:
    - not_null
  - name: transaction_date
    description: Date of the invoice or transaction
    cocoon_meta:
      missing_acceptable: Not applicable for non-live transactions or future-dated
        invoices.
  - name: unit_price
    description: Price per unit of the item
    tests:
    - not_null

stg_charge_data (first 100 rows)

charge_id amount_cents refunded_cents is_captured card_id currency customer_id description failure_code failure_message is_live network_status outcome_reason risk_level seller_message outcome_type is_paid payment_intent_id hashed_receipt_email is_refunded charge_status calculated_statement_descriptor created_at invoice_id metadata receipt_number receipt_url shipping_address_1 shipping_address_2 shipping_carrier shipping_city shipping_country shipping_phone shipping_postal_code shipping_recipient_name shipping_state shipping_tracking_number
0 ch_0IMDAfig6peNXzgDJYQKfT3B 3293232 0 False pm_0Hr3Oyig6peNXzgDkOfs9Dqm usd cus_IRb688lkE0TnTM 068dfcec35b4d2eb8e5655783b40608e card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDAfig6peNXzgDnE8UotlM 32beaaeef4e37a5d19f8bafc1a1631c2 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:07:57 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
1 ch_0IMDAVig6peNXzgDHlr1zyyW 2040000 0 False pm_0Hj3Mhig6peNXzgDeAoKLH7U usd cus_IHmGn2733l3GK6 403e2c77a9041c677cb45b09d65a2636 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDAVig6peNXzgDJXuKVLtD e9e8ea6013cb5c982f71b5247c98be65 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:07:47 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
2 ch_0IMD9Yig6peNXzgDUvMKMSla 4071 0 False pm_0HfVlUig6peNXzgDvnqkgdRQ usd cus_IEXWsmR0hA8iGL d36f9f0f170bb3069a9b1d7055c8b412 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMD9Yig6peNXzgDtgkX3pjH ab11bebc20a2f74af38dc1f84d33e759 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:06:48 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
3 ch_0IMDGtig6peNXzgD1jdR6t7Y 197391 0 False pm_0I3Nemig6peNXzgDdDSfZXb9 usd cus_IegzSpQ6V9deOW f794a8544921fbec51dd986d00a443f8 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDGtig6peNXzgDCuzBH6xK 24a64fea88592b8a7bb9783eeb93f4c5 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:14:23 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
4 ch_0IMDLjig6peNXzgDQ0WJ7OtY 15000 0 False pm_0Hw4QGig6peNXzgDCwWwFnh0 usd cus_IX8c0jeM4yuzDn cda6649904149ac57765d9deac2263e6 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDLjig6peNXzgDppN3qSTF eb27183b771710ba705cc3d1f10be3fd False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:19:23 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
5 ch_0IMD9Wig6peNXzgDHxwWBPEZ 183000 0 False pm_0HnC5mig6peNXzgDXSNeK1Bu usd cus_INy1KScKAog1uS 3944b9f788ae4e71b100786be80205de card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMD9Vig6peNXzgDQxQe1FHT 6e05435f9bf429c0fb659a54fd7529b8 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:06:46 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
6 ch_0IMDDQig6peNXzgDah11dNBN 243500 0 False pm_0HnC5mig6peNXzgDXSNeK1Bu usd cus_INy1KScKAog1uS dd43606ef2262a592ebf62590c9d4df5 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDDQig6peNXzgDaC9Gjkx0 6e05435f9bf429c0fb659a54fd7529b8 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:10:48 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
7 ch_0IMDDUig6peNXzgDyqDvLubr 2786 0 False pm_0HfVlUig6peNXzgDvnqkgdRQ usd cus_IEXWsmR0hA8iGL 7ae43df98d8720a8f8fa6cc2d7987552 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDDUig6peNXzgDsuEhnuAl ab11bebc20a2f74af38dc1f84d33e759 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:10:52 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
8 ch_0IMDEuig6peNXzgDkP5uU3im 73650 0 False pm_0Hpc71ig6peNXzgDy1i9s6en usd cus_IQT24DskOLZ2yF 95175f4654496b92456b626a93b7ac33 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDEuig6peNXzgDqEn5B1gv 9cad6f0e0c1dff3dd27a98ee7fa4ff40 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:12:20 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
9 ch_0IMDJ3ig6peNXzgD5HDCXZGY 25600 0 False pm_0I6fuwig6peNXzgDpmJZOcbj usd cus_I5NJ6elPyrZHfj a4a3c49803b2e7ab42c1f6de44197126 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDJ3ig6peNXzgDjJpHOesH 5eb7cf4a91f5aadf5a52479989bc55ed False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:16:37 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
10 ch_0IMD9pig6peNXzgD5E7v2nk3 69750 0 False pm_0Hpc71ig6peNXzgDy1i9s6en usd cus_IQT24DskOLZ2yF 0b3c44516e5462c35367b3bed49b4a4d card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMD9oig6peNXzgD8rGMNoRL 9cad6f0e0c1dff3dd27a98ee7fa4ff40 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:07:05 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
11 ch_0IMD9dig6peNXzgD3i6CTeP6 160700 0 False pm_0Hnu2tig6peNXzgDeQNHwzSV usd cus_IOhGAHpVOsOV99 d871ea4e3c6b57da4750add9e8da62ae card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMD9dig6peNXzgDSLNX3MAL 9bd8e73d66d10af5cb18588b9e7c3872 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:06:53 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
12 ch_0IMDH8ig6peNXzgDku6HtBcQ 24592 0 False pm_0I3saBig6peNXzgDVgYNcLHV usd cus_IfCy5uUXv2MDT0 e1f0c035dbb83e796ffac9c71d94b138 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDH7ig6peNXzgD3IFw1Ss8 a5548420ede4e57b3e2fe16a984f851d False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:14:38 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
13 ch_0IMDA2ig6peNXzgDU9JZdY1J 109800 0 False pm_0Hj3Mhig6peNXzgDeAoKLH7U usd cus_IHmGn2733l3GK6 ed23dd0d8e2a65a9980b08d23c73360d card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDA2ig6peNXzgDDcfY1N2L e9e8ea6013cb5c982f71b5247c98be65 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:07:18 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
14 ch_0IMDJyig6peNXzgDngzT0dAy 117100 0 False pm_0Hj3Mhig6peNXzgDeAoKLH7U usd cus_IHmGn2733l3GK6 75b420f296d4874b1fd7c70eb3630cfa card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IMDJyig6peNXzgD4Ghvs0zF e9e8ea6013cb5c982f71b5247c98be65 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-18 14:17:34 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None
15 ch_0IGmOVig6peNXzgDFYDv1XdZ 117524 0 False card_Gti5RQklrpVVJ2 usd cus_F4zOnlDjqyZKdP 61721ad6e321cf891a91d20b397a4fd4 card_declined Your card was declined. True declined_by_network do_not_honor normal The bank returned the decline code `do_not_honor`. issuer_declined False pi_0IGmOVig6peNXzgDoFcKFzqx bd6a239ac7909ad0fe72d99b6d464a24 False failed 6f867b34cbc9bf57509503b3123a2ecb 2021-02-03 14:31:47 None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} None None None None None None None None None None None None

stg_charge_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"charge_data_projected" AS (
    -- Projection: Selecting 53 out of 54 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "amount",
        "amount_refunded",
        "application",
        "application_fee_amount",
        "balance_transaction_id",
        "bank_account_id",
        "captured",
        "card_id",
        "connected_account_id",
        "created",
        "currency",
        "customer_id",
        "description",
        "destination",
        "failure_code",
        "failure_message",
        "fraud_details_stripe_report",
        "fraud_details_user_report",
        "invoice_id",
        "livemode",
        "metadata",
        "on_behalf_of",
        "outcome_network_status",
        "outcome_reason",
        "outcome_risk_level",
        "outcome_risk_score",
        "outcome_seller_message",
        "outcome_type",
        "paid",
        "payment_intent_id",
        "receipt_email",
        "receipt_number",
        "receipt_url",
        "refunded",
        "shipping_address_city",
        "shipping_address_country",
        "shipping_address_line_1",
        "shipping_address_line_2",
        "shipping_address_postal_code",
        "shipping_address_state",
        "shipping_carrier",
        "shipping_name",
        "shipping_phone",
        "shipping_tracking_number",
        "source_id",
        "source_transfer",
        "statement_descriptor",
        "status",
        "transfer_data_destination",
        "transfer_group",
        "transfer_id",
        "calculated_statement_descriptor"
    FROM "charge_data"
),

"charge_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> charge_id
    -- amount -> amount_cents
    -- amount_refunded -> refunded_cents
    -- application_fee_amount -> app_fee_amount
    -- captured -> is_captured
    -- created -> created_at
    -- fraud_details_stripe_report -> stripe_fraud_report
    -- fraud_details_user_report -> user_fraud_report
    -- livemode -> is_live
    -- outcome_network_status -> network_status
    -- outcome_risk_level -> risk_level
    -- outcome_risk_score -> risk_score
    -- outcome_seller_message -> seller_message
    -- paid -> is_paid
    -- receipt_email -> hashed_receipt_email
    -- refunded -> is_refunded
    -- shipping_address_city -> shipping_city
    -- shipping_address_country -> shipping_country
    -- shipping_address_line_1 -> shipping_address_1
    -- shipping_address_line_2 -> shipping_address_2
    -- shipping_address_postal_code -> shipping_postal_code
    -- shipping_address_state -> shipping_state
    -- shipping_name -> shipping_recipient_name
    -- status -> charge_status
    -- transfer_data_destination -> transfer_destination
    SELECT 
        "id" AS "charge_id",
        "amount" AS "amount_cents",
        "amount_refunded" AS "refunded_cents",
        "application",
        "application_fee_amount" AS "app_fee_amount",
        "balance_transaction_id",
        "bank_account_id",
        "captured" AS "is_captured",
        "card_id",
        "connected_account_id",
        "created" AS "created_at",
        "currency",
        "customer_id",
        "description",
        "destination",
        "failure_code",
        "failure_message",
        "fraud_details_stripe_report" AS "stripe_fraud_report",
        "fraud_details_user_report" AS "user_fraud_report",
        "invoice_id",
        "livemode" AS "is_live",
        "metadata",
        "on_behalf_of",
        "outcome_network_status" AS "network_status",
        "outcome_reason",
        "outcome_risk_level" AS "risk_level",
        "outcome_risk_score" AS "risk_score",
        "outcome_seller_message" AS "seller_message",
        "outcome_type",
        "paid" AS "is_paid",
        "payment_intent_id",
        "receipt_email" AS "hashed_receipt_email",
        "receipt_number",
        "receipt_url",
        "refunded" AS "is_refunded",
        "shipping_address_city" AS "shipping_city",
        "shipping_address_country" AS "shipping_country",
        "shipping_address_line_1" AS "shipping_address_1",
        "shipping_address_line_2" AS "shipping_address_2",
        "shipping_address_postal_code" AS "shipping_postal_code",
        "shipping_address_state" AS "shipping_state",
        "shipping_carrier",
        "shipping_name" AS "shipping_recipient_name",
        "shipping_phone",
        "shipping_tracking_number",
        "source_id",
        "source_transfer",
        "statement_descriptor",
        "status" AS "charge_status",
        "transfer_data_destination" AS "transfer_destination",
        "transfer_group",
        "transfer_id",
        "calculated_statement_descriptor"
    FROM "charge_data_projected"
),

"charge_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- app_fee_amount: from DECIMAL to VARCHAR
    -- balance_transaction_id: from DECIMAL to VARCHAR
    -- bank_account_id: from DECIMAL to VARCHAR
    -- connected_account_id: from DECIMAL to VARCHAR
    -- created_at: from VARCHAR to TIMESTAMP
    -- destination: from DECIMAL to VARCHAR
    -- invoice_id: from DECIMAL to VARCHAR
    -- metadata: from VARCHAR to JSON
    -- on_behalf_of: from DECIMAL to VARCHAR
    -- receipt_number: from DECIMAL to VARCHAR
    -- receipt_url: from DECIMAL to VARCHAR
    -- risk_score: from DECIMAL to VARCHAR
    -- shipping_address_1: from DECIMAL to VARCHAR
    -- shipping_address_2: from DECIMAL to VARCHAR
    -- shipping_carrier: from DECIMAL to VARCHAR
    -- shipping_city: from DECIMAL to VARCHAR
    -- shipping_country: from DECIMAL to VARCHAR
    -- shipping_phone: from DECIMAL to VARCHAR
    -- shipping_postal_code: from DECIMAL to VARCHAR
    -- shipping_recipient_name: from DECIMAL to VARCHAR
    -- shipping_state: from DECIMAL to VARCHAR
    -- shipping_tracking_number: from DECIMAL to VARCHAR
    -- source_id: from DECIMAL to VARCHAR
    -- source_transfer: from DECIMAL to VARCHAR
    -- statement_descriptor: from DECIMAL to VARCHAR
    -- stripe_fraud_report: from DECIMAL to VARCHAR
    -- transfer_destination: from DECIMAL to VARCHAR
    -- transfer_group: from DECIMAL to VARCHAR
    -- transfer_id: from DECIMAL to VARCHAR
    -- user_fraud_report: from DECIMAL to VARCHAR
    SELECT
        "charge_id",
        "amount_cents",
        "refunded_cents",
        "application",
        "is_captured",
        "card_id",
        "currency",
        "customer_id",
        "description",
        "failure_code",
        "failure_message",
        "is_live",
        "network_status",
        "outcome_reason",
        "risk_level",
        "seller_message",
        "outcome_type",
        "is_paid",
        "payment_intent_id",
        "hashed_receipt_email",
        "is_refunded",
        "charge_status",
        "calculated_statement_descriptor",
        CAST("app_fee_amount" AS VARCHAR) AS "app_fee_amount",
        CAST("balance_transaction_id" AS VARCHAR) AS "balance_transaction_id",
        CAST("bank_account_id" AS VARCHAR) AS "bank_account_id",
        CAST("connected_account_id" AS VARCHAR) AS "connected_account_id",
        CAST("created_at" AS TIMESTAMP) AS "created_at",
        CAST("destination" AS VARCHAR) AS "destination",
        CAST("invoice_id" AS VARCHAR) AS "invoice_id",
        CAST("metadata" AS JSON) AS "metadata",
        CAST("on_behalf_of" AS VARCHAR) AS "on_behalf_of",
        CAST("receipt_number" AS VARCHAR) AS "receipt_number",
        CAST("receipt_url" AS VARCHAR) AS "receipt_url",
        CAST("risk_score" AS VARCHAR) AS "risk_score",
        CAST("shipping_address_1" AS VARCHAR) AS "shipping_address_1",
        CAST("shipping_address_2" AS VARCHAR) AS "shipping_address_2",
        CAST("shipping_carrier" AS VARCHAR) AS "shipping_carrier",
        CAST("shipping_city" AS VARCHAR) AS "shipping_city",
        CAST("shipping_country" AS VARCHAR) AS "shipping_country",
        CAST("shipping_phone" AS VARCHAR) AS "shipping_phone",
        CAST("shipping_postal_code" AS VARCHAR) AS "shipping_postal_code",
        CAST("shipping_recipient_name" AS VARCHAR) AS "shipping_recipient_name",
        CAST("shipping_state" AS VARCHAR) AS "shipping_state",
        CAST("shipping_tracking_number" AS VARCHAR) AS "shipping_tracking_number",
        CAST("source_id" AS VARCHAR) AS "source_id",
        CAST("source_transfer" AS VARCHAR) AS "source_transfer",
        CAST("statement_descriptor" AS VARCHAR) AS "statement_descriptor",
        CAST("stripe_fraud_report" AS VARCHAR) AS "stripe_fraud_report",
        CAST("transfer_destination" AS VARCHAR) AS "transfer_destination",
        CAST("transfer_group" AS VARCHAR) AS "transfer_group",
        CAST("transfer_id" AS VARCHAR) AS "transfer_id",
        CAST("user_fraud_report" AS VARCHAR) AS "user_fraud_report"
    FROM "charge_data_projected_renamed"
),

"charge_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 16 columns with unacceptable missing values
    -- app_fee_amount has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- application has 93.75 percent missing. Strategy: 🗑️ Drop Column
    -- balance_transaction_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- bank_account_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- connected_account_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- destination has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- on_behalf_of has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- risk_score has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- source_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- source_transfer has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- statement_descriptor has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- stripe_fraud_report has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- transfer_destination has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- transfer_group has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- transfer_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- user_fraud_report has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "charge_id",
        "amount_cents",
        "refunded_cents",
        "is_captured",
        "card_id",
        "currency",
        "customer_id",
        "description",
        "failure_code",
        "failure_message",
        "is_live",
        "network_status",
        "outcome_reason",
        "risk_level",
        "seller_message",
        "outcome_type",
        "is_paid",
        "payment_intent_id",
        "hashed_receipt_email",
        "is_refunded",
        "charge_status",
        "calculated_statement_descriptor",
        "created_at",
        "invoice_id",
        "metadata",
        "receipt_number",
        "receipt_url",
        "shipping_address_1",
        "shipping_address_2",
        "shipping_carrier",
        "shipping_city",
        "shipping_country",
        "shipping_phone",
        "shipping_postal_code",
        "shipping_recipient_name",
        "shipping_state",
        "shipping_tracking_number"
    FROM "charge_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "charge_data_projected_renamed_casted_missing_handled"

stg_charge_data.yml (Document the table)

version: 2
models:
- name: stg_charge_data
  description: The table is about charge transactions. It contains details like amount,
    currency, customer ID, card details, and transaction status. Most charges failed
    due to card declines. The table includes information on the reason for failure,
    risk assessment, and metadata. All charges are in USD and were made on February
    18, 2021.
  columns:
  - name: charge_id
    description: Unique identifier for the charge
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each charge transaction.
        For this table, each row represents a distinct charge transaction. The charge_id
        is unique across rows.
  - name: amount_cents
    description: Transaction amount in cents
    tests:
    - not_null
  - name: refunded_cents
    description: Amount refunded in cents
    tests:
    - not_null
  - name: is_captured
    description: Whether the charge was captured
    tests:
    - not_null
  - name: card_id
    description: ID of the card used
    tests:
    - not_null
  - name: currency
    description: Currency of the charge
    tests:
    - not_null
    - accepted_values:
        values:
        - usd
        - eur
        - gbp
        - jpy
        - cad
        - aud
        - chf
        - cny
        - hkd
        - nzd
        - sek
        - krw
        - sgd
        - nok
        - mxn
        - inr
        - rub
        - zar
        - try
        - brl
        - twd
        - dkk
        - pln
        - thb
        - idr
  - name: customer_id
    description: ID of the customer
    tests:
    - not_null
  - name: description
    description: Description of the charge
    tests:
    - not_null
  - name: failure_code
    description: Code indicating reason for failure
    tests:
    - not_null
    - accepted_values:
        values:
        - card_declined
        - insufficient_funds
        - expired_card
        - invalid_card_number
        - invalid_cvc
        - incorrect_cvc
        - lost_card
        - stolen_card
        - fraudulent_card
        - processing_error
        - issuer_not_available
        - do_not_honor
        - card_not_supported
        - currency_not_supported
        - duplicate_transaction
        - authentication_required
        - blocked_card
        - restricted_card
        - card_velocity_exceeded
        - withdrawal_count_limit_exceeded
  - name: failure_message
    description: Message describing the failure
    tests:
    - not_null
  - name: is_live
    description: Whether charge was in live mode
    tests:
    - not_null
  - name: network_status
    description: Network status of the charge outcome
    tests:
    - not_null
    - accepted_values:
        values:
        - declined_by_network
        - approved
        - declined_by_issuer
        - network_error
        - timeout
        - invalid_card
        - insufficient_funds
        - lost_or_stolen_card
        - suspected_fraud
        - expired_card
        - processing_error
        - card_not_supported
        - card_restricted
        - do_not_honor
        - pickup_card
  - name: outcome_reason
    description: Reason for the charge outcome
    tests:
    - not_null
    - accepted_values:
        values:
        - do_not_honor
        - insufficient_funds
        - lost_card
        - stolen_card
        - expired_card
        - invalid_card_number
        - invalid_cvc
        - card_not_supported
        - processing_error
        - fraudulent
        - generic_decline
        - card_velocity_exceeded
        - suspected_fraud
        - card_restricted
        - currency_not_supported
        - approved
        - partially_approved
        - authentication_required
        - incorrect_address
        - transaction_not_allowed
  - name: risk_level
    description: Risk level of the charge outcome
    tests:
    - not_null
    - accepted_values:
        values:
        - low
        - normal
        - medium
        - high
        - critical
  - name: seller_message
    description: Seller message for the charge outcome
    tests:
    - not_null
    - accepted_values:
        values:
        - do_not_honor
        - insufficient_funds
        - lost_card
        - stolen_card
        - expired_card
        - invalid_card_number
        - invalid_cvc
        - card_declined
        - processing_error
        - incorrect_pin
        - incorrect_zip
        - invalid_expiry_date
        - card_not_supported
        - fraudulent
        - pickup_card
        - restricted_card
        - security_violation
        - service_not_allowed
        - transaction_not_allowed
        - try_again_later
        - The bank returned the decline code `do_not_honor`.
  - name: outcome_type
    description: Type of the charge outcome
    tests:
    - not_null
    - accepted_values:
        values:
        - issuer_declined
        - approved
        - blocked
        - expired_card
        - insufficient_funds
        - lost_card
        - stolen_card
        - invalid_amount
        - invalid_number
        - fraud_suspect
        - processor_declined
        - authentication_required
        - card_not_supported
        - do_not_honor
        - duplicate_transaction
        - generic_decline
  - name: is_paid
    description: Indicates if the charge was successful
    tests:
    - not_null
  - name: payment_intent_id
    description: Unique identifier for the payment intent
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for the payment intent
        associated with each charge. While it's likely to be unique for each transaction
        in this table, it's possible that multiple charges could be associated with
        the same payment intent in some cases.
  - name: hashed_receipt_email
    description: Hashed email address for receipt
    tests:
    - not_null
  - name: is_refunded
    description: Indicates if the charge was refunded
    tests:
    - not_null
  - name: charge_status
    description: Current status of the charge
    tests:
    - not_null
    - accepted_values:
        values:
        - failed
        - succeeded
        - pending
        - refunded
        - canceled
        - disputed
        - authorized
        - captured
        - expired
        - requires_payment_method
        - requires_confirmation
        - requires_action
        - processing
  - name: calculated_statement_descriptor
    description: ''
    tests:
    - not_null
  - name: created_at
    description: Timestamp of charge creation
    tests:
    - not_null
  - name: invoice_id
    description: ID of associated invoice
    cocoon_meta:
      missing_acceptable: Failed transactions don't generate invoices
  - name: metadata
    description: Additional metadata for the charge
    tests:
    - not_null
  - name: receipt_number
    description: Receipt number if available
    cocoon_meta:
      missing_acceptable: Failed transactions don't generate receipts
  - name: receipt_url
    description: URL to access the receipt
    cocoon_meta:
      missing_acceptable: Failed transactions don't generate receipts
  - name: shipping_address_1
    description: First line of shipping address
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction
  - name: shipping_address_2
    description: Second line of shipping address
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction
  - name: shipping_carrier
    description: Name of shipping carrier
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction
  - name: shipping_city
    description: City in shipping address
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction
  - name: shipping_country
    description: Country in shipping address
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction
  - name: shipping_phone
    description: Phone number for shipping
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction
  - name: shipping_postal_code
    description: Postal code in shipping address
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction
  - name: shipping_recipient_name
    description: Name of recipient for shipping
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction
  - name: shipping_state
    description: State in shipping address
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction
  - name: shipping_tracking_number
    description: Tracking number for shipment
    cocoon_meta:
      missing_acceptable: No shipping involved in this transaction

stg_price_data (first 100 rows)

price_id is_active billing_scheme currency_code invoice_item_id is_deleted is_live_mode product_id price_type unit_amount creation_date metadata recurring_interval recurring_interval_count recurring_usage_aggregation recurring_usage_type tiers_mode unit_amount_decimal
0 price_1 True per_unit usd ii_FYFJSuzUa5YRk False True prod_HCqb8lm6kfYk one_time 100000 2020-05-02 19:21:44 {} None None None None None 100000.0

stg_price_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"price_data_projected" AS (
    -- Projection: Selecting 22 out of 23 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "active",
        "billing_scheme",
        "created",
        "currency",
        "invoice_item_id",
        "is_deleted",
        "livemode",
        "lookup_key",
        "metadata",
        "nickname",
        "product_id",
        "recurring_aggregate_usage",
        "recurring_interval",
        "recurring_interval_count",
        "recurring_usage_type",
        "tiers_mode",
        "transform_quantity_divide_by",
        "transform_quantity_round",
        "type",
        "unit_amount",
        "unit_amount_decimal"
    FROM "price_data"
),

"price_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> price_id
    -- active -> is_active
    -- created -> creation_date
    -- currency -> currency_code
    -- livemode -> is_live_mode
    -- nickname -> friendly_name
    -- recurring_aggregate_usage -> recurring_usage_aggregation
    -- transform_quantity_divide_by -> quantity_divide_by
    -- transform_quantity_round -> quantity_round
    -- type -> price_type
    SELECT 
        "id" AS "price_id",
        "active" AS "is_active",
        "billing_scheme",
        "created" AS "creation_date",
        "currency" AS "currency_code",
        "invoice_item_id",
        "is_deleted",
        "livemode" AS "is_live_mode",
        "lookup_key",
        "metadata",
        "nickname" AS "friendly_name",
        "product_id",
        "recurring_aggregate_usage" AS "recurring_usage_aggregation",
        "recurring_interval",
        "recurring_interval_count",
        "recurring_usage_type",
        "tiers_mode",
        "transform_quantity_divide_by" AS "quantity_divide_by",
        "transform_quantity_round" AS "quantity_round",
        "type" AS "price_type",
        "unit_amount",
        "unit_amount_decimal"
    FROM "price_data_projected"
),

"price_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- creation_date: from VARCHAR to TIMESTAMP
    -- friendly_name: from DECIMAL to VARCHAR
    -- lookup_key: from DECIMAL to VARCHAR
    -- metadata: from VARCHAR to JSON
    -- quantity_divide_by: from DECIMAL to VARCHAR
    -- quantity_round: from DECIMAL to VARCHAR
    -- recurring_interval: from DECIMAL to VARCHAR
    -- recurring_interval_count: from DECIMAL to VARCHAR
    -- recurring_usage_aggregation: from DECIMAL to VARCHAR
    -- recurring_usage_type: from DECIMAL to VARCHAR
    -- tiers_mode: from DECIMAL to VARCHAR
    -- unit_amount_decimal: from INT to DECIMAL
    SELECT
        "price_id",
        "is_active",
        "billing_scheme",
        "currency_code",
        "invoice_item_id",
        "is_deleted",
        "is_live_mode",
        "product_id",
        "price_type",
        "unit_amount",
        CAST("creation_date" AS TIMESTAMP) AS "creation_date",
        CAST("friendly_name" AS VARCHAR) AS "friendly_name",
        CAST("lookup_key" AS VARCHAR) AS "lookup_key",
        CAST("metadata" AS JSON) AS "metadata",
        CAST("quantity_divide_by" AS VARCHAR) AS "quantity_divide_by",
        CAST("quantity_round" AS VARCHAR) AS "quantity_round",
        CAST("recurring_interval" AS VARCHAR) AS "recurring_interval",
        CAST("recurring_interval_count" AS VARCHAR) AS "recurring_interval_count",
        CAST("recurring_usage_aggregation" AS VARCHAR) AS "recurring_usage_aggregation",
        CAST("recurring_usage_type" AS VARCHAR) AS "recurring_usage_type",
        CAST("tiers_mode" AS VARCHAR) AS "tiers_mode",
        CAST("unit_amount_decimal" AS DECIMAL(10,2)) AS "unit_amount_decimal"
    FROM "price_data_projected_renamed"
),

"price_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 4 columns with unacceptable missing values
    -- friendly_name has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- lookup_key has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- quantity_divide_by has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- quantity_round has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "price_id",
        "is_active",
        "billing_scheme",
        "currency_code",
        "invoice_item_id",
        "is_deleted",
        "is_live_mode",
        "product_id",
        "price_type",
        "unit_amount",
        "creation_date",
        "metadata",
        "recurring_interval",
        "recurring_interval_count",
        "recurring_usage_aggregation",
        "recurring_usage_type",
        "tiers_mode",
        "unit_amount_decimal"
    FROM "price_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "price_data_projected_renamed_casted_missing_handled"

stg_price_data.yml (Document the table)

version: 2
models:
- name: stg_price_data
  description: The table is about pricing information. It includes details like price
    ID, active status, billing scheme, currency, and amount. The table also contains
    fields related to recurring pricing, such as interval and usage type. Additional
    information includes creation date, associated product ID, and metadata. The table
    seems to store comprehensive pricing data for various products or services.
  columns:
  - name: price_id
    description: Unique identifier for the price
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column is a unique identifier for each price. For this table,
        each row represents a distinct price entry. price_id is unique across rows
        as it's designed to be a primary identifier.
  - name: is_active
    description: Indicates if the price is currently active
    tests:
    - not_null
  - name: billing_scheme
    description: The pricing model for the product
    tests:
    - not_null
    - accepted_values:
        values:
        - per_unit
        - tiered
  - name: currency_code
    description: The currency code for the price
    tests:
    - not_null
  - name: invoice_item_id
    description: Associated invoice item identifier
    tests:
    - not_null
  - name: is_deleted
    description: Indicates if the price has been deleted
    tests:
    - not_null
  - name: is_live_mode
    description: Whether the price is in live or test mode
    tests:
    - not_null
  - name: product_id
    description: Identifier of the associated product
    tests:
    - not_null
  - name: price_type
    description: The type of pricing (one-time or recurring)
    tests:
    - not_null
    - accepted_values:
        values:
        - one_time
        - recurring
  - name: unit_amount
    description: Price amount in smallest currency unit
    tests:
    - not_null
  - name: creation_date
    description: Timestamp of when the price was created
    tests:
    - not_null
  - name: metadata
    description: Additional information about the price
    tests:
    - not_null
  - name: recurring_interval
    description: Billing frequency for recurring prices
    cocoon_meta:
      missing_acceptable: Not applicable for one-time pricing
  - name: recurring_interval_count
    description: Number of intervals between billings
    cocoon_meta:
      missing_acceptable: Not applicable for one-time pricing
  - name: recurring_usage_aggregation
    description: Usage aggregation for recurring prices
    cocoon_meta:
      missing_acceptable: Not applicable for one-time pricing
  - name: recurring_usage_type
    description: Usage calculation for recurring prices
    cocoon_meta:
      missing_acceptable: Not applicable for one-time pricing
  - name: tiers_mode
    description: Defines how tiers are handled
    cocoon_meta:
      missing_acceptable: Not applicable for per_unit billing scheme
  - name: unit_amount_decimal
    description: Decimal representation of unit amount
    tests:
    - not_null

stg_fee_data (first 100 rows)

transaction_id group_index amount_cents currency_code category_hash type_hash
0 txn_0IC7txig6peNXzgD0BI1c5fq 0 9281 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
1 txn_0IC9dPig6peNXzgDaOTwBq8B 0 22215 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
2 txn_0IC7bOig6peNXzgDE6EeCW6p 0 99 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
3 txn_0ICQWOig6peNXzgD2Cn5HdMK 0 9456 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
4 txn_0ICE3lig6peNXzgDvwFP6Cgz 0 10484 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
5 txn_0IC5tfig6peNXzgDxCGsg0DR 0 10535 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
6 txn_0IBsCcig6peNXzgDEDePzZOD 0 3117 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
7 txn_0IBJOlig6peNXzgDgRlNX2UI 0 99480 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
8 txn_0IBoyeig6peNXzgDkINDi0wS 0 88409 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
9 txn_0IBT4Oig6peNXzgDWT3wbNp1 0 25405 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
10 txn_0IBm5Yig6peNXzgDk1LI4JCA 0 25405 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
11 txn_0IBtOoig6peNXzgDbrhw4CcH 0 17430 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4
12 txn_0IBft3ig6peNXzgDoG5KpDGo 0 19605 usd 5648134d1ebad69e0037d22cb76a8a6a a63a12921d2c16182f640ee7d2875ec4

stg_fee_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"fee_data_projected" AS (
    -- Projection: Selecting 8 out of 9 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "balance_transaction_id",
        "index_",
        "amount",
        "application",
        "connected_account_id",
        "currency",
        "description",
        "type"
    FROM "fee_data"
),

"fee_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- balance_transaction_id -> transaction_id
    -- index_ -> group_index
    -- amount -> amount_cents
    -- currency -> currency_code
    -- description -> category_hash
    -- type -> type_hash
    SELECT 
        "balance_transaction_id" AS "transaction_id",
        "index_" AS "group_index",
        "amount" AS "amount_cents",
        "application",
        "connected_account_id",
        "currency" AS "currency_code",
        "description" AS "category_hash",
        "type" AS "type_hash"
    FROM "fee_data_projected"
),

"fee_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- application: from DECIMAL to VARCHAR
    -- connected_account_id: from DECIMAL to VARCHAR
    SELECT
        "transaction_id",
        "group_index",
        "amount_cents",
        "currency_code",
        "category_hash",
        "type_hash",
        CAST("application" AS VARCHAR) AS "application",
        CAST("connected_account_id" AS VARCHAR) AS "connected_account_id"
    FROM "fee_data_projected_renamed"
),

"fee_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 2 columns with unacceptable missing values
    -- application has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- connected_account_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "transaction_id",
        "group_index",
        "amount_cents",
        "currency_code",
        "category_hash",
        "type_hash"
    FROM "fee_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "fee_data_projected_renamed_casted_missing_handled"

stg_fee_data.yml (Document the table)

version: 2
models:
- name: stg_fee_data
  description: The table is about fee transactions. It includes details such as the
    transaction ID, amount, currency, description, and type. All transactions are
    in USD. The amounts vary significantly, from 99 to 22215. Each transaction has
    a unique balance_transaction_id. The description and type fields contain consistent
    values across all entries, suggesting they might be category identifiers.
  columns:
  - name: transaction_id
    description: Unique identifier for the transaction
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each transaction.
        For this table, each row represents a distinct fee transaction. The transaction_id
        appears to be unique across rows, as each sample has a different value.
  - name: group_index
    description: Constant value, possibly for grouping
    tests:
    - not_null
  - name: amount_cents
    description: Transaction amount in cents
    tests:
    - not_null
  - name: currency_code
    description: Currency of the transaction
    tests:
    - not_null
  - name: category_hash
    description: Identifier or hash for transaction category
    tests:
    - not_null
  - name: type_hash
    description: Identifier or hash for transaction type
    tests:
    - not_null

stg_credit_note_line_item_data (first 100 rows)

credit_note_id line_item_id item_description is_live_mode quantity line_item_type unit_price_cents discount_amount total_amount unit_price_precise
0 cn_89hUNfs cnli_H7kCLAE description_here True 10 custom_line_item 5 0.0 50.0 494.0
1 cn_Jg3Jf0s cnli_1HuHLafV description_here False 1 invoice_line_item 100 0.0 100.0 1000.0

stg_credit_note_line_item_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"credit_note_line_item_data_projected" AS (
    -- Projection: Selecting 10 out of 11 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "credit_note_id",
        "id",
        "amount",
        "discount_amount",
        "description",
        "livemode",
        "quantity",
        "type",
        "unit_amount",
        "unit_amount_decimal"
    FROM "credit_note_line_item_data"
),

"credit_note_line_item_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> line_item_id
    -- amount -> total_amount
    -- description -> item_description
    -- livemode -> is_live_mode
    -- type -> line_item_type
    -- unit_amount -> unit_price_cents
    -- unit_amount_decimal -> unit_price_precise
    SELECT 
        "credit_note_id",
        "id" AS "line_item_id",
        "amount" AS "total_amount",
        "discount_amount",
        "description" AS "item_description",
        "livemode" AS "is_live_mode",
        "quantity",
        "type" AS "line_item_type",
        "unit_amount" AS "unit_price_cents",
        "unit_amount_decimal" AS "unit_price_precise"
    FROM "credit_note_line_item_data_projected"
),

"credit_note_line_item_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- item_description: The problem is that 'description_here' is a placeholder value and not a real item description. This is unusual because it doesn't provide any actual information about the item. The correct value should be an empty string, as we don't have the real description and leaving it blank is more appropriate than using a placeholder. 
    SELECT
        "credit_note_id",
        "line_item_id",
        "total_amount",
        "discount_amount",
        CASE
            WHEN "item_description" = '''description_here''' THEN ''''
            ELSE "item_description"
        END AS "item_description",
        "is_live_mode",
        "quantity",
        "line_item_type",
        "unit_price_cents",
        "unit_price_precise"
    FROM "credit_note_line_item_data_projected_renamed"
),

"credit_note_line_item_data_projected_renamed_cleaned_casted" AS (
    -- Column Type Casting: 
    -- discount_amount: from INT to DECIMAL
    -- total_amount: from INT to DECIMAL
    -- unit_price_precise: from INT to DECIMAL
    SELECT
        "credit_note_id",
        "line_item_id",
        "item_description",
        "is_live_mode",
        "quantity",
        "line_item_type",
        "unit_price_cents",
        CAST("discount_amount" AS DECIMAL) AS "discount_amount",
        CAST("total_amount" AS DECIMAL) AS "total_amount",
        CAST("unit_price_precise" AS DECIMAL) AS "unit_price_precise"
    FROM "credit_note_line_item_data_projected_renamed_cleaned"
)

-- COCOON BLOCK END
SELECT * FROM "credit_note_line_item_data_projected_renamed_cleaned_casted"

stg_credit_note_line_item_data.yml (Document the table)

version: 2
models:
- name: stg_credit_note_line_item_data
  description: The table is about credit note line items. It contains details of individual
    items within a credit note. Each row represents a line item with information like
    amount, quantity, unit price, and description. The credit_note_id links the line
    item to its parent credit note. The table includes both custom line items and
    invoice line items. It also tracks whether each item is in live mode or not.
  columns:
  - name: credit_note_id
    description: Unique identifier of the parent credit note
    tests:
    - not_null
  - name: line_item_id
    description: Unique identifier for the line item
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the unique identifier for each line item.
        For this table, each row is a distinct line item. line_item_id should be unique
        across rows as it's designed to identify each specific line item.
  - name: item_description
    description: Brief description of the line item
    tests:
    - not_null
  - name: is_live_mode
    description: Indicates if the item is in live mode
    tests:
    - not_null
  - name: quantity
    description: Number of units for the line item
    tests:
    - not_null
  - name: line_item_type
    description: Type of line item (custom or invoice)
    tests:
    - not_null
    - accepted_values:
        values:
        - custom_line_item
        - invoice_line_item
  - name: unit_price_cents
    description: Price per unit in cents
    tests:
    - not_null
  - name: discount_amount
    description: Amount of discount applied to the line item
    tests:
    - not_null
  - name: total_amount
    description: Total amount for the line item
    tests:
    - not_null
  - name: unit_price_precise
    description: Precise unit amount with decimal places
    tests:
    - not_null

stg_account_data (first 100 rows)

merchant_category_code business_name support_city support_country support_address_line1 support_address_line2 support_state support_email support_url business_url afterpay_clearpay_status bancontact_status card_payments_status eps_status giropay_status ideal_status p24_status platform_payments_status sepa_debit_payments_status sofort_payments_status charges_enabled country default_currency details_submitted account_email is_deleted payouts_enabled branding_logo_file_id branding_primary_color dashboard_display_name dashboard_timezone payment_statement_descriptor debit_negative_balances payout_delay_days payout_schedule_interval account_type account_id au_becs_debit_status bacs_debit_status company_address_kana_city company_address_kana_country company_address_kana_line_1 company_address_kana_line_2 company_address_kana_postal_code company_address_kana_state company_address_kana_town company_address_kanji_city company_address_kanji_country company_address_kanji_line_1 company_address_kanji_line_2 company_address_kanji_postal_code company_address_kanji_state company_address_kanji_town company_name_kana company_name_kanji fpx_status grabpay_status jcb_status oxxo_status payment_statement_descriptor_kana payment_statement_descriptor_kanji payout_monthly_anchor payout_weekly_anchor support_postal_code
0 737 Hogwarts School of Witchcraft and Wizardry Hogwarts US 123 Street Apt 123 CA severus@hogwarts.com https://www.wizardingworld.com/ https://www.wizardingworld.com/ active active active active active active active active active active True US usd True dumbledore@hogwarts.com False True file_asdfasgas #0030ff Hogwarts Inc. America/Los_Angeles hogwarts.com True 7 daily standard 1234 None None None None None None None None None None None None None None None None None None None None None None None None NaN None 12345

stg_account_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"account_data_projected" AS (
    -- Projection: Selecting 110 out of 111 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "business_profile_mcc",
        "business_profile_name",
        "business_profile_product_description",
        "business_profile_support_address_city",
        "business_profile_support_address_country",
        "business_profile_support_address_line_1",
        "business_profile_support_address_line_2",
        "business_profile_support_address_postal_code",
        "business_profile_support_address_state",
        "business_profile_support_email",
        "business_profile_support_phone",
        "business_profile_support_url",
        "business_profile_url",
        "business_type",
        "capabilities_afterpay_clearpay_payments",
        "capabilities_au_becs_debit_payments",
        "capabilities_bacs_debit_payments",
        "capabilities_bancontact_payments",
        "capabilities_card_issuing",
        "capabilities_card_payments",
        "capabilities_cartes_bancaires_payments",
        "capabilities_eps_payments",
        "capabilities_fpx_payments",
        "capabilities_giropay_payments",
        "capabilities_grabpay_payments",
        "capabilities_ideal_payments",
        "capabilities_jcb_payments",
        "capabilities_legacy_payments",
        "capabilities_oxxo_payments",
        "capabilities_p_24_payments",
        "capabilities_platform_payments",
        "capabilities_sepa_debit_payments",
        "capabilities_sofort_payments",
        "capabilities_tax_reporting_us_1099_k",
        "capabilities_tax_reporting_us_1099_misc",
        "capabilities_transfers",
        "charges_enabled",
        "company_address_city",
        "company_address_country",
        "company_address_kana_city",
        "company_address_kana_country",
        "company_address_kana_line_1",
        "company_address_kana_line_2",
        "company_address_kana_postal_code",
        "company_address_kana_state",
        "company_address_kana_town",
        "company_address_kanji_city",
        "company_address_kanji_country",
        "company_address_kanji_line_1",
        "company_address_kanji_line_2",
        "company_address_kanji_postal_code",
        "company_address_kanji_state",
        "company_address_kanji_town",
        "company_address_line_1",
        "company_address_line_2",
        "company_address_postal_code",
        "company_address_state",
        "company_directors_provided",
        "company_executives_provided",
        "company_name",
        "company_name_kana",
        "company_name_kanji",
        "company_owners_provided",
        "company_phone",
        "company_structure",
        "company_tax_id_provided",
        "company_tax_id_registrar",
        "company_vat_id_provided",
        "company_verification_document_back",
        "company_verification_document_details",
        "company_verification_document_details_code",
        "company_verification_document_front",
        "country",
        "created",
        "default_currency",
        "details_submitted",
        "email",
        "individual_id",
        "is_deleted",
        "metadata",
        "payouts_enabled",
        "requirements_current_deadline",
        "requirements_currently_due",
        "requirements_disabled_reason",
        "requirements_errors",
        "requirements_eventually_due",
        "requirements_past_due",
        "requirements_pending_verification",
        "settings_branding_icon",
        "settings_branding_logo",
        "settings_branding_primary_color",
        "settings_card_payments_decline_on_avs_failure",
        "settings_card_payments_decline_on_cvc_failure",
        "settings_card_payments_statement_descriptor_prefix",
        "settings_dashboard_display_name",
        "settings_dashboard_timezone",
        "settings_payments_statement_descriptor",
        "settings_payments_statement_descriptor_kana",
        "settings_payments_statement_descriptor_kanji",
        "settings_payouts_debit_negative_balances",
        "settings_payouts_schedule_delay_days",
        "settings_payouts_schedule_interval",
        "settings_payouts_schedule_monthly_anchor",
        "settings_payouts_schedule_weekly_anchor",
        "settings_payouts_statement_descriptor",
        "tos_acceptance_date",
        "tos_acceptance_ip",
        "tos_acceptance_user_agent",
        "type"
    FROM "account_data"
),

"account_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> account_id
    -- business_profile_mcc -> merchant_category_code
    -- business_profile_name -> business_name
    -- business_profile_product_description -> product_description
    -- business_profile_support_address_city -> support_city
    -- business_profile_support_address_country -> support_country
    -- business_profile_support_address_line_1 -> support_address_line1
    -- business_profile_support_address_line_2 -> support_address_line2
    -- business_profile_support_address_postal_code -> support_postal_code
    -- business_profile_support_address_state -> support_state
    -- business_profile_support_email -> support_email
    -- business_profile_support_phone -> support_phone
    -- business_profile_support_url -> support_url
    -- business_profile_url -> business_url
    -- capabilities_afterpay_clearpay_payments -> afterpay_clearpay_status
    -- capabilities_au_becs_debit_payments -> au_becs_debit_status
    -- capabilities_bacs_debit_payments -> bacs_debit_status
    -- capabilities_bancontact_payments -> bancontact_status
    -- capabilities_card_issuing -> card_issuing_status
    -- capabilities_card_payments -> card_payments_status
    -- capabilities_cartes_bancaires_payments -> cartes_bancaires_status
    -- capabilities_eps_payments -> eps_status
    -- capabilities_fpx_payments -> fpx_status
    -- capabilities_giropay_payments -> giropay_status
    -- capabilities_grabpay_payments -> grabpay_status
    -- capabilities_ideal_payments -> ideal_status
    -- capabilities_jcb_payments -> jcb_status
    -- capabilities_legacy_payments -> legacy_payments_status
    -- capabilities_oxxo_payments -> oxxo_status
    -- capabilities_p_24_payments -> p24_status
    -- capabilities_platform_payments -> platform_payments_status
    -- capabilities_sepa_debit_payments -> sepa_debit_payments_status
    -- capabilities_sofort_payments -> sofort_payments_status
    -- capabilities_tax_reporting_us_1099_k -> tax_reporting_1099k_status
    -- capabilities_tax_reporting_us_1099_misc -> tax_reporting_1099misc_status
    -- capabilities_transfers -> transfers_status
    -- company_owners_provided -> owners_info_provided
    -- company_phone -> business_phone
    -- company_structure -> legal_structure
    -- company_tax_id_provided -> tax_id_provided
    -- company_tax_id_registrar -> tax_id_issuer
    -- company_vat_id_provided -> vat_id_provided
    -- company_verification_document_back -> verification_doc_back
    -- company_verification_document_details -> verification_doc_details
    -- company_verification_document_details_code -> verification_doc_code
    -- company_verification_document_front -> verification_doc_front
    -- created -> account_creation_date
    -- email -> account_email
    -- requirements_current_deadline -> current_requirements_deadline
    -- requirements_currently_due -> current_requirements
    -- requirements_errors -> requirement_errors
    -- requirements_eventually_due -> future_requirements
    -- requirements_past_due -> past_due_requirements
    -- requirements_pending_verification -> pending_verification
    -- settings_branding_icon -> branding_icon
    -- settings_branding_logo -> branding_logo_file_id
    -- settings_branding_primary_color -> branding_primary_color
    -- settings_card_payments_decline_on_avs_failure -> decline_on_avs_failure
    -- settings_card_payments_decline_on_cvc_failure -> decline_on_cvc_failure
    -- settings_card_payments_statement_descriptor_prefix -> statement_descriptor_prefix
    -- settings_dashboard_display_name -> dashboard_display_name
    -- settings_dashboard_timezone -> dashboard_timezone
    -- settings_payments_statement_descriptor -> payment_statement_descriptor
    -- settings_payments_statement_descriptor_kana -> payment_statement_descriptor_kana
    -- settings_payments_statement_descriptor_kanji -> payment_statement_descriptor_kanji
    -- settings_payouts_debit_negative_balances -> debit_negative_balances
    -- settings_payouts_schedule_delay_days -> payout_delay_days
    -- settings_payouts_schedule_interval -> payout_schedule_interval
    -- settings_payouts_schedule_monthly_anchor -> payout_monthly_anchor
    -- settings_payouts_schedule_weekly_anchor -> payout_weekly_anchor
    -- settings_payouts_statement_descriptor -> payout_statement_descriptor
    -- type -> account_type
    SELECT 
        "id" AS "account_id",
        "business_profile_mcc" AS "merchant_category_code",
        "business_profile_name" AS "business_name",
        "business_profile_product_description" AS "product_description",
        "business_profile_support_address_city" AS "support_city",
        "business_profile_support_address_country" AS "support_country",
        "business_profile_support_address_line_1" AS "support_address_line1",
        "business_profile_support_address_line_2" AS "support_address_line2",
        "business_profile_support_address_postal_code" AS "support_postal_code",
        "business_profile_support_address_state" AS "support_state",
        "business_profile_support_email" AS "support_email",
        "business_profile_support_phone" AS "support_phone",
        "business_profile_support_url" AS "support_url",
        "business_profile_url" AS "business_url",
        "business_type",
        "capabilities_afterpay_clearpay_payments" AS "afterpay_clearpay_status",
        "capabilities_au_becs_debit_payments" AS "au_becs_debit_status",
        "capabilities_bacs_debit_payments" AS "bacs_debit_status",
        "capabilities_bancontact_payments" AS "bancontact_status",
        "capabilities_card_issuing" AS "card_issuing_status",
        "capabilities_card_payments" AS "card_payments_status",
        "capabilities_cartes_bancaires_payments" AS "cartes_bancaires_status",
        "capabilities_eps_payments" AS "eps_status",
        "capabilities_fpx_payments" AS "fpx_status",
        "capabilities_giropay_payments" AS "giropay_status",
        "capabilities_grabpay_payments" AS "grabpay_status",
        "capabilities_ideal_payments" AS "ideal_status",
        "capabilities_jcb_payments" AS "jcb_status",
        "capabilities_legacy_payments" AS "legacy_payments_status",
        "capabilities_oxxo_payments" AS "oxxo_status",
        "capabilities_p_24_payments" AS "p24_status",
        "capabilities_platform_payments" AS "platform_payments_status",
        "capabilities_sepa_debit_payments" AS "sepa_debit_payments_status",
        "capabilities_sofort_payments" AS "sofort_payments_status",
        "capabilities_tax_reporting_us_1099_k" AS "tax_reporting_1099k_status",
        "capabilities_tax_reporting_us_1099_misc" AS "tax_reporting_1099misc_status",
        "capabilities_transfers" AS "transfers_status",
        "charges_enabled",
        "company_address_city",
        "company_address_country",
        "company_address_kana_city",
        "company_address_kana_country",
        "company_address_kana_line_1",
        "company_address_kana_line_2",
        "company_address_kana_postal_code",
        "company_address_kana_state",
        "company_address_kana_town",
        "company_address_kanji_city",
        "company_address_kanji_country",
        "company_address_kanji_line_1",
        "company_address_kanji_line_2",
        "company_address_kanji_postal_code",
        "company_address_kanji_state",
        "company_address_kanji_town",
        "company_address_line_1",
        "company_address_line_2",
        "company_address_postal_code",
        "company_address_state",
        "company_directors_provided",
        "company_executives_provided",
        "company_name",
        "company_name_kana",
        "company_name_kanji",
        "company_owners_provided" AS "owners_info_provided",
        "company_phone" AS "business_phone",
        "company_structure" AS "legal_structure",
        "company_tax_id_provided" AS "tax_id_provided",
        "company_tax_id_registrar" AS "tax_id_issuer",
        "company_vat_id_provided" AS "vat_id_provided",
        "company_verification_document_back" AS "verification_doc_back",
        "company_verification_document_details" AS "verification_doc_details",
        "company_verification_document_details_code" AS "verification_doc_code",
        "company_verification_document_front" AS "verification_doc_front",
        "country",
        "created" AS "account_creation_date",
        "default_currency",
        "details_submitted",
        "email" AS "account_email",
        "individual_id",
        "is_deleted",
        "metadata",
        "payouts_enabled",
        "requirements_current_deadline" AS "current_requirements_deadline",
        "requirements_currently_due" AS "current_requirements",
        "requirements_disabled_reason",
        "requirements_errors" AS "requirement_errors",
        "requirements_eventually_due" AS "future_requirements",
        "requirements_past_due" AS "past_due_requirements",
        "requirements_pending_verification" AS "pending_verification",
        "settings_branding_icon" AS "branding_icon",
        "settings_branding_logo" AS "branding_logo_file_id",
        "settings_branding_primary_color" AS "branding_primary_color",
        "settings_card_payments_decline_on_avs_failure" AS "decline_on_avs_failure",
        "settings_card_payments_decline_on_cvc_failure" AS "decline_on_cvc_failure",
        "settings_card_payments_statement_descriptor_prefix" AS "statement_descriptor_prefix",
        "settings_dashboard_display_name" AS "dashboard_display_name",
        "settings_dashboard_timezone" AS "dashboard_timezone",
        "settings_payments_statement_descriptor" AS "payment_statement_descriptor",
        "settings_payments_statement_descriptor_kana" AS "payment_statement_descriptor_kana",
        "settings_payments_statement_descriptor_kanji" AS "payment_statement_descriptor_kanji",
        "settings_payouts_debit_negative_balances" AS "debit_negative_balances",
        "settings_payouts_schedule_delay_days" AS "payout_delay_days",
        "settings_payouts_schedule_interval" AS "payout_schedule_interval",
        "settings_payouts_schedule_monthly_anchor" AS "payout_monthly_anchor",
        "settings_payouts_schedule_weekly_anchor" AS "payout_weekly_anchor",
        "settings_payouts_statement_descriptor" AS "payout_statement_descriptor",
        "tos_acceptance_date",
        "tos_acceptance_ip",
        "tos_acceptance_user_agent",
        "type" AS "account_type"
    FROM "account_data_projected"
),

"account_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- account_creation_date: from DECIMAL to DATE
    -- account_id: from INT to VARCHAR
    -- au_becs_debit_status: from DECIMAL to VARCHAR
    -- bacs_debit_status: from DECIMAL to VARCHAR
    -- branding_icon: from DECIMAL to VARCHAR
    -- business_phone: from DECIMAL to VARCHAR
    -- business_type: from DECIMAL to VARCHAR
    -- card_issuing_status: from DECIMAL to VARCHAR
    -- cartes_bancaires_status: from DECIMAL to VARCHAR
    -- company_address_city: from DECIMAL to VARCHAR
    -- company_address_country: from DECIMAL to VARCHAR
    -- company_address_kana_city: from DECIMAL to VARCHAR
    -- company_address_kana_country: from DECIMAL to VARCHAR
    -- company_address_kana_line_1: from DECIMAL to VARCHAR
    -- company_address_kana_line_2: from DECIMAL to VARCHAR
    -- company_address_kana_postal_code: from DECIMAL to VARCHAR
    -- company_address_kana_state: from DECIMAL to VARCHAR
    -- company_address_kana_town: from DECIMAL to VARCHAR
    -- company_address_kanji_city: from DECIMAL to VARCHAR
    -- company_address_kanji_country: from DECIMAL to VARCHAR
    -- company_address_kanji_line_1: from DECIMAL to VARCHAR
    -- company_address_kanji_line_2: from DECIMAL to VARCHAR
    -- company_address_kanji_postal_code: from DECIMAL to VARCHAR
    -- company_address_kanji_state: from DECIMAL to VARCHAR
    -- company_address_kanji_town: from DECIMAL to VARCHAR
    -- company_address_line_1: from DECIMAL to VARCHAR
    -- company_address_line_2: from DECIMAL to VARCHAR
    -- company_address_postal_code: from DECIMAL to VARCHAR
    -- company_address_state: from DECIMAL to VARCHAR
    -- company_directors_provided: from DECIMAL to BOOLEAN
    -- company_executives_provided: from DECIMAL to BOOLEAN
    -- company_name: from DECIMAL to VARCHAR
    -- company_name_kana: from DECIMAL to VARCHAR
    -- company_name_kanji: from DECIMAL to VARCHAR
    -- current_requirements: from DECIMAL to VARCHAR
    -- current_requirements_deadline: from DECIMAL to DATE
    -- decline_on_avs_failure: from DECIMAL to BOOLEAN
    -- decline_on_cvc_failure: from DECIMAL to BOOLEAN
    -- fpx_status: from DECIMAL to VARCHAR
    -- future_requirements: from DECIMAL to VARCHAR
    -- grabpay_status: from DECIMAL to VARCHAR
    -- individual_id: from DECIMAL to VARCHAR
    -- jcb_status: from DECIMAL to VARCHAR
    -- legacy_payments_status: from DECIMAL to VARCHAR
    -- legal_structure: from DECIMAL to VARCHAR
    -- metadata: from DECIMAL to JSON
    -- owners_info_provided: from DECIMAL to BOOLEAN
    -- oxxo_status: from DECIMAL to VARCHAR
    -- past_due_requirements: from DECIMAL to ARRAY
    -- payment_statement_descriptor_kana: from DECIMAL to VARCHAR
    -- payment_statement_descriptor_kanji: from DECIMAL to VARCHAR
    -- payout_monthly_anchor: from DECIMAL to INT
    -- payout_statement_descriptor: from DECIMAL to VARCHAR
    -- payout_weekly_anchor: from DECIMAL to VARCHAR
    -- pending_verification: from DECIMAL to ARRAY
    -- product_description: from DECIMAL to VARCHAR
    -- requirement_errors: from DECIMAL to ARRAY
    -- requirements_disabled_reason: from DECIMAL to VARCHAR
    -- statement_descriptor_prefix: from DECIMAL to VARCHAR
    -- support_phone: from DECIMAL to VARCHAR
    -- support_postal_code: from INT to VARCHAR
    -- tax_id_issuer: from DECIMAL to VARCHAR
    -- tax_id_provided: from DECIMAL to BOOLEAN
    -- tax_reporting_1099k_status: from DECIMAL to VARCHAR
    -- tax_reporting_1099misc_status: from DECIMAL to VARCHAR
    -- tos_acceptance_date: from DECIMAL to TIMESTAMP
    -- tos_acceptance_ip: from DECIMAL to VARCHAR
    -- tos_acceptance_user_agent: from DECIMAL to VARCHAR
    -- transfers_status: from DECIMAL to VARCHAR
    -- vat_id_provided: from DECIMAL to BOOLEAN
    -- verification_doc_back: from DECIMAL to VARCHAR
    -- verification_doc_code: from DECIMAL to VARCHAR
    -- verification_doc_details: from DECIMAL to VARCHAR
    -- verification_doc_front: from DECIMAL to VARCHAR
    SELECT
        "merchant_category_code",
        "business_name",
        "support_city",
        "support_country",
        "support_address_line1",
        "support_address_line2",
        "support_state",
        "support_email",
        "support_url",
        "business_url",
        "afterpay_clearpay_status",
        "bancontact_status",
        "card_payments_status",
        "eps_status",
        "giropay_status",
        "ideal_status",
        "p24_status",
        "platform_payments_status",
        "sepa_debit_payments_status",
        "sofort_payments_status",
        "charges_enabled",
        "country",
        "default_currency",
        "details_submitted",
        "account_email",
        "is_deleted",
        "payouts_enabled",
        "branding_logo_file_id",
        "branding_primary_color",
        "dashboard_display_name",
        "dashboard_timezone",
        "payment_statement_descriptor",
        "debit_negative_balances",
        "payout_delay_days",
        "payout_schedule_interval",
        "account_type",
        CAST("account_creation_date" AS DATE) AS "account_creation_date",
        CAST("account_id" AS VARCHAR) AS "account_id",
        CAST("au_becs_debit_status" AS VARCHAR) AS "au_becs_debit_status",
        CAST("bacs_debit_status" AS VARCHAR) AS "bacs_debit_status",
        CAST("branding_icon" AS VARCHAR) AS "branding_icon",
        CAST("business_phone" AS VARCHAR) AS "business_phone",
        CAST("business_type" AS VARCHAR) AS "business_type",
        CAST("card_issuing_status" AS VARCHAR) AS "card_issuing_status",
        CAST("cartes_bancaires_status" AS VARCHAR) AS "cartes_bancaires_status",
        CAST("company_address_city" AS VARCHAR) AS "company_address_city",
        CAST("company_address_country" AS VARCHAR) AS "company_address_country",
        CAST("company_address_kana_city" AS VARCHAR) AS "company_address_kana_city",
        CAST("company_address_kana_country" AS VARCHAR) AS "company_address_kana_country",
        CAST("company_address_kana_line_1" AS VARCHAR) AS "company_address_kana_line_1",
        CAST("company_address_kana_line_2" AS VARCHAR) AS "company_address_kana_line_2",
        CAST("company_address_kana_postal_code" AS VARCHAR) AS "company_address_kana_postal_code",
        CAST("company_address_kana_state" AS VARCHAR) AS "company_address_kana_state",
        CAST("company_address_kana_town" AS VARCHAR) AS "company_address_kana_town",
        CAST("company_address_kanji_city" AS VARCHAR) AS "company_address_kanji_city",
        CAST("company_address_kanji_country" AS VARCHAR) AS "company_address_kanji_country",
        CAST("company_address_kanji_line_1" AS VARCHAR) AS "company_address_kanji_line_1",
        CAST("company_address_kanji_line_2" AS VARCHAR) AS "company_address_kanji_line_2",
        CAST("company_address_kanji_postal_code" AS VARCHAR) AS "company_address_kanji_postal_code",
        CAST("company_address_kanji_state" AS VARCHAR) AS "company_address_kanji_state",
        CAST("company_address_kanji_town" AS VARCHAR) AS "company_address_kanji_town",
        CAST("company_address_line_1" AS VARCHAR) AS "company_address_line_1",
        CAST("company_address_line_2" AS VARCHAR) AS "company_address_line_2",
        CAST("company_address_postal_code" AS VARCHAR) AS "company_address_postal_code",
        CAST("company_address_state" AS VARCHAR) AS "company_address_state",
        CAST("company_directors_provided" AS BOOLEAN) AS "company_directors_provided",
        CAST("company_executives_provided" AS BOOLEAN) AS "company_executives_provided",
        CAST("company_name" AS VARCHAR) AS "company_name",
        CAST("company_name_kana" AS VARCHAR) AS "company_name_kana",
        CAST("company_name_kanji" AS VARCHAR) AS "company_name_kanji",
        CAST("current_requirements" AS VARCHAR) AS "current_requirements",
        CAST("current_requirements_deadline" AS DATE) AS "current_requirements_deadline",
        CAST("decline_on_avs_failure" AS BOOLEAN) AS "decline_on_avs_failure",
        CAST("decline_on_cvc_failure" AS BOOLEAN) AS "decline_on_cvc_failure",
        CAST("fpx_status" AS VARCHAR) AS "fpx_status",
        CAST("future_requirements" AS VARCHAR) AS "future_requirements",
        CAST("grabpay_status" AS VARCHAR) AS "grabpay_status",
        CAST("individual_id" AS VARCHAR) AS "individual_id",
        CAST("jcb_status" AS VARCHAR) AS "jcb_status",
        CAST("legacy_payments_status" AS VARCHAR) AS "legacy_payments_status",
        CAST("legal_structure" AS VARCHAR) AS "legal_structure",
        CAST("metadata" AS JSON) AS "metadata",
        CAST("owners_info_provided" AS BOOLEAN) AS "owners_info_provided",
        CAST("oxxo_status" AS VARCHAR) AS "oxxo_status",
        "past_due_requirements" AS "past_due_requirements",
        CAST("payment_statement_descriptor_kana" AS VARCHAR) AS "payment_statement_descriptor_kana",
        CAST("payment_statement_descriptor_kanji" AS VARCHAR) AS "payment_statement_descriptor_kanji",
        CAST("payout_monthly_anchor" AS INT) AS "payout_monthly_anchor",
        CAST("payout_statement_descriptor" AS VARCHAR) AS "payout_statement_descriptor",
        CAST("payout_weekly_anchor" AS VARCHAR) AS "payout_weekly_anchor",
        "pending_verification" AS "pending_verification",
        CAST("product_description" AS VARCHAR) AS "product_description",
        string_split(CAST("requirement_errors" AS VARCHAR), ',') AS "requirement_errors",
        CAST("requirements_disabled_reason" AS VARCHAR) AS "requirements_disabled_reason",
        CAST("statement_descriptor_prefix" AS VARCHAR) AS "statement_descriptor_prefix",
        CAST("support_phone" AS VARCHAR) AS "support_phone",
        CAST("support_postal_code" AS VARCHAR) AS "support_postal_code",
        CAST("tax_id_issuer" AS VARCHAR) AS "tax_id_issuer",
        CAST("tax_id_provided" AS BOOLEAN) AS "tax_id_provided",
        CAST("tax_reporting_1099k_status" AS VARCHAR) AS "tax_reporting_1099k_status",
        CAST("tax_reporting_1099misc_status" AS VARCHAR) AS "tax_reporting_1099misc_status",
        CAST("tos_acceptance_date" AS TIMESTAMP) AS "tos_acceptance_date",
        CAST("tos_acceptance_ip" AS VARCHAR) AS "tos_acceptance_ip",
        CAST("tos_acceptance_user_agent" AS VARCHAR) AS "tos_acceptance_user_agent",
        CAST("transfers_status" AS VARCHAR) AS "transfers_status",
        CAST("vat_id_provided" AS BOOLEAN) AS "vat_id_provided",
        CAST("verification_doc_back" AS VARCHAR) AS "verification_doc_back",
        CAST("verification_doc_code" AS VARCHAR) AS "verification_doc_code",
        CAST("verification_doc_details" AS VARCHAR) AS "verification_doc_details",
        CAST("verification_doc_front" AS VARCHAR) AS "verification_doc_front"
    FROM "account_data_projected_renamed"
),

"account_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 46 columns with unacceptable missing values
    -- account_creation_date has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- branding_icon has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- business_phone has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- business_type has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- card_issuing_status has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- cartes_bancaires_status has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- company_address_city has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- company_address_country has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- company_address_line_1 has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- company_address_line_2 has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- company_address_postal_code has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- company_address_state has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- company_directors_provided has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- company_executives_provided has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- company_name has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- current_requirements has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- current_requirements_deadline has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- decline_on_avs_failure has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- decline_on_cvc_failure has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- future_requirements has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- individual_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- legacy_payments_status has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- legal_structure has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- metadata has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- owners_info_provided has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- past_due_requirements has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- payout_statement_descriptor has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- pending_verification has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- product_description has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- requirement_errors has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- requirements_disabled_reason has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- statement_descriptor_prefix has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- support_phone has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tax_id_issuer has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tax_id_provided has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tax_reporting_1099k_status has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tax_reporting_1099misc_status has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tos_acceptance_date has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tos_acceptance_ip has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tos_acceptance_user_agent has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- transfers_status has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- vat_id_provided has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- verification_doc_back has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- verification_doc_code has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- verification_doc_details has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- verification_doc_front has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "merchant_category_code",
        "business_name",
        "support_city",
        "support_country",
        "support_address_line1",
        "support_address_line2",
        "support_state",
        "support_email",
        "support_url",
        "business_url",
        "afterpay_clearpay_status",
        "bancontact_status",
        "card_payments_status",
        "eps_status",
        "giropay_status",
        "ideal_status",
        "p24_status",
        "platform_payments_status",
        "sepa_debit_payments_status",
        "sofort_payments_status",
        "charges_enabled",
        "country",
        "default_currency",
        "details_submitted",
        "account_email",
        "is_deleted",
        "payouts_enabled",
        "branding_logo_file_id",
        "branding_primary_color",
        "dashboard_display_name",
        "dashboard_timezone",
        "payment_statement_descriptor",
        "debit_negative_balances",
        "payout_delay_days",
        "payout_schedule_interval",
        "account_type",
        "account_id",
        "au_becs_debit_status",
        "bacs_debit_status",
        "company_address_kana_city",
        "company_address_kana_country",
        "company_address_kana_line_1",
        "company_address_kana_line_2",
        "company_address_kana_postal_code",
        "company_address_kana_state",
        "company_address_kana_town",
        "company_address_kanji_city",
        "company_address_kanji_country",
        "company_address_kanji_line_1",
        "company_address_kanji_line_2",
        "company_address_kanji_postal_code",
        "company_address_kanji_state",
        "company_address_kanji_town",
        "company_name_kana",
        "company_name_kanji",
        "fpx_status",
        "grabpay_status",
        "jcb_status",
        "oxxo_status",
        "payment_statement_descriptor_kana",
        "payment_statement_descriptor_kanji",
        "payout_monthly_anchor",
        "payout_weekly_anchor",
        "support_postal_code"
    FROM "account_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "account_data_projected_renamed_casted_missing_handled"

stg_account_data.yml (Document the table)

version: 2
models:
- name: stg_account_data
  description: The table is about a Stripe business account. It contains details like
    business profile, capabilities, company information, settings, and compliance
    requirements. Key fields include business name, address, supported payment methods,
    payout settings, and legal acceptance details. The account belongs to Hogwarts
    School, with education-related merchant category code and wizarding world URLs.
  columns:
  - name: merchant_category_code
    description: Merchant Category Code for the business
    tests:
    - not_null
  - name: business_name
    description: Name of the business
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the name of the business. For this table,
        each row is a unique business account. Business names are generally unique,
        especially for a specific platform like Stripe.
  - name: support_city
    description: City of the business support address
    tests:
    - not_null
  - name: support_country
    description: Country of the business support address
    tests:
    - not_null
  - name: support_address_line1
    description: First line of the business support address
    tests:
    - not_null
  - name: support_address_line2
    description: Second line of the business support address
    tests:
    - not_null
  - name: support_state
    description: State of the business support address
    tests:
    - not_null
    - accepted_values:
        values:
        - AL
        - AK
        - AZ
        - AR
        - CA
        - CO
        - CT
        - DE
        - FL
        - GA
        - HI
        - ID
        - IL
        - IN
        - IA
        - KS
        - KY
        - LA
        - ME
        - MD
        - MA
        - MI
        - MN
        - MS
        - MO
        - MT
        - NE
        - NV
        - NH
        - NJ
        - NM
        - NY
        - NC
        - ND
        - OH
        - OK
        - OR
        - PA
        - RI
        - SC
        - SD
        - TN
        - TX
        - UT
        - VT
        - VA
        - WA
        - WV
        - WI
        - WY
        - DC
        - AS
        - GU
        - MP
        - PR
        - VI
  - name: support_email
    description: Support email address for the business
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the support email address for the business.
        For this table, each row is a unique business account. Email addresses are
        generally unique for each business account on platforms like Stripe.
  - name: support_url
    description: Support website URL for the business
    tests:
    - not_null
    - unique
    - accepted_values:
        values:
        - https://www.wizardingworld.com/help
        - https://www.wizardingworld.com/
    cocoon_meta:
      uniqueness: This column represents the support website URL for the business.
        For this table, each row is a unique business account. Support URLs are likely
        to be unique for each business, especially on a platform like Stripe.
  - name: business_url
    description: Main website URL for the business
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the main website URL for the business. For
        this table, each row is a unique business account. Business URLs are typically
        unique for each business.
  - name: afterpay_clearpay_status
    description: Afterpay/Clearpay payment capability status
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
        - rejected
  - name: bancontact_status
    description: Bancontact payment capability status
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
  - name: card_payments_status
    description: Card payment capability status
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
        - suspended
        - restricted
        - blocked
        - expired
        - not_available
  - name: eps_status
    description: EPS payment capability status
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - suspended
        - pending
        - blocked
        - limited
        - restricted
        - unavailable
        - maintenance
        - error
  - name: giropay_status
    description: Giropay payment capability status
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
  - name: ideal_status
    description: iDEAL payment capability status
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
        - suspended
        - disabled
        - unavailable
  - name: p24_status
    description: Przelewy24 payment capability status
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
  - name: platform_payments_status
    description: Status of platform payment capability
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
        - suspended
        - disabled
        - maintenance
        - error
  - name: sepa_debit_payments_status
    description: Status of SEPA debit payment capability
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
        - suspended
  - name: sofort_payments_status
    description: Status of Sofort payment capability
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
        - suspended
        - unavailable
        - error
  - name: charges_enabled
    description: Whether charges are enabled for the account
    tests:
    - not_null
  - name: country
    description: Country where the company is registered
    tests:
    - not_null
  - name: default_currency
    description: Default currency for the account
    tests:
    - not_null
  - name: details_submitted
    description: Indicates if all required details were submitted
    tests:
    - not_null
  - name: account_email
    description: Primary email address for the account
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the primary email address for the account.
        For this table, each row is a unique Stripe business account. Email addresses
        are typically unique for each account in financial systems, making this a
        good candidate for a unique identifier.
  - name: is_deleted
    description: Indicates if the account has been deleted
    tests:
    - not_null
  - name: payouts_enabled
    description: Indicates if payouts are enabled for account
    tests:
    - not_null
  - name: branding_logo_file_id
    description: File ID for the company's branding logo
    tests:
    - not_null
  - name: branding_primary_color
    description: Primary color for branding in hexadecimal format
    tests:
    - not_null
  - name: dashboard_display_name
    description: Display name for the Stripe dashboard
    tests:
    - not_null
  - name: dashboard_timezone
    description: Timezone setting for the Stripe dashboard
    tests:
    - not_null
  - name: payment_statement_descriptor
    description: Description appearing on customer's credit card statement
    tests:
    - not_null
  - name: debit_negative_balances
    description: Allow debiting account for negative balances
    tests:
    - not_null
  - name: payout_delay_days
    description: Number of days to delay scheduled payouts
    tests:
    - not_null
  - name: payout_schedule_interval
    description: Frequency of scheduled payouts
    tests:
    - not_null
    - accepted_values:
        values:
        - daily
        - weekly
        - biweekly
        - monthly
        - quarterly
        - semi-annually
        - annually
  - name: account_type
    description: Type of Stripe account
    tests:
    - not_null
    - accepted_values:
        values:
        - standard
        - express
        - custom
  - name: account_id
    description: Unique identifier for the Stripe account
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the unique identifier for the Stripe account.
        For this table, each row is for a unique Stripe business account. This is
        unique across rows as it's designed to be a unique identifier for each account.
  - name: au_becs_debit_status
    description: Australian BECS Direct Debit payment capability status
    cocoon_meta:
      missing_acceptable: Australian payment system not applicable for US company
  - name: bacs_debit_status
    description: BACS Direct Debit payment capability status
    cocoon_meta:
      missing_acceptable: UK payment system not applicable for US company
  - name: company_address_kana_city
    description: City in Kana script for Japanese addresses
    cocoon_meta:
      missing_acceptable: Kana address format not applicable for US company
  - name: company_address_kana_country
    description: Country in Kana script for Japanese addresses
    cocoon_meta:
      missing_acceptable: Kana address format not applicable for US company
  - name: company_address_kana_line_1
    description: Address line 1 in Kana script
    cocoon_meta:
      missing_acceptable: Kana address format not applicable for US company
  - name: company_address_kana_line_2
    description: Address line 2 in Kana script
    cocoon_meta:
      missing_acceptable: Kana address format not applicable for US company
  - name: company_address_kana_postal_code
    description: Postal code in Kana script
    cocoon_meta:
      missing_acceptable: Kana address format not applicable for US company
  - name: company_address_kana_state
    description: State in Kana script for Japanese addresses
    cocoon_meta:
      missing_acceptable: Kana address format not applicable for US company
  - name: company_address_kana_town
    description: Town in Kana script for Japanese addresses
    cocoon_meta:
      missing_acceptable: Kana address format not applicable for US company
  - name: company_address_kanji_city
    description: City in Kanji script for Japanese addresses
    cocoon_meta:
      missing_acceptable: Kanji address format not applicable for US company
  - name: company_address_kanji_country
    description: Country in Kanji script for Japanese addresses
    cocoon_meta:
      missing_acceptable: Kanji address format not applicable for US company
  - name: company_address_kanji_line_1
    description: Address line 1 in Kanji script
    cocoon_meta:
      missing_acceptable: Kanji address format not applicable for US company
  - name: company_address_kanji_line_2
    description: Address line 2 in Kanji script
    cocoon_meta:
      missing_acceptable: Kanji address format not applicable for US company
  - name: company_address_kanji_postal_code
    description: Postal code in Kanji script
    cocoon_meta:
      missing_acceptable: Kanji address format not applicable for US company
  - name: company_address_kanji_state
    description: State in Kanji script for Japanese addresses
    cocoon_meta:
      missing_acceptable: Kanji address format not applicable for US company
  - name: company_address_kanji_town
    description: Town in Kanji script for Japanese addresses
    cocoon_meta:
      missing_acceptable: Kanji address format not applicable for US company
  - name: company_name_kana
    description: Company name in Japanese kana characters
    cocoon_meta:
      missing_acceptable: Kana company name not applicable for US company
  - name: company_name_kanji
    description: Company name in Japanese kanji characters
    cocoon_meta:
      missing_acceptable: Kanji company name not applicable for US company
  - name: fpx_status
    description: FPX payment capability status
    cocoon_meta:
      missing_acceptable: FPX is a Malaysian payment method, not used globally.
  - name: grabpay_status
    description: GrabPay payment capability status
    cocoon_meta:
      missing_acceptable: GrabPay is a Southeast Asian payment method, not used globally.
  - name: jcb_status
    description: JCB payment capability status
    cocoon_meta:
      missing_acceptable: JCB is a Japanese credit card, not used globally.
  - name: oxxo_status
    description: OXXO payment capability status
    cocoon_meta:
      missing_acceptable: OXXO is a Mexican payment method, not used globally.
  - name: payment_statement_descriptor_kana
    description: Payment statement descriptor in Japanese kana
    cocoon_meta:
      missing_acceptable: Kana script is only used for Japanese language.
  - name: payment_statement_descriptor_kanji
    description: Payment statement descriptor in Japanese kanji
    cocoon_meta:
      missing_acceptable: Kanji script is only used for Japanese language.
  - name: payout_monthly_anchor
    description: Day of month for monthly payouts
    cocoon_meta:
      missing_acceptable: Not applicable for daily payout schedule.
  - name: payout_weekly_anchor
    description: Day of week for weekly payouts
    cocoon_meta:
      missing_acceptable: Not applicable for daily payout schedule.
  - name: support_postal_code
    description: Postal code of the business support address
    tests:
    - not_null

stg_balance_transaction_data (first 100 rows)

transaction_id transaction_amount_cents currency_code transaction_description fee_amount_cents net_amount_cents transaction_source_id transaction_status transaction_type payout_id connected_account_id funds_available_date transaction_created_at
0 txn_0IV4rIig6peNXzgDK3XAFbaN -18759 usd f39657a1847db73d9a2abb0bad3d31ae 0 -18759 po_0IV4rIig6peNXzgD51VFKdaB pending payout po_0IV4rIig6peNXzgD51VFKdaB None 2021-03-16 2021-03-15 01:04:36
1 txn_0IDYgiig6peNXzgDuNvLeoLR 2040000 usd d267c9d09a2d1e50f12635bd2b56ed29 59190 1980810 ch_0IDYghig6peNXzgDhuOFKdTS pending charge po_0IFUKBig6peNXzgDZQM7WPAo None 2021-02-01 2021-01-25 17:17:15
2 txn_0IG5fvig6peNXzgD8jemrxAp 117524 usd 0662d6089789e1fabd56c6d55e91ef09 3438 114086 ch_0IG5fuig6peNXzgDzZkrO949 pending charge po_0II1gGig6peNXzgD4BxKEJJJ None 2021-02-08 2021-02-01 16:54:54
3 txn_0ILGCbig6peNXzgDqjp7xaaX 7239375 usd 612942eb1230077a0b1d066de5aba0db 209972 7029403 ch_0ILGCZig6peNXzgDw4eVbq0v pending charge po_0IN6L6ig6peNXzgDu7m6fhRI None 2021-02-22 2021-02-15 23:09:59
4 txn_0IO6DWig6peNXzgDF8qNjZNX 255360 usd b8de27e00022f92981c965125c15c22d 7435 247925 ch_0IO6DVig6peNXzgDgTOGtdeD pending charge po_0IQ08Sig6peNXzgDC6UG0Oxc None 2021-03-02 2021-02-23 19:06:41
5 txn_0IROZoig6peNXzgDRsBjph8K 438750 usd d3c18c425369d3c6b26126b7f791cf3f 12754 425996 ch_0IROZmig6peNXzgDwohSYaPj pending charge po_0ITGUHig6peNXzgD78pmjvio None 2021-03-11 2021-03-04 21:19:18
6 txn_0IT7uhig6peNXzgDolTgmiUJ 19350 usd a29cfd524867f29bd7eddcb21fdf6e3b 591 18759 ch_0IT7ugig6peNXzgDh9iGZed7 pending charge po_0IV4rIig6peNXzgD51VFKdaB None 2021-03-16 2021-03-09 15:56:02
7 txn_0IUBwDig6peNXzgDCYCHC7gd 3519960 usd e8be2b872cd9d14ddf3b5cd89860d551 137308 3382652 ch_0IUBwCig6peNXzgDTOTEw24B pending charge None None 2021-03-19 2021-03-12 14:26:00
8 txn_0IUIaVig6peNXzgDoGvsNC17 7499999 usd 9b8159d008204266ff7f2df19843d5b4 217530 7282469 ch_0IUIaTig6peNXzgDhyoZBxWv pending charge None None 2021-03-19 2021-03-12 21:32:01

stg_balance_transaction_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"balance_transaction_data_projected" AS (
    -- Projection: Selecting 14 out of 15 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "amount",
        "available_on",
        "connected_account_id",
        "created",
        "currency",
        "description",
        "exchange_rate",
        "fee",
        "net",
        "source",
        "status",
        "type",
        "payout_id"
    FROM "balance_transaction_data"
),

"balance_transaction_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> transaction_id
    -- amount -> transaction_amount_cents
    -- available_on -> funds_available_date
    -- created -> transaction_created_at
    -- currency -> currency_code
    -- description -> transaction_description
    -- fee -> fee_amount_cents
    -- net -> net_amount_cents
    -- source -> transaction_source_id
    -- status -> transaction_status
    -- type -> transaction_type
    SELECT 
        "id" AS "transaction_id",
        "amount" AS "transaction_amount_cents",
        "available_on" AS "funds_available_date",
        "connected_account_id",
        "created" AS "transaction_created_at",
        "currency" AS "currency_code",
        "description" AS "transaction_description",
        "exchange_rate",
        "fee" AS "fee_amount_cents",
        "net" AS "net_amount_cents",
        "source" AS "transaction_source_id",
        "status" AS "transaction_status",
        "type" AS "transaction_type",
        "payout_id"
    FROM "balance_transaction_data_projected"
),

"balance_transaction_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- connected_account_id: from DECIMAL to VARCHAR
    -- funds_available_date: from VARCHAR to DATE
    -- transaction_created_at: from VARCHAR to TIMESTAMP
    SELECT
        "transaction_id",
        "transaction_amount_cents",
        "currency_code",
        "transaction_description",
        "exchange_rate",
        "fee_amount_cents",
        "net_amount_cents",
        "transaction_source_id",
        "transaction_status",
        "transaction_type",
        "payout_id",
        CAST("connected_account_id" AS VARCHAR) AS "connected_account_id",
        CAST("funds_available_date" AS DATE) AS "funds_available_date",
        CAST("transaction_created_at" AS TIMESTAMP) AS "transaction_created_at"
    FROM "balance_transaction_data_projected_renamed"
),

"balance_transaction_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 2 columns with unacceptable missing values
    -- exchange_rate has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- payout_id has 22.22 percent missing. Strategy: 🔄 Unchanged
    SELECT
        "transaction_id",
        "transaction_amount_cents",
        "currency_code",
        "transaction_description",
        "fee_amount_cents",
        "net_amount_cents",
        "transaction_source_id",
        "transaction_status",
        "transaction_type",
        "payout_id",
        "connected_account_id",
        "funds_available_date",
        "transaction_created_at"
    FROM "balance_transaction_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "balance_transaction_data_projected_renamed_casted_missing_handled"

stg_balance_transaction_data.yml (Document the table)

version: 2
models:
- name: stg_balance_transaction_data
  description: The table is about balance transactions. It includes details such as
    transaction ID, amount, date, currency, description, fees, net amount, source,
    status, and type. Each row represents a financial transaction like a charge or
    payout. The table tracks monetary movements, including both incoming (charges)
    and outgoing (payouts) transactions, with associated fees and net amounts.
  columns:
  - name: transaction_id
    description: Unique identifier for the transaction
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each transaction.
        For this table, each row is for a single financial transaction, and transaction_id
        is unique across rows.
  - name: transaction_amount_cents
    description: Transaction amount in cents
    tests:
    - not_null
  - name: currency_code
    description: Currency code of the transaction
    tests:
    - not_null
  - name: transaction_description
    description: Unique identifier or description of the transaction
    tests:
    - not_null
  - name: fee_amount_cents
    description: Fee amount in cents
    tests:
    - not_null
  - name: net_amount_cents
    description: Net amount after fees in cents
    tests:
    - not_null
  - name: transaction_source_id
    description: Source of the transaction (charge or payout ID)
    tests:
    - not_null
  - name: transaction_status
    description: Current status of the transaction
    tests:
    - not_null
    - accepted_values:
        values:
        - pending
        - completed
        - failed
        - cancelled
        - processing
        - rejected
        - on hold
        - refunded
        - partially refunded
  - name: transaction_type
    description: Type of transaction (charge or payout)
    tests:
    - not_null
    - accepted_values:
        values:
        - charge
        - payout
  - name: payout_id
    description: Identifier for the associated payout
    tests:
    - not_null
  - name: connected_account_id
    description: ID of the connected account (empty in this data)
    cocoon_meta:
      missing_acceptable: Not applicable for direct transactions without connected
        accounts.
  - name: funds_available_date
    description: Date when the funds become available
    tests:
    - not_null
  - name: transaction_created_at
    description: Date and time when the transaction was created
    tests:
    - not_null

stg_payment_method_card_data (first 100 rows)

payment_method_id payment_provider_id card_fingerprint funding_type digital_wallet_type
0 pm_0ISrBXig6peNXzgD6hYaUH2Z 553f65f270c86a4a05c964dc20e8cc70 iVwXZtKtbkTtJpN0 credit None
1 pm_0IStqWig6peNXzgDEGg3esc8 553f65f270c86a4a05c964dc20e8cc70 PBYmzFcBM1pwHfTQ credit None
2 pm_0ISornig6peNXzgDOeZ25NDW 553f65f270c86a4a05c964dc20e8cc70 fqtU9wYRQpmzlc4A credit None
3 pm_0ITGJgig6peNXzgDdqU3vem1 553f65f270c86a4a05c964dc20e8cc70 t1Z14pQbLsAtxb3N credit None
4 pm_0ITo6Eig6peNXzgDSGO9wikO 553f65f270c86a4a05c964dc20e8cc70 k2VOC54Kv0y6ju1j credit None
5 pm_0ITpNsig6peNXzgD6eKsQGnb 553f65f270c86a4a05c964dc20e8cc70 Dd3yZ5fegTpHhPvk credit None
6 pm_0ITr6jig6peNXzgDA6dTn2KI 553f65f270c86a4a05c964dc20e8cc70 JEtovVIKPa7HmNlB credit None
7 card_0IUBw6ig6peNXzgDLOJ0s9oJ 553f65f270c86a4a05c964dc20e8cc70 GnaMObYOxVfGvuVC credit None
8 pm_0IUGRYig6peNXzgDeUWYzAZx 553f65f270c86a4a05c964dc20e8cc70 HkQVKOdMfx7OQGlz credit None
9 pm_0IHlxQig6peNXzgDPbBTz3wN 553f65f270c86a4a05c964dc20e8cc70 xt3IXBWUo94YvvyJ credit None
10 pm_0IQaNxig6peNXzgDjLiWdPq7 553f65f270c86a4a05c964dc20e8cc70 3okrxlVqFJe4eFLP credit None

stg_payment_method_card_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"payment_method_card_data_projected" AS (
    -- Projection: Selecting 8 out of 9 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "payment_method_id",
        "brand",
        "charge_id",
        "description",
        "fingerprint",
        "funding",
        "type",
        "wallet_type"
    FROM "payment_method_card_data"
),

"payment_method_card_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- brand -> payment_provider_id
    -- fingerprint -> card_fingerprint
    -- funding -> funding_type
    -- type -> payment_method_type
    -- wallet_type -> digital_wallet_type
    SELECT 
        "payment_method_id",
        "brand" AS "payment_provider_id",
        "charge_id",
        "description",
        "fingerprint" AS "card_fingerprint",
        "funding" AS "funding_type",
        "type" AS "payment_method_type",
        "wallet_type" AS "digital_wallet_type"
    FROM "payment_method_card_data_projected"
),

"payment_method_card_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- charge_id: from DECIMAL to VARCHAR
    -- description: from DECIMAL to VARCHAR
    -- digital_wallet_type: from DECIMAL to VARCHAR
    -- payment_method_type: from DECIMAL to VARCHAR
    SELECT
        "payment_method_id",
        "payment_provider_id",
        "card_fingerprint",
        "funding_type",
        CAST("charge_id" AS VARCHAR) AS "charge_id",
        CAST("description" AS VARCHAR) AS "description",
        CAST("digital_wallet_type" AS VARCHAR) AS "digital_wallet_type",
        CAST("payment_method_type" AS VARCHAR) AS "payment_method_type"
    FROM "payment_method_card_data_projected_renamed"
),

"payment_method_card_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 3 columns with unacceptable missing values
    -- charge_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- description has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- payment_method_type has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "payment_method_id",
        "payment_provider_id",
        "card_fingerprint",
        "funding_type",
        "digital_wallet_type"
    FROM "payment_method_card_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "payment_method_card_data_projected_renamed_casted_missing_handled"

stg_payment_method_card_data.yml (Document the table)

version: 2
models:
- name: stg_payment_method_card_data
  description: The table is about payment method card details. It includes unique
    payment method IDs, a consistent brand identifier, and fingerprints for each card.
    The funding type is specified as credit for all entries. Some fields like charge_id,
    description, type, and wallet_type are empty. The table appears to store essential
    information for credit card payment methods.
  columns:
  - name: payment_method_id
    description: Unique identifier for the payment method
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each payment method.
        For this table, each row represents a distinct payment method, and the payment_method_id
        appears to be unique across rows.
  - name: payment_provider_id
    description: Identifier for the payment provider or card issuer
    tests:
    - not_null
  - name: card_fingerprint
    description: Unique identifier for the specific card
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each specific card.
        For this table, each row represents a distinct payment method, and the card_fingerprint
        appears to be unique across rows.
  - name: funding_type
    description: Type of funding source for the payment method
    tests:
    - not_null
    - accepted_values:
        values:
        - credit
        - debit
        - cash
        - check
        - wire transfer
        - cryptocurrency
        - gift card
        - store credit
        - loyalty points
        - prepaid card
        - mobile payment
        - bank transfer
  - name: digital_wallet_type
    description: Specifies the digital wallet used, if applicable
    cocoon_meta:
      missing_acceptable: Not applicable for non-digital wallet transactions.

stg_card_data (first 100 rows)

issuing_country expiration_year currency payment_method_id expiration_month payment_network funding_type card_brand is_deleted cvc_verification card_fingerprint creation_datetime last4_digits metadata
0 SG 2024 usd pm_0IB5RYig6peNXzgDEpJNTma5 12 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass dBtxWQhL5E69vKaA 2021-02-12 02:21:07 6002 None
1 US 2025 usd pm_0ICE3kig6peNXzgDaIknpelY 6 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass 8zjMKolROJb2DOfU 2021-02-12 02:21:07 1019 {"external_id":"80755622-45b3-40a6-9544-55485215151"}
2 US 2023 usd pm_0IBsCaig6peNXzgDJizDwm5N 12 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass vPwaBFU1Wv1CQqVm 2021-02-12 02:21:07 1101 None
3 SG 2024 usd pm_0IB5SCig6peNXzgDnoOeWOM2 12 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass dBtxWQhL5E69vKaA 2021-02-12 02:21:07 6002 None
4 US 2022 usd pm_0ICQWNig6peNXzgDdRO1sgVD 5 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass 4Z2iVx6VARCRpNa1 2021-02-12 02:21:07 1074 None
5 US 2021 usd pm_0IDYghig6peNXzgDayKTgvhk 6 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass kfKa2SdMc7wknRvo 2021-02-12 02:21:07 7029 None
6 US 2024 usd pm_0IEiyEig6peNXzgDQKMy0e9r 11 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass 0RngWb400WEDhlk0 2021-02-12 02:21:07 1003 None
7 US 2025 usd pm_0IEj3Nig6peNXzgDca8CkzmS 10 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass tfeM21vlpK28vge1 2021-02-12 02:21:07 7001 {"external_id":"80755622-45b3-40a6-9544-44455582c"}
8 US 2021 usd pm_0IOPFAig6peNXzgDe1tz420v 3 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass SHqULdMTagzWt3dY 2021-02-12 02:21:07 65 None
9 SG 2024 usd pm_0IOsAdig6peNXzgDvt1wyFWD 12 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass dBtxWQhL5E69vKaA 2021-02-12 02:21:07 6002 None
10 AU 2024 usd pm_0IRmpUig6peNXzgDiWmECRTW 3 553f65f270c86a4a05c964dc20e8cc70 credit 553f65f270c86a4a05c964dc20e8cc70 False pass CbPvCaPZuJyEx9Fl 2021-02-12 02:21:07 1006 {"external_id":"80755622-45b3-40a6-9544-25554515"}

stg_card_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"card_data_projected" AS (
    -- Projection: Selecting 29 out of 30 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "account_id",
        "address_city",
        "address_country",
        "address_line_1",
        "address_line_1_check",
        "address_line_2",
        "address_state",
        "address_zip",
        "address_zip_check",
        "brand",
        "connected_account_id",
        "country",
        "created",
        "currency",
        "customer_id",
        "cvc_check",
        "dynamic_last_4",
        "exp_month",
        "exp_year",
        "fingerprint",
        "funding",
        "is_deleted",
        "last_4",
        "name",
        "network",
        "recipient",
        "tokenization_method",
        "metadata"
    FROM "card_data"
),

"card_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> payment_method_id
    -- address_city -> billing_city
    -- address_country -> billing_country
    -- address_line_1 -> billing_address_line1
    -- address_line_1_check -> address_line1_verification
    -- address_line_2 -> billing_address_line2
    -- address_state -> billing_state
    -- address_zip -> billing_zip
    -- address_zip_check -> zip_verification
    -- brand -> card_brand
    -- country -> issuing_country
    -- created -> creation_datetime
    -- cvc_check -> cvc_verification
    -- dynamic_last_4 -> dynamic_last4_digits
    -- exp_month -> expiration_month
    -- exp_year -> expiration_year
    -- fingerprint -> card_fingerprint
    -- funding -> funding_type
    -- last_4 -> last4_digits
    -- name -> cardholder_name
    -- network -> payment_network
    -- recipient -> recipient_info
    SELECT 
        "id" AS "payment_method_id",
        "account_id",
        "address_city" AS "billing_city",
        "address_country" AS "billing_country",
        "address_line_1" AS "billing_address_line1",
        "address_line_1_check" AS "address_line1_verification",
        "address_line_2" AS "billing_address_line2",
        "address_state" AS "billing_state",
        "address_zip" AS "billing_zip",
        "address_zip_check" AS "zip_verification",
        "brand" AS "card_brand",
        "connected_account_id",
        "country" AS "issuing_country",
        "created" AS "creation_datetime",
        "currency",
        "customer_id",
        "cvc_check" AS "cvc_verification",
        "dynamic_last_4" AS "dynamic_last4_digits",
        "exp_month" AS "expiration_month",
        "exp_year" AS "expiration_year",
        "fingerprint" AS "card_fingerprint",
        "funding" AS "funding_type",
        "is_deleted",
        "last_4" AS "last4_digits",
        "name" AS "cardholder_name",
        "network" AS "payment_network",
        "recipient" AS "recipient_info",
        "tokenization_method",
        "metadata"
    FROM "card_data_projected"
),

"card_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- card_brand: The problem is that the card_brand column contains a value that appears to be a hash or encrypted string ('553f65f270c86a4a05c964dc20e8cc70') instead of an actual card brand name. This is unusual because card brands are typically recognizable names like Visa, Mastercard, American Express, etc. The hash-like value doesn't provide any meaningful information about the card brand. Since we don't have enough information to determine the actual card brand, and the current value is not useful, the most appropriate action is to map this unusual value to an empty string. 
    -- metadata: The problem is that there are empty JSON objects ('{}') in the metadata column, which are inconsistent with the other entries. The correct values should all follow the pattern of having an "external_id" key with a string value. The empty JSON objects are likely placeholder entries or errors that should be corrected. 
    SELECT
        "payment_method_id",
        "account_id",
        "billing_city",
        "billing_country",
        "billing_address_line1",
        "address_line1_verification",
        "billing_address_line2",
        "billing_state",
        "billing_zip",
        "zip_verification",
        CASE
            WHEN "card_brand" = '''553f65f270c86a4a05c964dc20e8cc70''' THEN ''''
            ELSE "card_brand"
        END AS "card_brand",
        "connected_account_id",
        "issuing_country",
        "creation_datetime",
        "currency",
        "customer_id",
        "cvc_verification",
        "dynamic_last4_digits",
        "expiration_month",
        "expiration_year",
        "card_fingerprint",
        "funding_type",
        "is_deleted",
        "last4_digits",
        "cardholder_name",
        "payment_network",
        "recipient_info",
        "tokenization_method",
        CASE
            WHEN "metadata" = '''{}''' THEN '{"external_id":""}'
            ELSE "metadata"
        END AS "metadata"
    FROM "card_data_projected_renamed"
),

"card_data_projected_renamed_cleaned_null" AS (
    -- NULL Imputation: Impute Null to Disguised Missing Values
    -- metadata: ['{}']
    SELECT 
        CASE
            WHEN "metadata" = '{}' THEN NULL
            ELSE "metadata"
        END AS "metadata",
        "issuing_country",
        "billing_city",
        "expiration_year",
        "currency",
        "last4_digits",
        "payment_method_id",
        "address_line1_verification",
        "tokenization_method",
        "customer_id",
        "expiration_month",
        "billing_address_line1",
        "payment_network",
        "funding_type",
        "connected_account_id",
        "recipient_info",
        "dynamic_last4_digits",
        "zip_verification",
        "billing_zip",
        "creation_datetime",
        "account_id",
        "billing_address_line2",
        "cardholder_name",
        "billing_country",
        "card_brand",
        "is_deleted",
        "cvc_verification",
        "billing_state",
        "card_fingerprint"
    FROM "card_data_projected_renamed_cleaned"
),

"card_data_projected_renamed_cleaned_null_casted" AS (
    -- Column Type Casting: 
    -- account_id: from DECIMAL to VARCHAR
    -- address_line1_verification: from DECIMAL to VARCHAR
    -- billing_address_line1: from DECIMAL to VARCHAR
    -- billing_address_line2: from DECIMAL to VARCHAR
    -- billing_city: from DECIMAL to VARCHAR
    -- billing_country: from DECIMAL to VARCHAR
    -- billing_state: from DECIMAL to VARCHAR
    -- billing_zip: from DECIMAL to VARCHAR
    -- cardholder_name: from DECIMAL to VARCHAR
    -- connected_account_id: from DECIMAL to VARCHAR
    -- creation_datetime: from VARCHAR to TIMESTAMP
    -- customer_id: from DECIMAL to VARCHAR
    -- dynamic_last4_digits: from DECIMAL to VARCHAR
    -- last4_digits: from INT to VARCHAR
    -- metadata: from VARCHAR to JSON
    -- recipient_info: from DECIMAL to VARCHAR
    -- tokenization_method: from DECIMAL to VARCHAR
    -- zip_verification: from DECIMAL to VARCHAR
    SELECT
        "issuing_country",
        "expiration_year",
        "currency",
        "payment_method_id",
        "expiration_month",
        "payment_network",
        "funding_type",
        "card_brand",
        "is_deleted",
        "cvc_verification",
        "card_fingerprint",
        CAST("account_id" AS VARCHAR) AS "account_id",
        CAST("address_line1_verification" AS VARCHAR) AS "address_line1_verification",
        CAST("billing_address_line1" AS VARCHAR) AS "billing_address_line1",
        CAST("billing_address_line2" AS VARCHAR) AS "billing_address_line2",
        CAST("billing_city" AS VARCHAR) AS "billing_city",
        CAST("billing_country" AS VARCHAR) AS "billing_country",
        CAST("billing_state" AS VARCHAR) AS "billing_state",
        CAST("billing_zip" AS VARCHAR) AS "billing_zip",
        CAST("cardholder_name" AS VARCHAR) AS "cardholder_name",
        CAST("connected_account_id" AS VARCHAR) AS "connected_account_id",
        CAST("creation_datetime" AS TIMESTAMP) AS "creation_datetime",
        CAST("customer_id" AS VARCHAR) AS "customer_id",
        CAST("dynamic_last4_digits" AS VARCHAR) AS "dynamic_last4_digits",
        CAST("last4_digits" AS VARCHAR) AS "last4_digits",
        CAST("metadata" AS JSON) AS "metadata",
        CAST("recipient_info" AS VARCHAR) AS "recipient_info",
        CAST("tokenization_method" AS VARCHAR) AS "tokenization_method",
        CAST("zip_verification" AS VARCHAR) AS "zip_verification"
    FROM "card_data_projected_renamed_cleaned_null"
),

"card_data_projected_renamed_cleaned_null_casted_missing_handled" AS (
    -- Handling missing values: There are 15 columns with unacceptable missing values
    -- account_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- address_line1_verification has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- billing_address_line1 has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- billing_address_line2 has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- billing_city has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- billing_country has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- billing_state has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- billing_zip has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- cardholder_name has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- connected_account_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- customer_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- dynamic_last4_digits has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- recipient_info has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tokenization_method has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- zip_verification has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "issuing_country",
        "expiration_year",
        "currency",
        "payment_method_id",
        "expiration_month",
        "payment_network",
        "funding_type",
        "card_brand",
        "is_deleted",
        "cvc_verification",
        "card_fingerprint",
        "creation_datetime",
        "last4_digits",
        "metadata"
    FROM "card_data_projected_renamed_cleaned_null_casted"
)

-- COCOON BLOCK END
SELECT * FROM "card_data_projected_renamed_cleaned_null_casted_missing_handled"

stg_card_data.yml (Document the table)

version: 2
models:
- name: stg_card_data
  description: The table is about payment methods. It contains details such as card
    ID, brand, country, currency, expiration date, last 4 digits, funding type, and
    creation date. Each row represents a unique payment method with its associated
    attributes. The table includes metadata and checks for address and CVC. Most fields
    are related to card information and payment processing details.
  columns:
  - name: issuing_country
    description: Country where the payment method was issued
    tests:
    - not_null
  - name: expiration_year
    description: Expiration year of the payment card
    tests:
    - not_null
  - name: currency
    description: Currency associated with the payment method
    tests:
    - not_null
  - name: payment_method_id
    description: Unique identifier for the payment method
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each payment method.
        For this table, each row represents a distinct payment method, and the payment_method_id
        appears to be unique across rows.
  - name: expiration_month
    description: Expiration month of the payment card
    tests:
    - not_null
  - name: payment_network
    description: Payment network processing the transaction
    tests:
    - not_null
    - accepted_values:
        values:
        - Visa
        - Mastercard
        - American Express
        - Discover
        - JCB
        - UnionPay
        - Diners Club
        - PayPal
        - Stripe
        - Square
        - Alipay
        - WeChat Pay
        - Apple Pay
        - Google Pay
        - Samsung Pay
        - Interac
        - Klarna
        - Affirm
        - Afterpay
        - Venmo
        - 553f65f270c86a4a05c964dc20e8cc70
  - name: funding_type
    description: Funding type of the payment method (e.g., credit, debit)
    tests:
    - not_null
    - accepted_values:
        values:
        - credit
        - debit
        - prepaid
        - gift card
        - bank transfer
        - cash
        - check
        - cryptocurrency
        - mobile payment
        - wire transfer
        - loyalty points
        - store credit
  - name: card_brand
    description: Brand or network of the payment card
    tests:
    - not_null
    - accepted_values:
        values:
        - Visa
        - Mastercard
        - American Express
        - Discover
        - JCB
        - Diners Club
        - UnionPay
        - Maestro
        - Visa Electron
        - China T-Union
        - RuPay
        - InterPayment
        - InstaPayment
        - UATP
        - Dankort
        - Mir
        - Troy
        - Elo
        - Hipercard
        - BC Card
        - 553f65f270c86a4a05c964dc20e8cc70
  - name: is_deleted
    description: Indicates if the payment method has been deleted
    tests:
    - not_null
  - name: cvc_verification
    description: Status of the Card Verification Code check
    tests:
    - not_null
    - accepted_values:
        values:
        - pass
        - fail
        - not_checked
  - name: card_fingerprint
    description: Unique identifier for the card number
    tests:
    - not_null
  - name: creation_datetime
    description: Date and time when the payment method was created
    tests:
    - not_null
  - name: last4_digits
    description: Last 4 digits of the payment card number
    tests:
    - not_null
  - name: metadata
    description: Additional information stored as key-value pairs
    cocoon_meta:
      missing_acceptable: Optional field for additional information, may not be needed.

stg_invoice_line_item_data (first 100 rows)

line_item_id subscription_item_id alternate_item_id invoice_id quantity is_live_mode currency subscription_id plan_id is_prorated description is_discountable amount billing_period_end billing_period_start line_item_type metadata
0 ad1111 sdm99 gg665 ab1111 5 True usd sg888 sg555 True description_here False 21.0 2021-02-19 14:16:37 2021-02-18 14:16:37 None None
1 ba222 sdgjk5489 dsgjnik978 bd665 4 True usd dfs8645 sdgf5575 False description_here True 65.0 2021-02-19 14:16:37 2021-02-18 14:16:37 None {"external_id":"1111111-2222-3333-4444-55555555"}

stg_invoice_line_item_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"invoice_line_item_data_projected" AS (
    -- Projection: Selecting 17 out of 18 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "invoice_id",
        "amount",
        "currency",
        "description",
        "discountable",
        "livemode",
        "period_end",
        "period_start",
        "plan_id",
        "proration",
        "quantity",
        "subscription_id",
        "subscription_item_id",
        "type",
        "unique_id",
        "metadata"
    FROM "invoice_line_item_data"
),

"invoice_line_item_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> line_item_id
    -- discountable -> is_discountable
    -- livemode -> is_live_mode
    -- period_end -> billing_period_end
    -- period_start -> billing_period_start
    -- proration -> is_prorated
    -- type -> line_item_type
    -- unique_id -> alternate_item_id
    SELECT 
        "id" AS "line_item_id",
        "invoice_id",
        "amount",
        "currency",
        "description",
        "discountable" AS "is_discountable",
        "livemode" AS "is_live_mode",
        "period_end" AS "billing_period_end",
        "period_start" AS "billing_period_start",
        "plan_id",
        "proration" AS "is_prorated",
        "quantity",
        "subscription_id",
        "subscription_item_id",
        "type" AS "line_item_type",
        "unique_id" AS "alternate_item_id",
        "metadata"
    FROM "invoice_line_item_data_projected"
),

"invoice_line_item_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- description: The problem is that 'description_here' is a placeholder value and not actual descriptive content. It appears to be the only value present in the description column, which suggests that real descriptions are missing. The correct values should be actual, meaningful descriptions of the items or entities being described. However, since we don't have access to the real descriptions, we can't provide them. 
    SELECT
        "line_item_id",
        "invoice_id",
        "amount",
        "currency",
        CASE
            WHEN "description" = '''description_here''' THEN ''''
            ELSE "description"
        END AS "description",
        "is_discountable",
        "is_live_mode",
        "billing_period_end",
        "billing_period_start",
        "plan_id",
        "is_prorated",
        "quantity",
        "subscription_id",
        "subscription_item_id",
        "line_item_type",
        "alternate_item_id",
        "metadata"
    FROM "invoice_line_item_data_projected_renamed"
),

"invoice_line_item_data_projected_renamed_cleaned_null" AS (
    -- NULL Imputation: Impute Null to Disguised Missing Values
    -- metadata: ['{}']
    SELECT 
        CASE
            WHEN "metadata" = '{}' THEN NULL
            ELSE "metadata"
        END AS "metadata",
        "line_item_type",
        "line_item_id",
        "subscription_item_id",
        "alternate_item_id",
        "invoice_id",
        "quantity",
        "is_live_mode",
        "amount",
        "currency",
        "billing_period_end",
        "billing_period_start",
        "subscription_id",
        "plan_id",
        "is_prorated",
        "description",
        "is_discountable"
    FROM "invoice_line_item_data_projected_renamed_cleaned"
),

"invoice_line_item_data_projected_renamed_cleaned_null_casted" AS (
    -- Column Type Casting: 
    -- amount: from INT to DECIMAL
    -- billing_period_end: from VARCHAR to TIMESTAMP
    -- billing_period_start: from VARCHAR to TIMESTAMP
    -- line_item_type: from DECIMAL to VARCHAR
    -- metadata: from VARCHAR to JSON
    SELECT
        "line_item_id",
        "subscription_item_id",
        "alternate_item_id",
        "invoice_id",
        "quantity",
        "is_live_mode",
        "currency",
        "subscription_id",
        "plan_id",
        "is_prorated",
        "description",
        "is_discountable",
        CAST("amount" AS DECIMAL) AS "amount",
        CAST("billing_period_end" AS TIMESTAMP) AS "billing_period_end",
        CAST("billing_period_start" AS TIMESTAMP) AS "billing_period_start",
        CAST("line_item_type" AS VARCHAR) AS "line_item_type",
        CAST("metadata" AS JSON) AS "metadata"
    FROM "invoice_line_item_data_projected_renamed_cleaned_null"
)

-- COCOON BLOCK END
SELECT * FROM "invoice_line_item_data_projected_renamed_cleaned_null_casted"

stg_invoice_line_item_data.yml (Document the table)

version: 2
models:
- name: stg_invoice_line_item_data
  description: The table is about invoice line items. It contains details such as
    the amount, currency, description, and time period for each item. It also includes
    information about associated plans, subscriptions, and discounts. The table stores
    metadata and unique identifiers for each line item. This data likely represents
    individual charges or services on a customer's invoice.
  columns:
  - name: line_item_id
    description: Unique identifier for the line item
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each line item on
        an invoice. For this table, each row is a separate line item, and the line_item_id
        should be unique across rows.
  - name: subscription_item_id
    description: ID of the specific subscription item
    tests:
    - not_null
  - name: alternate_item_id
    description: Another unique identifier for the item
    tests:
    - not_null
  - name: invoice_id
    description: ID of the associated invoice
    tests:
    - not_null
  - name: quantity
    description: Number of units for the line item
    tests:
    - not_null
  - name: is_live_mode
    description: Indicates if the item is in live mode
    tests:
    - not_null
  - name: currency
    description: Currency code for the amount
    tests:
    - not_null
  - name: subscription_id
    description: ID of the associated subscription
    tests:
    - not_null
  - name: plan_id
    description: ID of the associated plan
    tests:
    - not_null
  - name: is_prorated
    description: Indicates if the item is prorated
    tests:
    - not_null
  - name: description
    description: Brief description of the line item
    tests:
    - not_null
  - name: is_discountable
    description: Whether the item is eligible for discounts
    tests:
    - not_null
  - name: amount
    description: Monetary value of the line item
    tests:
    - not_null
  - name: billing_period_end
    description: End date of the billing period
    tests:
    - not_null
  - name: billing_period_start
    description: Start date of the billing period
    tests:
    - not_null
  - name: line_item_type
    description: Type of the line item
    cocoon_meta:
      missing_acceptable: May not be applicable for all types of transactions.
  - name: metadata
    description: Additional custom data in JSON format
    tests:
    - not_null

stg_payment_intent_data (first 100 rows)

payment_intent_id amount_in_cents amount_capturable amount_received application capture_method confirmation_method currency_code customer_id description is_live payment_method_id receipt_email status canceled_at cancellation_reason created_at decline_code error_charge_id error_code error_doc_url error_message error_param error_source_id error_type
0 pi_0IEpzwig6peNXzgDxFY8plfJ 67845 0 67845 None automatic automatic usd cus_I0JJf8lbCaJBZS f1df1d3d813e93b0093ada118723aa23 True pm_0IEij1ig6peNXzgDQeigpAeH None succeeded 2021-02-12 02:21:07 None 2021-01-29 05:58:24 None None None None None None None None
1 pi_0IEq0wig6peNXzgD0BPTgrg3 14154 0 14154 None automatic automatic usd cus_I0JJf8lbCaJBZS f1df1d3d813e93b0093ada118723aa23 True pm_0IEij1ig6peNXzgDQeigpAeH None succeeded 2021-02-12 02:21:07 None 2021-01-29 05:59:26 None None None None None None None None
2 pi_0IEq1qig6peNXzgDlfK6CSfM 11976 0 11976 None automatic automatic usd cus_I0JJf8lbCaJBZS f1df1d3d813e93b0093ada118723aa23 True pm_0IEij1ig6peNXzgDQeigpAeH None succeeded 2021-02-12 02:21:07 None 2021-01-29 06:00:22 None None None None None None None None
3 pi_0IJbnkig6peNXzgD0yXQHZac 60000 0 60000 None automatic automatic usd cus_IrzdXtpzmRAOIT f1df1d3d813e93b0093ada118723aa23 True pm_0IGFjsig6peNXzgDBI2hCfL5 None succeeded 2021-02-12 02:21:07 None 2021-02-11 09:49:32 None None None None None None None None
4 pi_0IJboeig6peNXzgD2wQr6zRO 32300 0 32300 None automatic automatic usd cus_IrzdXtpzmRAOIT f1df1d3d813e93b0093ada118723aa23 True pm_0IGFjsig6peNXzgDBI2hCfL5 None succeeded 2021-02-12 02:21:07 None 2021-02-11 09:50:28 None None None None None None None None
5 pi_0IJbq9ig6peNXzgD66itql9S 2700 0 2700 None automatic automatic usd cus_IrzdXtpzmRAOIT f1df1d3d813e93b0093ada118723aa23 True pm_0IGFjsig6peNXzgDBI2hCfL5 None succeeded 2021-02-12 02:21:07 None 2021-02-11 09:52:01 None None None None None None None None
6 pi_0IJbpHig6peNXzgDIcI1DH9B 7600 0 7600 None automatic automatic usd cus_IrzdXtpzmRAOIT f1df1d3d813e93b0093ada118723aa23 True pm_0IGFjsig6peNXzgDBI2hCfL5 None succeeded 2021-02-12 02:21:07 None 2021-02-11 09:51:07 None None None None None None None None
7 pi_0IB5RYig6peNXzgDaRjzw1rZ 190800 0 190800 ca_8Spi8Y6vQsJEmSegXeWoWPihihlqB3kC automatic automatic usd None c76e09d8a163526a171f372fce170129 True pm_0IB5RYig6peNXzgDEpJNTma5 222a0f40559271ab98c3046c9d03f2da succeeded 2021-02-12 02:21:07 None 2021-01-18 21:39:24 None None None None None None None None
8 pi_0IB5SCig6peNXzgDsyG4fPpk 148500 0 148500 ca_8Spi8Y6vQsJEmSegXeWoWPihihlqB3kC automatic automatic usd None c76e09d8a163526a171f372fce170129 True pm_0IB5SCig6peNXzgDnoOeWOM2 222a0f40559271ab98c3046c9d03f2da succeeded 2021-02-12 02:21:07 None 2021-01-18 21:40:04 None None None None None None None None
9 pi_0IBJOjig6peNXzgDfdxPzsoh 2550000 0 2550000 ca_8Spi8Y6vQsJEmSegXeWoWPihihlqB3kC automatic automatic usd None c76e09d8a163526a171f372fce170129 True pm_0IBJOjig6peNXzgDrwox8suf 1d256ae8550cb70df1cf19978c900874 succeeded 2021-02-12 02:21:07 None 2021-01-19 12:33:25 None None None None None None None None
10 pi_0IBm5Xig6peNXzgDfbem16Ks 875000 0 875000 ca_8Spi8Y6vQsJEmSegXeWoWPihihlqB3kC automatic automatic usd None c76e09d8a163526a171f372fce170129 True pm_0IBm5Xig6peNXzgDkUtpXzZT a665a3fbf734bdacfa4f6212f4ec2dcb succeeded 2021-02-12 02:21:07 None 2021-01-20 19:11:31 None None None None None None None None

stg_payment_intent_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"payment_intent_data_projected" AS (
    -- Projection: Selecting 31 out of 32 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "amount",
        "amount_capturable",
        "amount_received",
        "application",
        "application_fee_amount",
        "canceled_at",
        "cancellation_reason",
        "capture_method",
        "confirmation_method",
        "created",
        "currency",
        "customer_id",
        "description",
        "last_payment_error_charge_id",
        "last_payment_error_code",
        "last_payment_error_decline_code",
        "last_payment_error_doc_url",
        "last_payment_error_message",
        "last_payment_error_param",
        "last_payment_error_source_id",
        "last_payment_error_type",
        "livemode",
        "on_behalf_of",
        "payment_method_id",
        "receipt_email",
        "source_id",
        "statement_descriptor",
        "status",
        "transfer_data_destination",
        "transfer_group"
    FROM "payment_intent_data"
),

"payment_intent_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> payment_intent_id
    -- amount -> amount_in_cents
    -- created -> created_at
    -- currency -> currency_code
    -- last_payment_error_charge_id -> error_charge_id
    -- last_payment_error_code -> error_code
    -- last_payment_error_decline_code -> decline_code
    -- last_payment_error_doc_url -> error_doc_url
    -- last_payment_error_message -> error_message
    -- last_payment_error_param -> error_param
    -- last_payment_error_source_id -> error_source_id
    -- last_payment_error_type -> error_type
    -- livemode -> is_live
    -- transfer_data_destination -> transfer_destination
    SELECT 
        "id" AS "payment_intent_id",
        "amount" AS "amount_in_cents",
        "amount_capturable",
        "amount_received",
        "application",
        "application_fee_amount",
        "canceled_at",
        "cancellation_reason",
        "capture_method",
        "confirmation_method",
        "created" AS "created_at",
        "currency" AS "currency_code",
        "customer_id",
        "description",
        "last_payment_error_charge_id" AS "error_charge_id",
        "last_payment_error_code" AS "error_code",
        "last_payment_error_decline_code" AS "decline_code",
        "last_payment_error_doc_url" AS "error_doc_url",
        "last_payment_error_message" AS "error_message",
        "last_payment_error_param" AS "error_param",
        "last_payment_error_source_id" AS "error_source_id",
        "last_payment_error_type" AS "error_type",
        "livemode" AS "is_live",
        "on_behalf_of",
        "payment_method_id",
        "receipt_email",
        "source_id",
        "statement_descriptor",
        "status",
        "transfer_data_destination" AS "transfer_destination",
        "transfer_group"
    FROM "payment_intent_data_projected"
),

"payment_intent_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- application_fee_amount: from DECIMAL to VARCHAR
    -- canceled_at: from VARCHAR to TIMESTAMP
    -- cancellation_reason: from DECIMAL to VARCHAR
    -- created_at: from VARCHAR to TIMESTAMP
    -- decline_code: from DECIMAL to VARCHAR
    -- error_charge_id: from DECIMAL to VARCHAR
    -- error_code: from DECIMAL to VARCHAR
    -- error_doc_url: from DECIMAL to VARCHAR
    -- error_message: from DECIMAL to VARCHAR
    -- error_param: from DECIMAL to VARCHAR
    -- error_source_id: from DECIMAL to VARCHAR
    -- error_type: from DECIMAL to VARCHAR
    -- on_behalf_of: from DECIMAL to VARCHAR
    -- source_id: from DECIMAL to VARCHAR
    -- statement_descriptor: from DECIMAL to VARCHAR
    -- transfer_destination: from DECIMAL to VARCHAR
    -- transfer_group: from DECIMAL to VARCHAR
    SELECT
        "payment_intent_id",
        "amount_in_cents",
        "amount_capturable",
        "amount_received",
        "application",
        "capture_method",
        "confirmation_method",
        "currency_code",
        "customer_id",
        "description",
        "is_live",
        "payment_method_id",
        "receipt_email",
        "status",
        CAST("application_fee_amount" AS VARCHAR) AS "application_fee_amount",
        CAST("canceled_at" AS TIMESTAMP) AS "canceled_at",
        CAST("cancellation_reason" AS VARCHAR) AS "cancellation_reason",
        CAST("created_at" AS TIMESTAMP) AS "created_at",
        CAST("decline_code" AS VARCHAR) AS "decline_code",
        CAST("error_charge_id" AS VARCHAR) AS "error_charge_id",
        CAST("error_code" AS VARCHAR) AS "error_code",
        CAST("error_doc_url" AS VARCHAR) AS "error_doc_url",
        CAST("error_message" AS VARCHAR) AS "error_message",
        CAST("error_param" AS VARCHAR) AS "error_param",
        CAST("error_source_id" AS VARCHAR) AS "error_source_id",
        CAST("error_type" AS VARCHAR) AS "error_type",
        CAST("on_behalf_of" AS VARCHAR) AS "on_behalf_of",
        CAST("source_id" AS VARCHAR) AS "source_id",
        CAST("statement_descriptor" AS VARCHAR) AS "statement_descriptor",
        CAST("transfer_destination" AS VARCHAR) AS "transfer_destination",
        CAST("transfer_group" AS VARCHAR) AS "transfer_group"
    FROM "payment_intent_data_projected_renamed"
),

"payment_intent_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 9 columns with unacceptable missing values
    -- application has 63.64 percent missing. Strategy: 🔄 Unchanged
    -- application_fee_amount has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- customer_id has 36.36 percent missing. Strategy: 🔄 Unchanged
    -- on_behalf_of has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- receipt_email has 63.64 percent missing. Strategy: 🔄 Unchanged
    -- source_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- statement_descriptor has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- transfer_destination has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- transfer_group has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "payment_intent_id",
        "amount_in_cents",
        "amount_capturable",
        "amount_received",
        "application",
        "capture_method",
        "confirmation_method",
        "currency_code",
        "customer_id",
        "description",
        "is_live",
        "payment_method_id",
        "receipt_email",
        "status",
        "canceled_at",
        "cancellation_reason",
        "created_at",
        "decline_code",
        "error_charge_id",
        "error_code",
        "error_doc_url",
        "error_message",
        "error_param",
        "error_source_id",
        "error_type"
    FROM "payment_intent_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "payment_intent_data_projected_renamed_casted_missing_handled"

stg_payment_intent_data.yml (Document the table)

version: 2
models:
- name: stg_payment_intent_data
  description: The table is about payment intents. It includes details such as amount,
    currency, customer ID, payment method ID, and status. Each row represents a single
    payment intent with a unique ID. The table tracks information like creation date,
    capture method, and whether the payment succeeded. It also includes fields for
    errors and cancellations, though most are empty in these samples.
  columns:
  - name: payment_intent_id
    description: Unique identifier for the payment intent
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each payment intent.
        For this table, each row is for a single payment intent, and payment_intent_id
        is unique across rows.
  - name: amount_in_cents
    description: Payment amount in the smallest currency unit
    tests:
    - not_null
  - name: amount_capturable
    description: Amount available for capture
    tests:
    - not_null
  - name: amount_received
    description: Amount actually received
    tests:
    - not_null
  - name: application
    description: Associated application for the payment
    tests:
    - not_null
  - name: capture_method
    description: Method used to capture payment
    tests:
    - not_null
    - accepted_values:
        values:
        - automatic
        - manual
        - card
        - bank_transfer
        - cash
        - check
        - paypal
        - apple_pay
        - google_pay
        - cryptocurrency
        - wire_transfer
        - direct_debit
        - invoice
  - name: confirmation_method
    description: Method used to confirm payment
    tests:
    - not_null
    - accepted_values:
        values:
        - automatic
        - manual
        - email
        - sms
        - phone call
        - in-app notification
        - bank statement
        - receipt
        - invoice
        - credit card statement
        - payment gateway confirmation
        - third-party verification
  - name: currency_code
    description: Currency code for the payment
    tests:
    - not_null
  - name: customer_id
    description: Unique identifier for the customer
    tests:
    - not_null
  - name: description
    description: Description of the payment intent
    tests:
    - not_null
  - name: is_live
    description: Whether the payment is live or test
    tests:
    - not_null
  - name: payment_method_id
    description: ID of the payment method used
    tests:
    - not_null
  - name: receipt_email
    description: Email address for receipt
    tests:
    - not_null
  - name: status
    description: Current status of the payment intent
    tests:
    - not_null
    - accepted_values:
        values:
        - succeeded
        - processing
        - requires_payment_method
        - requires_confirmation
        - requires_action
        - canceled
        - requires_capture
  - name: canceled_at
    description: Timestamp of cancellation
    tests:
    - not_null
  - name: cancellation_reason
    description: Reason for cancellation if applicable
    cocoon_meta:
      missing_acceptable: Not applicable for transactions that weren't cancelled.
  - name: created_at
    description: Timestamp of payment intent creation
    tests:
    - not_null
  - name: decline_code
    description: Decline code if payment was declined
    cocoon_meta:
      missing_acceptable: Not applicable for successful transactions.
  - name: error_charge_id
    description: ID of charge with last error
    cocoon_meta:
      missing_acceptable: Not applicable for transactions without errors.
  - name: error_code
    description: Error code of last failed attempt
    cocoon_meta:
      missing_acceptable: Not applicable for transactions without errors.
  - name: error_doc_url
    description: URL to error documentation
    cocoon_meta:
      missing_acceptable: Not applicable for transactions without errors.
  - name: error_message
    description: Error message for last failed attempt
    cocoon_meta:
      missing_acceptable: Not applicable for transactions without errors.
  - name: error_param
    description: Parameter that caused the error
    cocoon_meta:
      missing_acceptable: Not applicable for transactions without errors.
  - name: error_source_id
    description: ID of source causing the error
    cocoon_meta:
      missing_acceptable: Not applicable for transactions without errors.
  - name: error_type
    description: Type of the last error
    cocoon_meta:
      missing_acceptable: Not applicable for transactions without errors.

stg_subscription_history_data (first 100 rows)

subscription_id is_active billing_method billing_threshold reset_billing_cycle_on_threshold cancel_at_period_end customer_id payment_due_days default_payment_source_id is_live_mode subscription_quantity subscription_status app_fee_percentage billing_cycle_start cancellation_date creation_date current_period_end current_period_start end_date metadata scheduled_cancellation_date start_date tax_percentage trial_end_date trial_start_date
0 sdgfs4536 True fdfjk 9 False True sdf6547 4 dfa543 True 4 active 5.0 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 2021-02-19 14:16:37 2021-02-18 14:16:37 5.0 2021-02-19 14:16:37 2021-02-18 14:16:37
1 sfjytkyu876 False fdsiew 5 False True 123fsdf 5 764rhgf True 5 active 6.0 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 2021-02-19 14:16:37 2021-02-18 14:16:37 6.0 2021-02-19 14:16:37 2021-02-18 14:16:37

stg_subscription_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"subscription_history_data_projected" AS (
    -- Projection: Selecting 25 out of 26 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "_fivetran_active",
        "application_fee_percent",
        "billing",
        "billing_cycle_anchor",
        "billing_threshold_amount_gte",
        "billing_threshold_reset_billing_cycle_anchor",
        "cancel_at",
        "cancel_at_period_end",
        "canceled_at",
        "created",
        "current_period_end",
        "current_period_start",
        "customer_id",
        "days_until_due",
        "default_source_id",
        "ended_at",
        "livemode",
        "metadata",
        "quantity",
        "start_date",
        "status",
        "tax_percent",
        "trial_end",
        "trial_start"
    FROM "subscription_history_data"
),

"subscription_history_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> subscription_id
    -- _fivetran_active -> is_active
    -- application_fee_percent -> app_fee_percentage
    -- billing -> billing_method
    -- billing_cycle_anchor -> billing_cycle_start
    -- billing_threshold_amount_gte -> billing_threshold
    -- billing_threshold_reset_billing_cycle_anchor -> reset_billing_cycle_on_threshold
    -- cancel_at -> scheduled_cancellation_date
    -- canceled_at -> cancellation_date
    -- created -> creation_date
    -- days_until_due -> payment_due_days
    -- default_source_id -> default_payment_source_id
    -- ended_at -> end_date
    -- livemode -> is_live_mode
    -- quantity -> subscription_quantity
    -- status -> subscription_status
    -- tax_percent -> tax_percentage
    -- trial_end -> trial_end_date
    -- trial_start -> trial_start_date
    SELECT 
        "id" AS "subscription_id",
        "_fivetran_active" AS "is_active",
        "application_fee_percent" AS "app_fee_percentage",
        "billing" AS "billing_method",
        "billing_cycle_anchor" AS "billing_cycle_start",
        "billing_threshold_amount_gte" AS "billing_threshold",
        "billing_threshold_reset_billing_cycle_anchor" AS "reset_billing_cycle_on_threshold",
        "cancel_at" AS "scheduled_cancellation_date",
        "cancel_at_period_end",
        "canceled_at" AS "cancellation_date",
        "created" AS "creation_date",
        "current_period_end",
        "current_period_start",
        "customer_id",
        "days_until_due" AS "payment_due_days",
        "default_source_id" AS "default_payment_source_id",
        "ended_at" AS "end_date",
        "livemode" AS "is_live_mode",
        "metadata",
        "quantity" AS "subscription_quantity",
        "start_date",
        "status" AS "subscription_status",
        "tax_percent" AS "tax_percentage",
        "trial_end" AS "trial_end_date",
        "trial_start" AS "trial_start_date"
    FROM "subscription_history_data_projected"
),

"subscription_history_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- billing_method: The problem is that both values 'fdfjk' and 'fdsiew' in the billing_method column are meaningless strings that do not represent valid billing methods. These appear to be random character combinations with no discernible meaning or pattern. The correct values for a billing method column should be actual payment methods like 'credit card', 'debit card', 'PayPal', 'bank transfer', etc. Since we don't have information about the correct billing methods, we'll map these meaningless strings to an empty string. 
    SELECT
        "subscription_id",
        "is_active",
        "app_fee_percentage",
        CASE
            WHEN "billing_method" = '''fdfjk''' THEN ''''
            WHEN "billing_method" = '''fdsiew''' THEN ''''
            ELSE "billing_method"
        END AS "billing_method",
        "billing_cycle_start",
        "billing_threshold",
        "reset_billing_cycle_on_threshold",
        "scheduled_cancellation_date",
        "cancel_at_period_end",
        "cancellation_date",
        "creation_date",
        "current_period_end",
        "current_period_start",
        "customer_id",
        "payment_due_days",
        "default_payment_source_id",
        "end_date",
        "is_live_mode",
        "metadata",
        "subscription_quantity",
        "start_date",
        "subscription_status",
        "tax_percentage",
        "trial_end_date",
        "trial_start_date"
    FROM "subscription_history_data_projected_renamed"
),

"subscription_history_data_projected_renamed_cleaned_casted" AS (
    -- Column Type Casting: 
    -- app_fee_percentage: from INT to DECIMAL
    -- billing_cycle_start: from VARCHAR to TIMESTAMP
    -- cancellation_date: from VARCHAR to TIMESTAMP
    -- creation_date: from VARCHAR to TIMESTAMP
    -- current_period_end: from VARCHAR to TIMESTAMP
    -- current_period_start: from VARCHAR to TIMESTAMP
    -- end_date: from VARCHAR to TIMESTAMP
    -- metadata: from VARCHAR to JSON
    -- scheduled_cancellation_date: from VARCHAR to TIMESTAMP
    -- start_date: from VARCHAR to TIMESTAMP
    -- tax_percentage: from INT to DECIMAL
    -- trial_end_date: from VARCHAR to TIMESTAMP
    -- trial_start_date: from VARCHAR to TIMESTAMP
    SELECT
        "subscription_id",
        "is_active",
        "billing_method",
        "billing_threshold",
        "reset_billing_cycle_on_threshold",
        "cancel_at_period_end",
        "customer_id",
        "payment_due_days",
        "default_payment_source_id",
        "is_live_mode",
        "subscription_quantity",
        "subscription_status",
        CAST("app_fee_percentage" AS DECIMAL) AS "app_fee_percentage",
        CAST("billing_cycle_start" AS TIMESTAMP) AS "billing_cycle_start",
        CAST("cancellation_date" AS TIMESTAMP) AS "cancellation_date",
        CAST("creation_date" AS TIMESTAMP) AS "creation_date",
        CAST("current_period_end" AS TIMESTAMP) AS "current_period_end",
        CAST("current_period_start" AS TIMESTAMP) AS "current_period_start",
        CAST("end_date" AS TIMESTAMP) AS "end_date",
        CAST("metadata" AS JSON) AS "metadata",
        CAST("scheduled_cancellation_date" AS TIMESTAMP) AS "scheduled_cancellation_date",
        CAST("start_date" AS TIMESTAMP) AS "start_date",
        CAST("tax_percentage" AS DECIMAL) AS "tax_percentage",
        CAST("trial_end_date" AS TIMESTAMP) AS "trial_end_date",
        CAST("trial_start_date" AS TIMESTAMP) AS "trial_start_date"
    FROM "subscription_history_data_projected_renamed_cleaned"
)

-- COCOON BLOCK END
SELECT * FROM "subscription_history_data_projected_renamed_cleaned_casted"

stg_subscription_history_data.yml (Document the table)

version: 2
models:
- name: stg_subscription_history_data
  description: The table is about subscription history. It contains details of individual
    subscriptions, including billing information, dates, status, and customer details.
    Each row represents a unique subscription with its ID, customer ID, billing cycle,
    trial period, cancellation details, and other relevant subscription attributes.
    The table tracks the lifecycle of subscriptions from creation to cancellation
    or expiration.
  columns:
  - name: subscription_id
    description: Unique identifier for the subscription
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each subscription.
        For this table, each row represents a unique subscription, and subscription_id
        is designed to be unique across rows.
  - name: is_active
    description: Indicates if the subscription is currently active
    tests:
    - not_null
  - name: billing_method
    description: Billing method or frequency
    tests:
    - not_null
    - accepted_values:
        values:
        - Monthly
        - Quarterly
        - Annually
        - Semi-annually
        - Weekly
        - Bi-weekly
        - Daily
        - One-time
        - Pay-per-use
        - Subscription
        - Installment
        - Prepaid
        - Postpaid
        - Metered
        - Flat rate
        - fdfjk
        - fdsiew
  - name: billing_threshold
    description: Minimum amount to trigger billing
    tests:
    - not_null
  - name: reset_billing_cycle_on_threshold
    description: Resets billing cycle anchor when threshold reached
    tests:
    - not_null
  - name: cancel_at_period_end
    description: Indicates if subscription cancels at period end
    tests:
    - not_null
  - name: customer_id
    description: Unique identifier for the customer
    tests:
    - not_null
  - name: payment_due_days
    description: Number of days until payment is due
    tests:
    - not_null
  - name: default_payment_source_id
    description: ID of default payment source
    tests:
    - not_null
  - name: is_live_mode
    description: Indicates if subscription is in live mode
    tests:
    - not_null
  - name: subscription_quantity
    description: Number of units in the subscription
    tests:
    - not_null
  - name: subscription_status
    description: Current status of the subscription
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
        - cancelled
        - expired
        - suspended
        - trialing
        - past_due
        - unpaid
        - on_hold
  - name: app_fee_percentage
    description: Percentage of the subscription fee taken as application fee
    tests:
    - not_null
  - name: billing_cycle_start
    description: Date that anchors the billing cycle
    tests:
    - not_null
  - name: cancellation_date
    description: Date when subscription was canceled
    tests:
    - not_null
  - name: creation_date
    description: Date when subscription was created
    tests:
    - not_null
  - name: current_period_end
    description: End date of current billing period
    tests:
    - not_null
  - name: current_period_start
    description: Start date of current billing period
    tests:
    - not_null
  - name: end_date
    description: Date when subscription ended
    tests:
    - not_null
  - name: metadata
    description: Additional information about the subscription
    tests:
    - not_null
  - name: scheduled_cancellation_date
    description: Date when subscription is set to cancel
    tests:
    - not_null
  - name: start_date
    description: Date when subscription started
    tests:
    - not_null
  - name: tax_percentage
    description: Percentage of tax applied to subscription
    tests:
    - not_null
  - name: trial_end_date
    description: End date of trial period
    tests:
    - not_null
  - name: trial_start_date
    description: Start date of trial period
    tests:
    - not_null

stg_payment_method_data (first 100 rows)

billing_postal_code payment_method_id billing_name payment_method_type customer_id billing_email is_live billing_address_1 billing_address_2 billing_city billing_country billing_state created_at
0 fbed5cdfc14c8acab8bfc6fc608b57f3 pm_0IT7ufig6peNXzgDtFEUcWQq 29074c94bcd7496666c2516bdb84464a card None 29074c94bcd7496666c2516bdb84464a True None None None None None 2021-03-09 15:56:01
1 61ee93b89af4fccf77f604ddbdbfc508 card_0IDuzgig6peNXzgDiedW46Fs 00b659ac6a3cdb5afc520be084f0810a card cus_IITpWhRKEpP8oQ None True None None None None None 2021-01-26 17:06:20
2 37a6259cc0c1dae299a7866489dff0bd card_0IC7trig6peNXzgDuVtbBvrq af5da2c2d7e449fe0cff743e114893d9 card cus_GrTE2lUSyzG85x None True None None None None None 2021-01-21 18:28:55
3 f55e51631ea375b777ec380d7d6804b8 card_GQxHpPyKWUVsRS 75b77af238c31ba9b1b89e29a3a81053 card cus_GQxHnIOOpXDmHp None True None None None None None 2021-03-06 17:46:13
4 8f84fb5cdc0dd814d6aeb4e78fc41845 card_0IHGUUig6peNXzgD2fQWkF2H 00e1c9acc02a44880a725c24482a2bb9 card cus_It2ZjcDAnrL4fN None True None None None None None 2021-02-04 22:39:58
5 94472fbf2a4233129e7eb05c77f3321e card_0IO6DQig6peNXzgDzSyyQxed 201636b0ecc8bf4962b2426d7b292c34 card cus_J06QWm1jiY7XUw None True None None None None None 2021-02-23 19:06:36
6 37a6259cc0c1dae299a7866489dff0bd card_0IO8mGig6peNXzgD05gU9Nea 564048e93b6096f5cb8db8ed73d3dcab card cus_J0940I34bEZxFW None True None None None None None 2021-02-23 21:50:44
7 489981404dd301a023c9f75abed505f3 card_HC20VgUIY5YKcR 845b3e75a0227dddd8e1f0e08c1c5aaf card cus_HC20s92vymipWS None True None None None None None 2021-02-05 17:22:10
8 44fdc5ad1a08aace32d53264bc95a4b7 card_0IK2uDig6peNXzgDYgtvZhx1 63b43b7208989dbc6450746a34160a0c card cus_IvujSQV90Rsk6P None True None None None None None 2021-02-12 14:46:01
9 65e512403849d438dc08889bf6461073 card_0IBT4Hig6peNXzgD2UDI98rg a665a3fbf734bdacfa4f6212f4ec2dcb card cus_In3AMjd2X4TLgj None True None None None None None 2021-01-19 22:52:57
10 4674554ec907d598a620d5b131a9f685 card_0IUBw6ig6peNXzgDLOJ0s9oJ ae369c63d0f28eb65c99d8dccd3e5e6b card cus_J6OjltyC6E9zos None True None None None None None 2021-03-12 14:25:54
11 4674554ec907d598a620d5b131a9f685 pm_0HWPPYig6peNXzgDYaytTYRk 6601a62d87cfb0d57bad7610e7d3db63 card None 6601a62d87cfb0d57bad7610e7d3db63 True None None None None None 2020-09-28 16:41:12
12 None pm_0I1Bvcig6peNXzgDj0JyN58m 6601a62d87cfb0d57bad7610e7d3db63 card None 6601a62d87cfb0d57bad7610e7d3db63 True None None None None None 2020-12-22 14:33:32

stg_payment_method_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"payment_method_data_projected" AS (
    -- Projection: Selecting 14 out of 15 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "billing_detail_address_city",
        "billing_detail_address_country",
        "billing_detail_address_line_1",
        "billing_detail_address_line_2",
        "billing_detail_address_postal_code",
        "billing_detail_address_state",
        "billing_detail_email",
        "billing_detail_name",
        "billing_detail_phone",
        "created",
        "customer_id",
        "livemode",
        "type"
    FROM "payment_method_data"
),

"payment_method_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> payment_method_id
    -- billing_detail_address_city -> billing_city
    -- billing_detail_address_country -> billing_country
    -- billing_detail_address_line_1 -> billing_address_1
    -- billing_detail_address_line_2 -> billing_address_2
    -- billing_detail_address_postal_code -> billing_postal_code
    -- billing_detail_address_state -> billing_state
    -- billing_detail_email -> billing_email
    -- billing_detail_name -> billing_name
    -- billing_detail_phone -> billing_phone
    -- created -> created_at
    -- livemode -> is_live
    -- type -> payment_method_type
    SELECT 
        "id" AS "payment_method_id",
        "billing_detail_address_city" AS "billing_city",
        "billing_detail_address_country" AS "billing_country",
        "billing_detail_address_line_1" AS "billing_address_1",
        "billing_detail_address_line_2" AS "billing_address_2",
        "billing_detail_address_postal_code" AS "billing_postal_code",
        "billing_detail_address_state" AS "billing_state",
        "billing_detail_email" AS "billing_email",
        "billing_detail_name" AS "billing_name",
        "billing_detail_phone" AS "billing_phone",
        "created" AS "created_at",
        "customer_id",
        "livemode" AS "is_live",
        "type" AS "payment_method_type"
    FROM "payment_method_data_projected"
),

"payment_method_data_projected_renamed_null" AS (
    -- NULL Imputation: Impute Null to Disguised Missing Values
    -- billing_postal_code: ['d41d8cd98f00b204e9800998ecf8427e']
    SELECT 
        CASE
            WHEN "billing_postal_code" = 'd41d8cd98f00b204e9800998ecf8427e' THEN NULL
            ELSE "billing_postal_code"
        END AS "billing_postal_code",
        "payment_method_id",
        "billing_name",
        "billing_address_2",
        "payment_method_type",
        "customer_id",
        "billing_city",
        "billing_address_1",
        "billing_country",
        "billing_email",
        "created_at",
        "billing_phone",
        "is_live",
        "billing_state"
    FROM "payment_method_data_projected_renamed"
),

"payment_method_data_projected_renamed_null_casted" AS (
    -- Column Type Casting: 
    -- billing_address_1: from DECIMAL to VARCHAR
    -- billing_address_2: from DECIMAL to VARCHAR
    -- billing_city: from DECIMAL to VARCHAR
    -- billing_country: from DECIMAL to VARCHAR
    -- billing_phone: from DECIMAL to VARCHAR
    -- billing_state: from DECIMAL to VARCHAR
    -- created_at: from VARCHAR to TIMESTAMP
    SELECT
        "billing_postal_code",
        "payment_method_id",
        "billing_name",
        "payment_method_type",
        "customer_id",
        "billing_email",
        "is_live",
        CAST("billing_address_1" AS VARCHAR) AS "billing_address_1",
        CAST("billing_address_2" AS VARCHAR) AS "billing_address_2",
        CAST("billing_city" AS VARCHAR) AS "billing_city",
        CAST("billing_country" AS VARCHAR) AS "billing_country",
        CAST("billing_phone" AS VARCHAR) AS "billing_phone",
        CAST("billing_state" AS VARCHAR) AS "billing_state",
        CAST("created_at" AS TIMESTAMP) AS "created_at"
    FROM "payment_method_data_projected_renamed_null"
),

"payment_method_data_projected_renamed_null_casted_missing_handled" AS (
    -- Handling missing values: There are 4 columns with unacceptable missing values
    -- billing_email has 76.92 percent missing. Strategy: 🔄 Unchanged
    -- billing_phone has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- billing_postal_code has 7.69 percent missing. Strategy: 🔄 Unchanged
    -- customer_id has 23.08 percent missing. Strategy: 🔄 Unchanged
    SELECT
        "billing_postal_code",
        "payment_method_id",
        "billing_name",
        "payment_method_type",
        "customer_id",
        "billing_email",
        "is_live",
        "billing_address_1",
        "billing_address_2",
        "billing_city",
        "billing_country",
        "billing_state",
        "created_at"
    FROM "payment_method_data_projected_renamed_null_casted"
)

-- COCOON BLOCK END
SELECT * FROM "payment_method_data_projected_renamed_null_casted_missing_handled"

stg_payment_method_data.yml (Document the table)

version: 2
models:
- name: stg_payment_method_data
  description: The table is about payment method data. It contains details like ID,
    billing information, customer ID, and payment type. Billing details include address,
    email, name, and phone, but most fields are empty or encrypted. All entries are
    for card payments in live mode. The table tracks payment methods associated with
    customers, including creation date and unique identifiers.
  columns:
  - name: billing_postal_code
    description: Postal code of the billing address (encrypted)
    tests:
    - not_null
  - name: payment_method_id
    description: Unique identifier for the payment method
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each payment method.
        For this table, each row represents a distinct payment method, and payment_method_id
        is unique across rows.
  - name: billing_name
    description: Name associated with the billing details (encrypted)
    tests:
    - not_null
  - name: payment_method_type
    description: Type of payment method (e.g., card)
    tests:
    - not_null
    - accepted_values:
        values:
        - card
        - cash
        - bank transfer
        - check
        - digital wallet
        - cryptocurrency
        - mobile payment
        - wire transfer
        - money order
        - debit card
        - credit card
        - prepaid card
        - ACH
        - PayPal
        - Venmo
        - Apple Pay
        - Google Pay
        - gift card
        - store credit
  - name: customer_id
    description: Unique identifier for the customer
    tests:
    - not_null
  - name: billing_email
    description: Email address for billing (encrypted)
    tests:
    - not_null
  - name: is_live
    description: Indicates if the payment method is in live mode
    tests:
    - not_null
  - name: billing_address_1
    description: First line of the billing address
    cocoon_meta:
      missing_acceptable: Not applicable for digital or non-shipped products/services.
  - name: billing_address_2
    description: Second line of the billing address
    cocoon_meta:
      missing_acceptable: Not applicable for digital or non-shipped products/services.
  - name: billing_city
    description: City of the billing address
    cocoon_meta:
      missing_acceptable: Not applicable for digital or non-shipped products/services.
  - name: billing_country
    description: Country of the billing address
    cocoon_meta:
      missing_acceptable: Not applicable for digital or non-shipped products/services.
  - name: billing_state
    description: State of the billing address
    cocoon_meta:
      missing_acceptable: Not applicable for digital or non-shipped products/services.
  - name: created_at
    description: Date and time the payment method was created
    tests:
    - not_null

stg_refund_data (first 100 rows)

refund_id refund_amount_cents balance_transaction_id charge_id currency refund_reason receipt_number refund_status failure_balance_transaction_id failure_reason metadata refund_created_at
0 re_0IMJuLig6peNXzgDSLN6dNzl 675000 txn_0IMJuMig6peNXzgD8geSKVTA ch_0IBft2ig6peNXzgDv3vdM6nM usd duplicate 5555-555 succeeded None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 2021-02-18 21:19:33
1 re_0INhCiig6peNXzgDWw7VVan8 13650 txn_0INhCiig6peNXzgDZSsC5kGs ch_0IMD9sig6peNXzgDoUawu0L1 usd requested_by_customer 5555-555 succeeded None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 2021-02-22 16:24:12
2 re_0IMKOqig6peNXzgDKcwfyQvJ 1541221 txn_0IMKOqig6peNXzgDwl0qbnLD ch_0IMDADig6peNXzgDLUgpgKRp usd requested_by_customer 5555-555 succeeded None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 2021-02-18 21:51:04
3 re_0ISmXVig6peNXzgDtw7Hev23 161550 txn_0ISmXVig6peNXzgDO3k6vo6d ch_0IMDKoig6peNXzgDec7KCChy usd requested_by_customer 5555-555 succeeded None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 2021-03-08 17:06:41

stg_refund_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"refund_data_projected" AS (
    -- Projection: Selecting 13 out of 14 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "amount",
        "balance_transaction_id",
        "charge_id",
        "created",
        "currency",
        "description",
        "failure_balance_transaction_id",
        "failure_reason",
        "metadata",
        "reason",
        "receipt_number",
        "status"
    FROM "refund_data"
),

"refund_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> refund_id
    -- amount -> refund_amount_cents
    -- created -> refund_created_at
    -- description -> refund_description
    -- reason -> refund_reason
    -- status -> refund_status
    SELECT 
        "id" AS "refund_id",
        "amount" AS "refund_amount_cents",
        "balance_transaction_id",
        "charge_id",
        "created" AS "refund_created_at",
        "currency",
        "description" AS "refund_description",
        "failure_balance_transaction_id",
        "failure_reason",
        "metadata",
        "reason" AS "refund_reason",
        "receipt_number",
        "status" AS "refund_status"
    FROM "refund_data_projected"
),

"refund_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- failure_balance_transaction_id: from DECIMAL to VARCHAR
    -- failure_reason: from DECIMAL to VARCHAR
    -- metadata: from VARCHAR to JSON
    -- refund_created_at: from VARCHAR to TIMESTAMP
    -- refund_description: from DECIMAL to VARCHAR
    SELECT
        "refund_id",
        "refund_amount_cents",
        "balance_transaction_id",
        "charge_id",
        "currency",
        "refund_reason",
        "receipt_number",
        "refund_status",
        CAST("failure_balance_transaction_id" AS VARCHAR) AS "failure_balance_transaction_id",
        CAST("failure_reason" AS VARCHAR) AS "failure_reason",
        CAST("metadata" AS JSON) AS "metadata",
        CAST("refund_created_at" AS TIMESTAMP) AS "refund_created_at",
        CAST("refund_description" AS VARCHAR) AS "refund_description"
    FROM "refund_data_projected_renamed"
),

"refund_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 1 columns with unacceptable missing values
    -- refund_description has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "refund_id",
        "refund_amount_cents",
        "balance_transaction_id",
        "charge_id",
        "currency",
        "refund_reason",
        "receipt_number",
        "refund_status",
        "failure_balance_transaction_id",
        "failure_reason",
        "metadata",
        "refund_created_at"
    FROM "refund_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "refund_data_projected_renamed_casted_missing_handled"

stg_refund_data.yml (Document the table)

version: 2
models:
- name: stg_refund_data
  description: The table is about refund data. It contains details of refund transactions.
    Each row represents a refund with attributes like ID, amount, currency, and status.
    It includes information on the associated charge, reason for refund, and timestamp.
    The table also stores metadata and receipt numbers for each refund. All refunds
    in the sample have succeeded status and are in USD currency.
  columns:
  - name: refund_id
    description: Unique identifier for the refund
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each refund. For
        this table, each row is for a single refund transaction. refund_id is unique
        across rows as it's designed to be a unique identifier for each refund.
  - name: refund_amount_cents
    description: Refund amount in cents
    tests:
    - not_null
  - name: balance_transaction_id
    description: Unique identifier for the balance transaction
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each balance transaction
        associated with the refund. For this table, each row is for a single refund
        transaction. balance_transaction_id is likely unique across rows as each refund
        would typically have its own balance transaction.
  - name: charge_id
    description: Unique identifier for the associated charge
    tests:
    - not_null
  - name: currency
    description: Currency of the refund
    tests:
    - not_null
  - name: refund_reason
    description: Reason for the refund
    tests:
    - not_null
    - accepted_values:
        values:
        - requested_by_customer
        - duplicate
        - item_not_received
        - item_defective
        - wrong_item_shipped
        - arrived_too_late
        - no_longer_needed
        - better_price_found
        - not_as_described
        - changed_mind
        - unauthorized_purchase
        - damaged_in_transit
        - quality_not_as_expected
        - missing_parts
        - incorrect_size
        - allergic_reaction
        - subscription_cancellation
        - technical_issues
        - pricing_error
        - product_recall
  - name: receipt_number
    description: Receipt number for the refund
    tests:
    - not_null
  - name: refund_status
    description: Current status of the refund
    tests:
    - not_null
    - accepted_values:
        values:
        - succeeded
        - pending
        - failed
        - cancelled
        - processing
        - reversed
  - name: failure_balance_transaction_id
    description: ID of failed balance transaction, if any
    cocoon_meta:
      missing_acceptable: Not applicable for successful transactions without failures.
  - name: failure_reason
    description: Reason for refund failure, if any
    cocoon_meta:
      missing_acceptable: Not applicable for successful transactions without failures.
  - name: metadata
    description: Additional information about the refund
    tests:
    - not_null
  - name: refund_created_at
    description: Timestamp of when the refund was created
    tests:
    - not_null

stg_subscription_data (first 100 rows)

subscription_id billing_method billing_threshold_amount reset_billing_cycle_on_threshold cancel_at_period_end customer_id days_until_due default_payment_source_id is_live_mode subscription_quantity subscription_status application_fee_percentage billing_cycle_start cancellation_date creation_date current_period_end current_period_start end_date metadata scheduled_cancellation_date subscription_start_date tax_percentage trial_end_date trial_start_date
0 sdgfs4536 fdfjk 9 False True sdf6547 4 dfa543 True 4 active 5.0 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 2021-02-19 14:16:37 2021-02-18 14:16:37 5.0 2021-02-19 14:16:37 2021-02-18 14:16:37
1 sfjytkyu876 fdsiew 5 False True 123fsdf 5 764rhgf True 5 active 6.0 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 2021-02-18 14:16:37 2021-02-19 14:16:37 {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"} 2021-02-19 14:16:37 2021-02-18 14:16:37 6.0 2021-02-19 14:16:37 2021-02-18 14:16:37

stg_subscription_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"subscription_data_projected" AS (
    -- Projection: Selecting 24 out of 25 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "application_fee_percent",
        "billing",
        "billing_cycle_anchor",
        "billing_threshold_amount_gte",
        "billing_threshold_reset_billing_cycle_anchor",
        "cancel_at",
        "cancel_at_period_end",
        "canceled_at",
        "created",
        "current_period_end",
        "current_period_start",
        "customer_id",
        "days_until_due",
        "default_source_id",
        "ended_at",
        "livemode",
        "metadata",
        "quantity",
        "start_date",
        "status",
        "tax_percent",
        "trial_end",
        "trial_start"
    FROM "subscription_data"
),

"subscription_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> subscription_id
    -- application_fee_percent -> application_fee_percentage
    -- billing -> billing_method
    -- billing_cycle_anchor -> billing_cycle_start
    -- billing_threshold_amount_gte -> billing_threshold_amount
    -- billing_threshold_reset_billing_cycle_anchor -> reset_billing_cycle_on_threshold
    -- cancel_at -> scheduled_cancellation_date
    -- canceled_at -> cancellation_date
    -- created -> creation_date
    -- default_source_id -> default_payment_source_id
    -- ended_at -> end_date
    -- livemode -> is_live_mode
    -- quantity -> subscription_quantity
    -- start_date -> subscription_start_date
    -- status -> subscription_status
    -- tax_percent -> tax_percentage
    -- trial_end -> trial_end_date
    -- trial_start -> trial_start_date
    SELECT 
        "id" AS "subscription_id",
        "application_fee_percent" AS "application_fee_percentage",
        "billing" AS "billing_method",
        "billing_cycle_anchor" AS "billing_cycle_start",
        "billing_threshold_amount_gte" AS "billing_threshold_amount",
        "billing_threshold_reset_billing_cycle_anchor" AS "reset_billing_cycle_on_threshold",
        "cancel_at" AS "scheduled_cancellation_date",
        "cancel_at_period_end",
        "canceled_at" AS "cancellation_date",
        "created" AS "creation_date",
        "current_period_end",
        "current_period_start",
        "customer_id",
        "days_until_due",
        "default_source_id" AS "default_payment_source_id",
        "ended_at" AS "end_date",
        "livemode" AS "is_live_mode",
        "metadata",
        "quantity" AS "subscription_quantity",
        "start_date" AS "subscription_start_date",
        "status" AS "subscription_status",
        "tax_percent" AS "tax_percentage",
        "trial_end" AS "trial_end_date",
        "trial_start" AS "trial_start_date"
    FROM "subscription_data_projected"
),

"subscription_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- billing_method: The problem is that both values 'fdfjk' and 'fdsiew' in the billing_method column are meaningless strings that do not represent valid billing methods. These appear to be random character combinations with no discernible meaning or pattern. The correct values for a billing method column should be actual payment methods like 'credit card', 'debit card', 'PayPal', 'bank transfer', etc. Since we don't have information about the correct billing methods, we'll map these meaningless strings to an empty string. 
    SELECT
        "subscription_id",
        "application_fee_percentage",
        CASE
            WHEN "billing_method" = '''fdfjk''' THEN ''''
            WHEN "billing_method" = '''fdsiew''' THEN ''''
            ELSE "billing_method"
        END AS "billing_method",
        "billing_cycle_start",
        "billing_threshold_amount",
        "reset_billing_cycle_on_threshold",
        "scheduled_cancellation_date",
        "cancel_at_period_end",
        "cancellation_date",
        "creation_date",
        "current_period_end",
        "current_period_start",
        "customer_id",
        "days_until_due",
        "default_payment_source_id",
        "end_date",
        "is_live_mode",
        "metadata",
        "subscription_quantity",
        "subscription_start_date",
        "subscription_status",
        "tax_percentage",
        "trial_end_date",
        "trial_start_date"
    FROM "subscription_data_projected_renamed"
),

"subscription_data_projected_renamed_cleaned_casted" AS (
    -- Column Type Casting: 
    -- application_fee_percentage: from INT to DECIMAL
    -- billing_cycle_start: from VARCHAR to TIMESTAMP
    -- cancellation_date: from VARCHAR to TIMESTAMP
    -- creation_date: from VARCHAR to TIMESTAMP
    -- current_period_end: from VARCHAR to TIMESTAMP
    -- current_period_start: from VARCHAR to TIMESTAMP
    -- end_date: from VARCHAR to TIMESTAMP
    -- metadata: from VARCHAR to JSON
    -- scheduled_cancellation_date: from VARCHAR to TIMESTAMP
    -- subscription_start_date: from VARCHAR to TIMESTAMP
    -- tax_percentage: from INT to DECIMAL
    -- trial_end_date: from VARCHAR to TIMESTAMP
    -- trial_start_date: from VARCHAR to TIMESTAMP
    SELECT
        "subscription_id",
        "billing_method",
        "billing_threshold_amount",
        "reset_billing_cycle_on_threshold",
        "cancel_at_period_end",
        "customer_id",
        "days_until_due",
        "default_payment_source_id",
        "is_live_mode",
        "subscription_quantity",
        "subscription_status",
        CAST("application_fee_percentage" AS DECIMAL) AS "application_fee_percentage",
        CAST("billing_cycle_start" AS TIMESTAMP) AS "billing_cycle_start",
        CAST("cancellation_date" AS TIMESTAMP) AS "cancellation_date",
        CAST("creation_date" AS TIMESTAMP) AS "creation_date",
        CAST("current_period_end" AS TIMESTAMP) AS "current_period_end",
        CAST("current_period_start" AS TIMESTAMP) AS "current_period_start",
        CAST("end_date" AS TIMESTAMP) AS "end_date",
        CAST("metadata" AS JSON) AS "metadata",
        CAST("scheduled_cancellation_date" AS TIMESTAMP) AS "scheduled_cancellation_date",
        CAST("subscription_start_date" AS TIMESTAMP) AS "subscription_start_date",
        CAST("tax_percentage" AS DECIMAL) AS "tax_percentage",
        CAST("trial_end_date" AS TIMESTAMP) AS "trial_end_date",
        CAST("trial_start_date" AS TIMESTAMP) AS "trial_start_date"
    FROM "subscription_data_projected_renamed_cleaned"
)

-- COCOON BLOCK END
SELECT * FROM "subscription_data_projected_renamed_cleaned_casted"

stg_subscription_data.yml (Document the table)

version: 2
models:
- name: stg_subscription_data
  description: The table is about subscription data. It contains details of individual
    subscriptions, including billing information, subscription status, customer ID,
    and pricing details. Key fields include subscription ID, billing cycle dates,
    cancellation info, customer ID, subscription status, and trial period dates. The
    metadata field stores additional custom information like external IDs.
  columns:
  - name: subscription_id
    description: Unique identifier for the subscription
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each subscription.
        For this table, each row represents a distinct subscription, and subscription_id
        should be unique across rows.
  - name: billing_method
    description: Billing type or method for the subscription
    tests:
    - not_null
    - accepted_values:
        values:
        - Credit Card
        - Debit Card
        - PayPal
        - Bank Transfer
        - Cash
        - Check
        - Apple Pay
        - Google Pay
        - Cryptocurrency
        - Invoice
        - Direct Debit
        - Wire Transfer
        - fdfjk
        - fdsiew
  - name: billing_threshold_amount
    description: Minimum amount to trigger a billing event
    tests:
    - not_null
  - name: reset_billing_cycle_on_threshold
    description: Indicates if billing cycle resets on threshold
    tests:
    - not_null
  - name: cancel_at_period_end
    description: Indicates if subscription cancels at period end
    tests:
    - not_null
  - name: customer_id
    description: Unique identifier for the customer
    tests:
    - not_null
  - name: days_until_due
    description: Number of days until payment is due
    tests:
    - not_null
  - name: default_payment_source_id
    description: ID of the default payment source
    tests:
    - not_null
  - name: is_live_mode
    description: Indicates if the subscription is in live mode
    tests:
    - not_null
  - name: subscription_quantity
    description: Quantity of the subscribed item or service
    tests:
    - not_null
  - name: subscription_status
    description: Current status of the subscription
    tests:
    - not_null
    - accepted_values:
        values:
        - active
        - inactive
        - pending
        - cancelled
        - expired
        - suspended
        - trialing
        - past_due
        - unpaid
        - on_hold
  - name: application_fee_percentage
    description: Percentage of the application fee charged
    tests:
    - not_null
  - name: billing_cycle_start
    description: Date/time when the billing cycle starts
    tests:
    - not_null
  - name: cancellation_date
    description: Date/time when the subscription was canceled
    tests:
    - not_null
  - name: creation_date
    description: Date/time when the subscription was created
    tests:
    - not_null
  - name: current_period_end
    description: End date/time of the current billing period
    tests:
    - not_null
  - name: current_period_start
    description: Start date/time of the current billing period
    tests:
    - not_null
  - name: end_date
    description: Date/time when the subscription ended
    tests:
    - not_null
  - name: metadata
    description: Additional custom information about the subscription
    tests:
    - not_null
  - name: scheduled_cancellation_date
    description: Scheduled date/time for subscription cancellation
    tests:
    - not_null
  - name: subscription_start_date
    description: Date/time when the subscription started
    tests:
    - not_null
  - name: tax_percentage
    description: Percentage of tax applied to the subscription
    tests:
    - not_null
  - name: trial_end_date
    description: End date/time of the trial period
    tests:
    - not_null
  - name: trial_start_date
    description: Start date/time of the trial period
    tests:
    - not_null

stg_payout_data (first 100 rows)

payout_id payout_amount_cents is_automatic balance_transaction_id currency_code description destination_bank_account_id is_live_mode payout_method source_type payout_status destination_type connected_account_id creation_timestamp destination_card_id estimated_arrival_date failure_code failure_message failure_transaction_id metadata
0 po_0IB8cXig6peNXzgDJWLvHBB7 3029432 True txn_0IB8cXig6peNXzgDppfO2tfk usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card paid bank_account None 2021-01-19 01:02:57 None 2021-01-20 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
1 po_0IBrZLig6peNXzgD7Q0he6QN 326282 True txn_0IBrZLig6peNXzgDfFANob1M usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card paid bank_account None 2021-01-21 01:02:39 None 2021-01-22 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
2 po_0ICwzpig6peNXzgDqW5S9QbF 326007 True txn_0ICwzpig6peNXzgDhkqfC7lv usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-01-24 01:02:29 None 2021-01-25 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
3 po_0IDJVZig6peNXzgDCa4dLDjL 3300115 True txn_0IDJVZig6peNXzgD8oPNqfSe usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-01-25 01:04:45 None 2021-01-26 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
4 po_0IDfx4ig6peNXzgD2NiVJ5ld 4464139 True txn_0IDfx4ig6peNXzgDOvqZCzzq usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-01-26 01:02:38 None 2021-01-27 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
5 po_0IE2QFig6peNXzgDCoJMX6xo -833651 True txn_0IE2QFig6peNXzgDr5Rvjm1t usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-01-27 01:02:15 None 2021-01-28 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
6 po_0IEOwcig6peNXzgDLErzeeJU 174685 True txn_0IEOwcig6peNXzgDQKcXjNLh usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-01-28 01:05:10 None 2021-01-29 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
7 po_0IFUKBig6peNXzgDZQM7WPAo 1980810 True txn_0IFUKBig6peNXzgDrDgkiAOI usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-01-31 01:01:59 None 2021-02-01 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
8 po_0IFqn3ig6peNXzgDJ7KVXGLY 270636 True txn_0IFqn3ig6peNXzgDgLPJeYJh usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-02-01 01:01:17 None 2021-02-02 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
9 po_0IGZkNig6peNXzgDKn9LrliN 1813268 True txn_0IGZkNig6peNXzgDHrcegNwS usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-02-03 01:01:31 None 2021-02-04 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
10 po_0IGwErig6peNXzgDEGgZ8lu3 39668 True txn_0IGwErig6peNXzgDiZ6nFXFL usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-02-04 01:02:29 None 2021-02-05 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
11 po_0II1gGig6peNXzgD4BxKEJJJ 2849353 True txn_0II1gGig6peNXzgDFFGOaKud usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-02-07 01:03:16 None 2021-02-08 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
12 po_0IIOASig6peNXzgDiKGtfbo9 775006 True txn_0IIOASig6peNXzgDk2yRKDOz usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-02-08 01:03:56 None 2021-02-09 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
13 po_0IIkbpig6peNXzgDs1u3xoyq 2593997 True txn_0IIkbpig6peNXzgDPUQ4T1Hd usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-02-09 01:01:41 None 2021-02-10 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}
14 po_0IJ74Lig6peNXzgD2WboJcUe 361777 True txn_0IJ74Lig6peNXzgD4IuGp8d3 usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True standard card in_transit bank_account None 2021-02-10 01:00:37 None 2021-02-11 None None None {"external_id":"80755622-45b3-40a6-9544-25af39e0e50c"}

stg_payout_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"payout_data_projected" AS (
    -- Projection: Selecting 21 out of 22 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "amount",
        "arrival_date",
        "automatic",
        "balance_transaction_id",
        "connected_account_id",
        "created",
        "currency",
        "description",
        "destination_bank_account_id",
        "destination_card_id",
        "failure_balance_transaction_id",
        "failure_code",
        "failure_message",
        "livemode",
        "metadata",
        "method",
        "source_type",
        "statement_descriptor",
        "status",
        "type"
    FROM "payout_data"
),

"payout_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> payout_id
    -- amount -> payout_amount_cents
    -- arrival_date -> estimated_arrival_date
    -- automatic -> is_automatic
    -- created -> creation_timestamp
    -- currency -> currency_code
    -- failure_balance_transaction_id -> failure_transaction_id
    -- livemode -> is_live_mode
    -- method -> payout_method
    -- status -> payout_status
    -- type -> destination_type
    SELECT 
        "id" AS "payout_id",
        "amount" AS "payout_amount_cents",
        "arrival_date" AS "estimated_arrival_date",
        "automatic" AS "is_automatic",
        "balance_transaction_id",
        "connected_account_id",
        "created" AS "creation_timestamp",
        "currency" AS "currency_code",
        "description",
        "destination_bank_account_id",
        "destination_card_id",
        "failure_balance_transaction_id" AS "failure_transaction_id",
        "failure_code",
        "failure_message",
        "livemode" AS "is_live_mode",
        "metadata",
        "method" AS "payout_method",
        "source_type",
        "statement_descriptor",
        "status" AS "payout_status",
        "type" AS "destination_type"
    FROM "payout_data_projected"
),

"payout_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- connected_account_id: from DECIMAL to VARCHAR
    -- creation_timestamp: from VARCHAR to TIMESTAMP
    -- destination_card_id: from DECIMAL to VARCHAR
    -- estimated_arrival_date: from VARCHAR to DATE
    -- failure_code: from DECIMAL to VARCHAR
    -- failure_message: from DECIMAL to VARCHAR
    -- failure_transaction_id: from DECIMAL to VARCHAR
    -- metadata: from VARCHAR to JSON
    -- statement_descriptor: from DECIMAL to VARCHAR
    SELECT
        "payout_id",
        "payout_amount_cents",
        "is_automatic",
        "balance_transaction_id",
        "currency_code",
        "description",
        "destination_bank_account_id",
        "is_live_mode",
        "payout_method",
        "source_type",
        "payout_status",
        "destination_type",
        CAST("connected_account_id" AS VARCHAR) AS "connected_account_id",
        CAST("creation_timestamp" AS TIMESTAMP) AS "creation_timestamp",
        CAST("destination_card_id" AS VARCHAR) AS "destination_card_id",
        CAST("estimated_arrival_date" AS DATE) AS "estimated_arrival_date",
        CAST("failure_code" AS VARCHAR) AS "failure_code",
        CAST("failure_message" AS VARCHAR) AS "failure_message",
        CAST("failure_transaction_id" AS VARCHAR) AS "failure_transaction_id",
        CAST("metadata" AS JSON) AS "metadata",
        CAST("statement_descriptor" AS VARCHAR) AS "statement_descriptor"
    FROM "payout_data_projected_renamed"
),

"payout_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 1 columns with unacceptable missing values
    -- statement_descriptor has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "payout_id",
        "payout_amount_cents",
        "is_automatic",
        "balance_transaction_id",
        "currency_code",
        "description",
        "destination_bank_account_id",
        "is_live_mode",
        "payout_method",
        "source_type",
        "payout_status",
        "destination_type",
        "connected_account_id",
        "creation_timestamp",
        "destination_card_id",
        "estimated_arrival_date",
        "failure_code",
        "failure_message",
        "failure_transaction_id",
        "metadata"
    FROM "payout_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "payout_data_projected_renamed_casted_missing_handled"

stg_payout_data.yml (Document the table)

version: 2
models:
- name: stg_payout_data
  description: The table is about Stripe payouts. It contains details of individual
    payout transactions. Each row represents a payout with attributes like amount,
    currency, dates, status, and destination account. The table includes information
    on payout methods, source types, and transaction IDs. It also stores metadata
    and flags for automatic processing and live mode.
  columns:
  - name: payout_id
    description: Unique identifier for the payout
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column is a unique identifier for each payout transaction.
        For this table, each row represents a single payout, and payout_id is unique
        across rows.
  - name: payout_amount_cents
    description: Payout amount in cents
    tests:
    - not_null
  - name: is_automatic
    description: Indicates if payout was automatically scheduled
    tests:
    - not_null
  - name: balance_transaction_id
    description: Unique identifier for the balance transaction
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column appears to be a unique identifier for each balance transaction
        associated with a payout. For this table, each row represents a single payout,
        and balance_transaction_id is unique across rows.
  - name: currency_code
    description: Currency code of the payout
    tests:
    - not_null
  - name: description
    description: Brief description of the payout
    tests:
    - not_null
  - name: destination_bank_account_id
    description: ID of the destination bank account
    tests:
    - not_null
  - name: is_live_mode
    description: Indicates if payout was in live mode
    tests:
    - not_null
  - name: payout_method
    description: Method used for the payout
    tests:
    - not_null
    - accepted_values:
        values:
        - standard
        - express
        - wire transfer
        - check
        - direct deposit
        - paypal
        - cryptocurrency
        - prepaid card
        - cash
        - bank transfer
  - name: source_type
    description: Type of source for the payout
    tests:
    - not_null
    - accepted_values:
        values:
        - card
        - bank_account
        - cash
        - check
        - wire_transfer
        - paypal
        - venmo
        - cryptocurrency
        - other
  - name: payout_status
    description: Current status of the payout
    tests:
    - not_null
    - accepted_values:
        values:
        - in_transit
        - paid
        - pending
        - failed
        - canceled
        - reversed
        - completed
  - name: destination_type
    description: Type of payout destination
    tests:
    - not_null
    - accepted_values:
        values:
        - bank_account
        - credit_card
        - paypal
        - venmo
        - cash_app
        - check
        - wire_transfer
        - prepaid_card
        - cryptocurrency_wallet
        - mobile_money
  - name: connected_account_id
    description: ID of the connected Stripe account
    cocoon_meta:
      missing_acceptable: Not applicable for direct payouts without connected accounts.
  - name: creation_timestamp
    description: Timestamp of payout creation
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the exact time when the payout was created.
        While it's theoretically possible for two payouts to be created at the exact
        same second, it's highly unlikely in practice. For this table, each row represents
        a single payout, and creation_timestamp is likely to be unique across rows.
  - name: destination_card_id
    description: ID of the destination card (if applicable)
    cocoon_meta:
      missing_acceptable: Not applicable for bank account payouts.
  - name: estimated_arrival_date
    description: Estimated date of payout arrival
    tests:
    - not_null
  - name: failure_code
    description: Code indicating reason for payout failure
    cocoon_meta:
      missing_acceptable: Not applicable for successful transactions without failures.
  - name: failure_message
    description: Detailed message explaining payout failure
    cocoon_meta:
      missing_acceptable: Not applicable for successful transactions without failures.
  - name: failure_transaction_id
    description: Transaction ID if payout failed
    cocoon_meta:
      missing_acceptable: Not applicable for successful transactions without failures.
  - name: metadata
    description: Additional information in JSON format
    tests:
    - not_null

stg_credit_note_data (first 100 rows)

credit_note_id currency is_live credit_note_number pdf_url status credit_note_type invoice_id refund_id creation_date credit_note_amount discount_amount metadata subtotal total void_date
0 cn_89hUNfs usd True E89505E-0024-CN-01 https://pay.stripe.com/credit_notes/acct_test/cnst_test/pdf issued post_payment in_1J7DINLdeVo re_1J82INYKl7x 2021-06-30 10:04:03 50.0 0.0 {} 50.0 50.0 NaT
1 cn_Jg3Jf0s usd False 450DS21-0034-CN-01 https://pay.stripe.com/credit_notes/acct_test2/cnst_test2/pdf issued post_payment in_1IPp7kCLA0Q re_1IKhINvmkAi 2021-03-15 17:44:14 100.0 0.0 {} 100.0 100.0 NaT

stg_credit_note_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"credit_note_data_projected" AS (
    -- Projection: Selecting 19 out of 20 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "amount",
        "created",
        "currency",
        "discount_amount",
        "subtotal",
        "total",
        "livemode",
        "memo",
        "metadata",
        "number",
        "pdf",
        "reason",
        "status",
        "type",
        "voided_at",
        "customer_balance_transaction_id",
        "invoice_id",
        "refund_id"
    FROM "credit_note_data"
),

"credit_note_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> credit_note_id
    -- amount -> credit_note_amount
    -- created -> creation_date
    -- livemode -> is_live
    -- number -> credit_note_number
    -- pdf -> pdf_url
    -- type -> credit_note_type
    -- voided_at -> void_date
    -- customer_balance_transaction_id -> balance_transaction_id
    SELECT 
        "id" AS "credit_note_id",
        "amount" AS "credit_note_amount",
        "created" AS "creation_date",
        "currency",
        "discount_amount",
        "subtotal",
        "total",
        "livemode" AS "is_live",
        "memo",
        "metadata",
        "number" AS "credit_note_number",
        "pdf" AS "pdf_url",
        "reason",
        "status",
        "type" AS "credit_note_type",
        "voided_at" AS "void_date",
        "customer_balance_transaction_id" AS "balance_transaction_id",
        "invoice_id",
        "refund_id"
    FROM "credit_note_data_projected"
),

"credit_note_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- balance_transaction_id: from DECIMAL to VARCHAR
    -- creation_date: from VARCHAR to TIMESTAMP
    -- credit_note_amount: from INT to DECIMAL
    -- discount_amount: from INT to DECIMAL
    -- memo: from DECIMAL to VARCHAR
    -- metadata: from VARCHAR to JSON
    -- reason: from DECIMAL to VARCHAR
    -- subtotal: from INT to DECIMAL
    -- total: from INT to DECIMAL
    -- void_date: from DECIMAL to DATE
    SELECT
        "credit_note_id",
        "currency",
        "is_live",
        "credit_note_number",
        "pdf_url",
        "status",
        "credit_note_type",
        "invoice_id",
        "refund_id",
        CAST("balance_transaction_id" AS VARCHAR) AS "balance_transaction_id",
        CAST("creation_date" AS TIMESTAMP) AS "creation_date",
        CAST("credit_note_amount" AS DECIMAL) AS "credit_note_amount",
        CAST("discount_amount" AS DECIMAL) AS "discount_amount",
        CAST("memo" AS VARCHAR) AS "memo",
        CAST("metadata" AS JSON) AS "metadata",
        CAST("reason" AS VARCHAR) AS "reason",
        CAST("subtotal" AS DECIMAL) AS "subtotal",
        CAST("total" AS DECIMAL) AS "total",
        CAST("void_date" AS DATE) AS "void_date"
    FROM "credit_note_data_projected_renamed"
),

"credit_note_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 3 columns with unacceptable missing values
    -- balance_transaction_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- memo has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- reason has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "credit_note_id",
        "currency",
        "is_live",
        "credit_note_number",
        "pdf_url",
        "status",
        "credit_note_type",
        "invoice_id",
        "refund_id",
        "creation_date",
        "credit_note_amount",
        "discount_amount",
        "metadata",
        "subtotal",
        "total",
        "void_date"
    FROM "credit_note_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "credit_note_data_projected_renamed_casted_missing_handled"

stg_credit_note_data.yml (Document the table)

version: 2
models:
- name: stg_credit_note_data
  description: The table is about credit notes issued to customers. It contains details
    like id, amount, currency, date created, discount, subtotal, total, status, and
    type. Each credit note has a unique number and PDF link. It also includes references
    to related invoice and refund ids. The table tracks whether the credit note is
    live or in test mode, and includes optional fields for memo and metadata.
  columns:
  - name: credit_note_id
    description: Unique identifier for the credit note
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column is a unique identifier for each credit note. For this
        table, each row represents a distinct credit note, and credit_note_id is unique
        across rows.
  - name: currency
    description: Currency code for the credit note
    tests:
    - not_null
  - name: is_live
    description: Indicates if the credit note is live or test
    tests:
    - not_null
  - name: credit_note_number
    description: Unique number assigned to the credit note
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique number assigned to each credit note.
        For this table, each credit note has a distinct number, making it unique across
        rows.
  - name: pdf_url
    description: URL link to the PDF version of the credit note
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column contains a unique URL for each credit note's PDF. As
        each credit note would have its own PDF link, this is likely unique across
        rows.
  - name: status
    description: Current status of the credit note
    tests:
    - not_null
    - accepted_values:
        values:
        - draft
        - issued
        - paid
        - partially_paid
        - voided
        - cancelled
        - overdue
  - name: credit_note_type
    description: Type of credit note (e.g., post_payment)
    tests:
    - not_null
    - accepted_values:
        values:
        - post_payment
        - pre_payment
        - refund
        - price_adjustment
        - goodwill
        - product_return
        - cancellation
        - correction
        - discount
        - write_off
  - name: invoice_id
    description: ID of the related invoice
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column refers to the related invoice ID. While it's possible
        that multiple credit notes could be issued for the same invoice, it's more
        likely that each credit note corresponds to a unique invoice, making it potentially
        unique across rows.
  - name: refund_id
    description: ID of the related refund
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column refers to the related refund ID. Similar to invoice_id,
        it's likely that each credit note corresponds to a unique refund, making it
        potentially unique across rows.
  - name: creation_date
    description: Date and time when the credit note was created
    tests:
    - not_null
  - name: credit_note_amount
    description: Total amount of the credit note
    tests:
    - not_null
  - name: discount_amount
    description: Amount of discount applied to the credit note
    tests:
    - not_null
  - name: metadata
    description: Additional metadata in JSON format
    tests:
    - not_null
  - name: subtotal
    description: Subtotal amount of the credit note
    tests:
    - not_null
  - name: total
    description: Total amount of the credit note after discounts
    tests:
    - not_null
  - name: void_date
    description: Date and time when the credit note was voided
    cocoon_meta:
      missing_acceptable: Not applicable for credit notes that aren't voided.

stg_transfer_data (first 100 rows)

payout_id payout_amount_cents reversed_amount_cents balance_transaction_id currency payout_description destination_bank_account_id is_live_mode is_reversed payment_source_type destination_payment destination_payment_id metadata payout_created_at
0 po_0Njtvzig6peNXzgD6RPBasht 1447318 0 txn_0Njtw0ig6peNXzgDXY3mJGwC usd STRIPE PAYOUT ba_0MkB7Nig6peNXzgDBFL0SIgk True False card None None {"netsuite_deposit_id":"3975560","netsuite_deposit_link":"https://en.wikipedia.org/wiki/Beyonc%C3%A9"} 2023-08-28 01:08:03
1 po_0NjXKxig6peNXzgDgn8MqQuZ 2660278 0 txn_0NjXKyig6peNXzgDbmNVE84K usd STRIPE PAYOUT ba_0MkB7Nig6peNXzgDBFL0SIgk True False card None None None 2023-08-27 01:00:19
2 po_0NkGNTig6peNXzgDJWfkSimX 760313 0 txn_0NkGNTig6peNXzgDTsXXisyE usd STRIPE PAYOUT ba_0MkB7Nig6peNXzgDBFL0SIgk True False card None None None 2023-08-29 01:05:55
3 po_0NkcrHig6peNXzgDwoDFU4Yi 1944407 0 txn_0NkcrHig6peNXzgD7eFO2jc7 usd STRIPE PAYOUT ba_0MkB7Nig6peNXzgDBFL0SIgk True False card None None None 2023-08-30 01:06:11
4 po_0Mbvvvig6peNXzgDNH6Wf3ha 7251977 0 txn_0Mbvvvig6peNXzgDJAGJCdpN usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True False card None None None 2023-02-16 01:06:47
5 po_0LunJvig6peNXzgD41QBrw1m -1426166 0 txn_0LunJwig6peNXzgDCnBflWPl usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True False card None None None 2022-10-20 01:13:15
6 po_0MRQ1gig6peNXzgD138jhQS7 7332491 0 txn_0MRQ1gig6peNXzgDchKTwIPQ usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True False card None None None 2023-01-18 01:01:16
7 po_0MRmW1ig6peNXzgDUPQSnmYw 6108653 0 txn_0MRmW1ig6peNXzgDFqR0yaFa usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True False card None None None 2023-01-19 01:02:05
8 po_0MJ5C6ig6peNXzgDyic22YlD 3456033 0 txn_0MJ5C7ig6peNXzgDfWTszRUw usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True False card None None None 2022-12-26 01:09:34
9 po_0MDe3Sig6peNXzgDJHinDGmA 3330213 0 txn_0MDe3Tig6peNXzgDSyxtRpRH usd STRIPE PAYOUT ba_1S2vcDBpbM03IU True False card None None None 2022-12-11 01:10:10

stg_transfer_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"transfer_data_projected" AS (
    -- Projection: Selecting 17 out of 18 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "amount",
        "amount_reversed",
        "balance_transaction_id",
        "created",
        "currency",
        "description",
        "destination",
        "destination_payment",
        "destination_payment_id",
        "livemode",
        "metadata",
        "reversed",
        "source_transaction",
        "source_transaction_id",
        "source_type",
        "transfer_group"
    FROM "transfer_data"
),

"transfer_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> payout_id
    -- amount -> payout_amount_cents
    -- amount_reversed -> reversed_amount_cents
    -- created -> payout_created_at
    -- description -> payout_description
    -- destination -> destination_bank_account_id
    -- livemode -> is_live_mode
    -- reversed -> is_reversed
    -- source_type -> payment_source_type
    SELECT 
        "id" AS "payout_id",
        "amount" AS "payout_amount_cents",
        "amount_reversed" AS "reversed_amount_cents",
        "balance_transaction_id",
        "created" AS "payout_created_at",
        "currency",
        "description" AS "payout_description",
        "destination" AS "destination_bank_account_id",
        "destination_payment",
        "destination_payment_id",
        "livemode" AS "is_live_mode",
        "metadata",
        "reversed" AS "is_reversed",
        "source_transaction",
        "source_transaction_id",
        "source_type" AS "payment_source_type",
        "transfer_group"
    FROM "transfer_data_projected"
),

"transfer_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- destination_payment: from DECIMAL to VARCHAR
    -- destination_payment_id: from DECIMAL to VARCHAR
    -- metadata: from VARCHAR to JSON
    -- payout_created_at: from VARCHAR to TIMESTAMP
    -- source_transaction: from DECIMAL to VARCHAR
    -- source_transaction_id: from DECIMAL to VARCHAR
    -- transfer_group: from DECIMAL to VARCHAR
    SELECT
        "payout_id",
        "payout_amount_cents",
        "reversed_amount_cents",
        "balance_transaction_id",
        "currency",
        "payout_description",
        "destination_bank_account_id",
        "is_live_mode",
        "is_reversed",
        "payment_source_type",
        CAST("destination_payment" AS VARCHAR) AS "destination_payment",
        CAST("destination_payment_id" AS VARCHAR) AS "destination_payment_id",
        CAST(TRIM("metadata", '"') AS JSON) AS "metadata",
        CAST("payout_created_at" AS TIMESTAMP) AS "payout_created_at",
        CAST("source_transaction" AS VARCHAR) AS "source_transaction",
        CAST("source_transaction_id" AS VARCHAR) AS "source_transaction_id",
        CAST("transfer_group" AS VARCHAR) AS "transfer_group"
    FROM "transfer_data_projected_renamed"
),

"transfer_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 4 columns with unacceptable missing values
    -- metadata has 90.0 percent missing. Strategy: 🔄 Unchanged
    -- source_transaction has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- source_transaction_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- transfer_group has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "payout_id",
        "payout_amount_cents",
        "reversed_amount_cents",
        "balance_transaction_id",
        "currency",
        "payout_description",
        "destination_bank_account_id",
        "is_live_mode",
        "is_reversed",
        "payment_source_type",
        "destination_payment",
        "destination_payment_id",
        "metadata",
        "payout_created_at"
    FROM "transfer_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "transfer_data_projected_renamed_casted_missing_handled"

stg_transfer_data.yml (Document the table)

version: 2
models:
- name: stg_transfer_data
  description: The table is about Stripe payouts. It includes details such as payout
    amount, currency, creation date, destination bank account, and transaction IDs.
    Each row represents a single payout. The table contains metadata fields, including
    references to NetSuite deposit IDs and links. All payouts are in USD and have
    not been reversed. The destination bank account is consistent across most entries.
  columns:
  - name: payout_id
    description: Unique identifier for the payout
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each payout. For
        this table, each row is for a single payout transaction. payout_id is unique
        across rows as it's specifically designed to be a unique identifier for each
        payout.
  - name: payout_amount_cents
    description: Payout amount in cents
    tests:
    - not_null
  - name: reversed_amount_cents
    description: Amount reversed in cents
    tests:
    - not_null
  - name: balance_transaction_id
    description: Unique identifier for the balance transaction
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each balance transaction
        associated with a payout. For this table, each row is for a single payout
        transaction. balance_transaction_id is unique across rows as it's specifically
        designed to be a unique identifier for each transaction.
  - name: currency
    description: Currency of the payout
    tests:
    - not_null
    - accepted_values:
        values:
        - usd
        - eur
        - gbp
        - jpy
        - cny
        - chf
        - cad
        - aud
        - nzd
        - inr
        - krw
        - sgd
        - hkd
        - mxn
        - brl
        - zar
        - sek
        - nok
        - dkk
        - rub
  - name: payout_description
    description: Brief description of the payout
    tests:
    - not_null
  - name: destination_bank_account_id
    description: Destination bank account identifier
    tests:
    - not_null
  - name: is_live_mode
    description: Indicates if the payout is live or test
    tests:
    - not_null
  - name: is_reversed
    description: Indicates if the payout was reversed
    tests:
    - not_null
  - name: payment_source_type
    description: Type of payment source
    tests:
    - not_null
    - accepted_values:
        values:
        - card
        - cash
        - bank transfer
        - digital wallet
        - cryptocurrency
        - check
        - money order
        - gift card
        - store credit
        - mobile payment
        - paypal
        - wire transfer
        - direct debit
        - prepaid card
  - name: destination_payment
    description: Unused field for destination payment
    cocoon_meta:
      missing_acceptable: Not applicable for direct bank account payouts.
  - name: destination_payment_id
    description: Unused field for destination payment ID
    cocoon_meta:
      missing_acceptable: Not applicable for direct bank account payouts.
  - name: metadata
    description: Additional information in JSON format
    tests:
    - not_null
  - name: payout_created_at
    description: Date and time of payout creation
    tests:
    - not_null

stg_plan_data (first 100 rows)

plan_id is_active price_in_cents billing_method currency_code billing_interval billing_cycle_duration is_deleted is_live_mode product_id usage_type creation_datetime plan_nickname pricing_tier_mode trial_period_days usage_aggregation_method usage_transform_divisor usage_transform_rounding
0 zbc001 True 150000 per_unit usd month 1 False True prod_BUZaPcD5jIhqAG licensed 2017-05-10 18:50:13 None None NaN None NaN None
1 abc002 True 150000 per_unit usd month 1 False True prod_BUqcov3uJTssuQ licensed 2017-05-05 16:56:44 None None NaN None NaN None
2 ghg005 True 150000 per_unit usd month 6 False True prod_BTzAZ8EnmwNUqW licensed 2017-05-15 18:53:55 None None NaN None NaN None
3 gfg003 True 180000 per_unit usd month 6 False True prod_BUonomUNsdG3qx licensed 2017-06-15 16:01:06 None None NaN None NaN None
4 gfd214 True 264030 per_unit usd month 3 False True prod_BUo1nHP2vIrVtF licensed 2017-08-04 16:29:13 None None NaN None NaN None
5 fgs754 True 45000 per_unit usd month 1 False True prod_BUBtgJBLlTGcy9 licensed 2017-06-21 16:23:32 None None NaN None NaN None
6 dfw576 True 20000 per_unit usd month 1 False True prod_BV5IFAOt2EwqSl licensed 2015-05-28 01:08:05 None None NaN None NaN None
7 rhs456 True 100 per_unit usd month 1 False True prod_BU23UCziUM7ezw licensed 2015-05-28 01:10:13 None None NaN None NaN None
8 gds003 True 50000 per_unit usd month 1 False True prod_BTXZakZKkKlf6g licensed 2015-10-23 21:23:35 None None NaN None NaN None
9 rtg234 True 40000 per_unit usd month 1 False True prod_BUrKq3BcaxvjkU licensed 2015-12-01 21:06:02 None None NaN None NaN None
10 jfg658 True 15000 per_unit usd month 1 False True prod_BUaE6AwT15sLSX licensed 2015-11-16 22:42:15 None None NaN None NaN None
11 hft345 True 11500 per_unit usd month 1 False True prod_BTN1m9rU6ivOBN licensed 2016-01-06 16:58:21 None None NaN None NaN None
12 mfh634 True 89000 per_unit usd month 1 False True prod_BTNNlwDZ0nGHYp licensed 2016-03-09 23:16:21 None None NaN None NaN None

stg_plan_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"plan_data_projected" AS (
    -- Projection: Selecting 18 out of 19 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "active",
        "aggregate_usage",
        "amount",
        "billing_scheme",
        "created",
        "currency",
        "interval_",
        "interval_count",
        "is_deleted",
        "livemode",
        "nickname",
        "product_id",
        "tiers_mode",
        "transform_usage_divide_by",
        "transform_usage_round",
        "trial_period_days",
        "usage_type"
    FROM "plan_data"
),

"plan_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> plan_id
    -- active -> is_active
    -- aggregate_usage -> usage_aggregation_method
    -- amount -> price_in_cents
    -- billing_scheme -> billing_method
    -- created -> creation_datetime
    -- currency -> currency_code
    -- interval_ -> billing_interval
    -- interval_count -> billing_cycle_duration
    -- livemode -> is_live_mode
    -- nickname -> plan_nickname
    -- tiers_mode -> pricing_tier_mode
    -- transform_usage_divide_by -> usage_transform_divisor
    -- transform_usage_round -> usage_transform_rounding
    SELECT 
        "id" AS "plan_id",
        "active" AS "is_active",
        "aggregate_usage" AS "usage_aggregation_method",
        "amount" AS "price_in_cents",
        "billing_scheme" AS "billing_method",
        "created" AS "creation_datetime",
        "currency" AS "currency_code",
        "interval_" AS "billing_interval",
        "interval_count" AS "billing_cycle_duration",
        "is_deleted",
        "livemode" AS "is_live_mode",
        "nickname" AS "plan_nickname",
        "product_id",
        "tiers_mode" AS "pricing_tier_mode",
        "transform_usage_divide_by" AS "usage_transform_divisor",
        "transform_usage_round" AS "usage_transform_rounding",
        "trial_period_days",
        "usage_type"
    FROM "plan_data_projected"
),

"plan_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- plan_id: The problem is that the plan_id column contains inconsistent formats and lengths. Some values start with numbers, others with letters, and there's no consistent pattern. The correct format appears to be a combination of letters and numbers, with the most common pattern being three letters followed by three numbers (e.g., 'abc123'). Values that don't fit this pattern should be considered unusual and need to be corrected. 
    SELECT
        CASE
            WHEN "plan_id" = '214gfdg' THEN 'gfd214'
            WHEN "plan_id" = '234rtgh' THEN 'rtg234'
            WHEN "plan_id" = '3gds' THEN 'gds003'
            WHEN "plan_id" = '3gf' THEN 'gfg003'
            WHEN "plan_id" = '5gh' THEN 'ghg005'
            WHEN "plan_id" = '634mfh' THEN 'mfh634'
            WHEN "plan_id" = '658jfgh' THEN 'jfg658'
            WHEN "plan_id" = 'ab2' THEN 'abc002'
            WHEN "plan_id" = 'dfgdw576' THEN 'dfw576'
            WHEN "plan_id" = 'fgds754' THEN 'fgs754'
            WHEN "plan_id" = 'hfdstrt345' THEN 'hft345'
            WHEN "plan_id" = 'rhsdr456' THEN 'rhs456'
            WHEN "plan_id" = 'zb1' THEN 'zbc001'
            ELSE "plan_id"
        END AS "plan_id",
        "is_active",
        "usage_aggregation_method",
        "price_in_cents",
        "billing_method",
        "creation_datetime",
        "currency_code",
        "billing_interval",
        "billing_cycle_duration",
        "is_deleted",
        "is_live_mode",
        "plan_nickname",
        "product_id",
        "pricing_tier_mode",
        "usage_transform_divisor",
        "usage_transform_rounding",
        "trial_period_days",
        "usage_type"
    FROM "plan_data_projected_renamed"
),

"plan_data_projected_renamed_cleaned_casted" AS (
    -- Column Type Casting: 
    -- creation_datetime: from VARCHAR to TIMESTAMP
    -- plan_nickname: from DECIMAL to VARCHAR
    -- pricing_tier_mode: from DECIMAL to VARCHAR
    -- trial_period_days: from DECIMAL to INT
    -- usage_aggregation_method: from DECIMAL to VARCHAR
    -- usage_transform_divisor: from DECIMAL to INT
    -- usage_transform_rounding: from DECIMAL to VARCHAR
    SELECT
        "plan_id",
        "is_active",
        "price_in_cents",
        "billing_method",
        "currency_code",
        "billing_interval",
        "billing_cycle_duration",
        "is_deleted",
        "is_live_mode",
        "product_id",
        "usage_type",
        CAST("creation_datetime" AS TIMESTAMP) AS "creation_datetime",
        CAST("plan_nickname" AS VARCHAR) AS "plan_nickname",
        CAST("pricing_tier_mode" AS VARCHAR) AS "pricing_tier_mode",
        CAST("trial_period_days" AS INT) AS "trial_period_days",
        CAST("usage_aggregation_method" AS VARCHAR) AS "usage_aggregation_method",
        CAST("usage_transform_divisor" AS INT) AS "usage_transform_divisor",
        CAST("usage_transform_rounding" AS VARCHAR) AS "usage_transform_rounding"
    FROM "plan_data_projected_renamed_cleaned"
)

-- COCOON BLOCK END
SELECT * FROM "plan_data_projected_renamed_cleaned_casted"

stg_plan_data.yml (Document the table)

version: 2
models:
- name: stg_plan_data
  description: The table is about subscription plans. It contains details like plan
    ID, active status, pricing amount, currency, billing interval, created date, and
    product ID. Each row represents a unique plan with its specific attributes. The
    plans have different durations (monthly or multi-month) and prices. All plans
    use USD currency and are set to "licensed" usage type.
  columns:
  - name: plan_id
    description: Unique identifier for the plan
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each subscription
        plan. For this table, each row represents a distinct subscription plan. The
        plan_id appears to be unique across rows, as it uses a specific alphanumeric
        format (e.g., zbc001, abc002) that is likely designed to be unique for each
        plan.
  - name: is_active
    description: Indicates if the plan is currently active
    tests:
    - not_null
  - name: price_in_cents
    description: Price of the plan in cents
    tests:
    - not_null
  - name: billing_method
    description: Method used for billing calculation
    tests:
    - not_null
    - accepted_values:
        values:
        - per_unit
        - flat_rate
        - tiered
        - usage_based
        - subscription
        - value_based
        - time_and_materials
        - milestone
        - cost_plus
        - percentage_of_completion
  - name: currency_code
    description: Currency used for the plan pricing
    tests:
    - not_null
  - name: billing_interval
    description: Billing frequency (e.g., month)
    tests:
    - not_null
    - accepted_values:
        values:
        - day
        - week
        - month
        - quarter
        - year
  - name: billing_cycle_duration
    description: Number of intervals between billings
    tests:
    - not_null
  - name: is_deleted
    description: Indicates if the plan has been deleted
    tests:
    - not_null
  - name: is_live_mode
    description: Indicates if the plan is in live or test mode
    tests:
    - not_null
  - name: product_id
    description: Unique identifier of the associated product
    tests:
    - not_null
  - name: usage_type
    description: Type of usage for the plan
    tests:
    - not_null
    - accepted_values:
        values:
        - licensed
        - subscription
        - pay-per-use
        - freemium
        - perpetual
        - tiered
        - metered
        - floating
        - site
        - volume
        - concurrent
        - named-user
        - enterprise
        - academic
        - trial
  - name: creation_datetime
    description: Date and time when the plan was created
    tests:
    - not_null
  - name: plan_nickname
    description: Optional nickname for the plan (empty in this case)
    cocoon_meta:
      missing_acceptable: Optional friendly name for the plan, not always needed.
  - name: pricing_tier_mode
    description: Pricing tier structure (empty in this case)
    cocoon_meta:
      missing_acceptable: Not applicable for plans without tiered pricing.
  - name: trial_period_days
    description: Number of trial days (empty in this case)
    cocoon_meta:
      missing_acceptable: Not applicable for plans without a trial period.
  - name: usage_aggregation_method
    description: Aggregation method for metered usage (empty in this case)
    cocoon_meta:
      missing_acceptable: Not applicable for licensed plans without usage-based billing.
  - name: usage_transform_divisor
    description: Usage transformation divisor (empty in this case)
    cocoon_meta:
      missing_acceptable: Not applicable for licensed plans without usage transformations.
  - name: usage_transform_rounding
    description: Usage transformation rounding method (empty in this case)
    cocoon_meta:
      missing_acceptable: Not applicable for licensed plans without usage transformations.

stg_customer_data (first 100 rows)

customer_id is_delinquent invoice_prefix is_deleted is_live_mode hashed_customer_name tax_exempt_status account_balance account_creation_date balance shipping_address_city shipping_address_country shipping_address_line_1 shipping_address_line_2 shipping_address_postal_code shipping_address_state shipping_carrier shipping_name shipping_phone shipping_tracking_number
0 cus_ImVzJQmSlYHjZL False 8311D827 False True a0d47e7c5acc1069de81fd0ac370d10f none 0.0 2021-01-18 12:35:30 0.0 None None None None None None None None None None
1 cus_IzaB1l1LWzI6DZ False 79EDFB49 False True 0d080bf0b4e2e0cce69b285046962a7b none 0.0 2021-02-22 09:48:04 0.0 None None None None None None None None None None
2 cus_J2eHEreSmx1eAe False B3530880 False True fc48fc29ca836fb38f6d81a99fa4204e none 0.0 2021-03-02 14:13:25 0.0 None None None None None None None None None None
3 cus_IxqxnofljLKmqa False 612C196A False True 37bac6dce4f46277d89bfa3003e2e39b none 0.0 2021-02-17 18:59:27 0.0 None None None None None None None None None None
4 cus_J66nsZHMTFup1P False 446D4207 False True b65dc7a76139fc06725caccf229004c2 none 0.0 2021-03-11 19:53:45 0.0 None None None None None None None None None None
5 cus_IvSD6mXKJ1pZeW False 89291D20 False True 6025a593946d5965fdf7c7365e25c33f none 0.0 2021-02-11 09:18:04 0.0 None None None None None None None None None None
6 cus_IrpAwGHpPSwzWv False F0F08B37 False True dcddf44d3df6437334f3491ed8c52bf2 none 0.0 2021-02-01 16:45:09 0.0 None None None None None None None None None None
7 cus_IpSJ4exzUAFTHX False B761C599 False True 93f783b4d19fb35f9522de6fef236d98 none 0.0 2021-01-26 08:59:52 0.0 None None None None None None None None None None
8 cus_IvcMWh1c3qNhie False 08D6093C False True c31eed413e5e7ea16023bcfa3a4e5e55 none 0.0 2021-02-11 19:46:48 0.0 None None None None None None None None None None
9 cus_J2lfqeIO1HDfEy False 934E47FE False True e6fe1559d8fe8d56ec8e4b58bde4916e none 0.0 2021-03-02 21:51:56 0.0 None None None None None None None None None None
10 cus_J0nHRNKalyp1TX False 3D83A36A False True 6ff9f4444ac481652f4412b5e1623846 none 0.0 2021-02-25 15:23:42 0.0 None None None None None None None None None None
11 cus_IuKuZJLG9mNRn2 False 94FA9348 True True 37a6259cc0c1dae299a7866489dff0bd none 0.0 2021-02-08 09:40:39 0.0 None None None None None None None None None None

stg_customer_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"customer_data_projected" AS (
    -- Projection: Selecting 39 out of 40 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "account_balance",
        "address_city",
        "address_country",
        "address_line_1",
        "address_line_2",
        "address_postal_code",
        "address_state",
        "balance",
        "bank_account_id",
        "created",
        "currency",
        "default_card_id",
        "delinquent",
        "description",
        "email",
        "invoice_prefix",
        "invoice_settings_default_payment_method",
        "invoice_settings_footer",
        "is_deleted",
        "livemode",
        "name",
        "phone",
        "shipping_address_city",
        "shipping_address_country",
        "shipping_address_line_1",
        "shipping_address_line_2",
        "shipping_address_postal_code",
        "shipping_address_state",
        "shipping_carrier",
        "shipping_name",
        "shipping_phone",
        "shipping_tracking_number",
        "source_id",
        "tax_exempt",
        "tax_info_tax_id",
        "tax_info_type",
        "tax_info_verification_status",
        "tax_info_verification_verified_name"
    FROM "customer_data"
),

"customer_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> customer_id
    -- created -> account_creation_date
    -- delinquent -> is_delinquent
    -- description -> customer_description
    -- invoice_settings_default_payment_method -> default_invoice_payment_method
    -- invoice_settings_footer -> invoice_footer
    -- livemode -> is_live_mode
    -- name -> hashed_customer_name
    -- source_id -> customer_data_source_id
    -- tax_exempt -> tax_exempt_status
    -- tax_info_tax_id -> tax_id
    -- tax_info_verification_status -> tax_verification_status
    -- tax_info_verification_verified_name -> tax_verified_name
    SELECT 
        "id" AS "customer_id",
        "account_balance",
        "address_city",
        "address_country",
        "address_line_1",
        "address_line_2",
        "address_postal_code",
        "address_state",
        "balance",
        "bank_account_id",
        "created" AS "account_creation_date",
        "currency",
        "default_card_id",
        "delinquent" AS "is_delinquent",
        "description" AS "customer_description",
        "email",
        "invoice_prefix",
        "invoice_settings_default_payment_method" AS "default_invoice_payment_method",
        "invoice_settings_footer" AS "invoice_footer",
        "is_deleted",
        "livemode" AS "is_live_mode",
        "name" AS "hashed_customer_name",
        "phone",
        "shipping_address_city",
        "shipping_address_country",
        "shipping_address_line_1",
        "shipping_address_line_2",
        "shipping_address_postal_code",
        "shipping_address_state",
        "shipping_carrier",
        "shipping_name",
        "shipping_phone",
        "shipping_tracking_number",
        "source_id" AS "customer_data_source_id",
        "tax_exempt" AS "tax_exempt_status",
        "tax_info_tax_id" AS "tax_id",
        "tax_info_type",
        "tax_info_verification_status" AS "tax_verification_status",
        "tax_info_verification_verified_name" AS "tax_verified_name"
    FROM "customer_data_projected"
),

"customer_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- account_balance: from INT to DECIMAL
    -- account_creation_date: from VARCHAR to TIMESTAMP
    -- address_city: from DECIMAL to VARCHAR
    -- address_country: from DECIMAL to VARCHAR
    -- address_line_1: from DECIMAL to VARCHAR
    -- address_line_2: from DECIMAL to VARCHAR
    -- address_postal_code: from DECIMAL to VARCHAR
    -- address_state: from DECIMAL to VARCHAR
    -- balance: from INT to DECIMAL
    -- currency: from DECIMAL to VARCHAR
    -- customer_data_source_id: from DECIMAL to VARCHAR
    -- customer_description: from DECIMAL to VARCHAR
    -- default_card_id: from DECIMAL to VARCHAR
    -- default_invoice_payment_method: from DECIMAL to VARCHAR
    -- email: from DECIMAL to VARCHAR
    -- invoice_footer: from DECIMAL to VARCHAR
    -- phone: from DECIMAL to VARCHAR
    -- shipping_address_city: from DECIMAL to VARCHAR
    -- shipping_address_country: from DECIMAL to VARCHAR
    -- shipping_address_line_1: from DECIMAL to VARCHAR
    -- shipping_address_line_2: from DECIMAL to VARCHAR
    -- shipping_address_postal_code: from DECIMAL to VARCHAR
    -- shipping_address_state: from DECIMAL to VARCHAR
    -- shipping_carrier: from DECIMAL to VARCHAR
    -- shipping_name: from DECIMAL to VARCHAR
    -- shipping_phone: from DECIMAL to VARCHAR
    -- shipping_tracking_number: from DECIMAL to VARCHAR
    -- tax_id: from DECIMAL to VARCHAR
    -- tax_info_type: from DECIMAL to VARCHAR
    -- tax_verification_status: from DECIMAL to VARCHAR
    -- tax_verified_name: from DECIMAL to VARCHAR
    SELECT
        "customer_id",
        "bank_account_id",
        "is_delinquent",
        "invoice_prefix",
        "is_deleted",
        "is_live_mode",
        "hashed_customer_name",
        "tax_exempt_status",
        CAST("account_balance" AS DECIMAL) AS "account_balance",
        CAST("account_creation_date" AS TIMESTAMP) AS "account_creation_date",
        CAST("address_city" AS VARCHAR) AS "address_city",
        CAST("address_country" AS VARCHAR) AS "address_country",
        CAST("address_line_1" AS VARCHAR) AS "address_line_1",
        CAST("address_line_2" AS VARCHAR) AS "address_line_2",
        CAST("address_postal_code" AS VARCHAR) AS "address_postal_code",
        CAST("address_state" AS VARCHAR) AS "address_state",
        CAST("balance" AS DECIMAL) AS "balance",
        CAST("currency" AS VARCHAR) AS "currency",
        CAST("customer_data_source_id" AS VARCHAR) AS "customer_data_source_id",
        CAST("customer_description" AS VARCHAR) AS "customer_description",
        CAST("default_card_id" AS VARCHAR) AS "default_card_id",
        CAST("default_invoice_payment_method" AS VARCHAR) AS "default_invoice_payment_method",
        CAST("email" AS VARCHAR) AS "email",
        CAST("invoice_footer" AS VARCHAR) AS "invoice_footer",
        CAST("phone" AS VARCHAR) AS "phone",
        CAST("shipping_address_city" AS VARCHAR) AS "shipping_address_city",
        CAST("shipping_address_country" AS VARCHAR) AS "shipping_address_country",
        CAST("shipping_address_line_1" AS VARCHAR) AS "shipping_address_line_1",
        CAST("shipping_address_line_2" AS VARCHAR) AS "shipping_address_line_2",
        CAST("shipping_address_postal_code" AS VARCHAR) AS "shipping_address_postal_code",
        CAST("shipping_address_state" AS VARCHAR) AS "shipping_address_state",
        CAST("shipping_carrier" AS VARCHAR) AS "shipping_carrier",
        CAST("shipping_name" AS VARCHAR) AS "shipping_name",
        CAST("shipping_phone" AS VARCHAR) AS "shipping_phone",
        CAST("shipping_tracking_number" AS VARCHAR) AS "shipping_tracking_number",
        CAST("tax_id" AS VARCHAR) AS "tax_id",
        CAST("tax_info_type" AS VARCHAR) AS "tax_info_type",
        CAST("tax_verification_status" AS VARCHAR) AS "tax_verification_status",
        CAST("tax_verified_name" AS VARCHAR) AS "tax_verified_name"
    FROM "customer_data_projected_renamed"
),

"customer_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 19 columns with unacceptable missing values
    -- address_city has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- address_country has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- address_line_1 has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- address_line_2 has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- address_postal_code has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- address_state has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- bank_account_id has 91.67 percent missing. Strategy: 🗑️ Drop Column
    -- currency has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- customer_data_source_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- customer_description has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- default_card_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- default_invoice_payment_method has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- email has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- invoice_footer has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- phone has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tax_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tax_info_type has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tax_verification_status has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- tax_verified_name has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "customer_id",
        "is_delinquent",
        "invoice_prefix",
        "is_deleted",
        "is_live_mode",
        "hashed_customer_name",
        "tax_exempt_status",
        "account_balance",
        "account_creation_date",
        "balance",
        "shipping_address_city",
        "shipping_address_country",
        "shipping_address_line_1",
        "shipping_address_line_2",
        "shipping_address_postal_code",
        "shipping_address_state",
        "shipping_carrier",
        "shipping_name",
        "shipping_phone",
        "shipping_tracking_number"
    FROM "customer_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "customer_data_projected_renamed_casted_missing_handled"

stg_customer_data.yml (Document the table)

version: 2
models:
- name: stg_customer_data
  description: The table is about customer information. It contains details like customer
    ID, account balance, address, email, name, phone, and shipping information. The
    table also includes payment-related data such as currency, invoice settings, and
    tax information. Each row represents a unique customer with various attributes,
    but many fields are empty in the given samples.
  columns:
  - name: customer_id
    description: Unique identifier for the customer
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each customer. For
        this table, each row represents a unique customer, and customer_id appears
        to be unique across rows.
  - name: is_delinquent
    description: Indicates if customer's account is delinquent
    tests:
    - not_null
  - name: invoice_prefix
    description: Prefix used for customer's invoices
    tests:
    - not_null
  - name: is_deleted
    description: Indicates if customer account is deleted
    tests:
    - not_null
  - name: is_live_mode
    description: Indicates if account is in live mode
    tests:
    - not_null
  - name: hashed_customer_name
    description: Customer's name (hashed for privacy)
    tests:
    - not_null
  - name: tax_exempt_status
    description: Customer's tax exemption status
    tests:
    - not_null
    - accepted_values:
        values:
        - none
        - exempt
        - partial
        - government
        - non-profit
        - educational
        - religious
        - charitable
        - military
        - diplomatic
  - name: account_balance
    description: Customer's current account balance
    tests:
    - not_null
  - name: account_creation_date
    description: Date and time when customer account was created
    tests:
    - not_null
  - name: balance
    description: Current balance of the customer's account
    tests:
    - not_null
  - name: shipping_address_city
    description: City of customer's shipping address
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
  - name: shipping_address_country
    description: Country of customer's shipping address
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
  - name: shipping_address_line_1
    description: First line of customer's shipping address
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
  - name: shipping_address_line_2
    description: Second line of customer's shipping address
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
  - name: shipping_address_postal_code
    description: Postal code of customer's shipping address
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
  - name: shipping_address_state
    description: State or province of shipping address
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
  - name: shipping_carrier
    description: Preferred shipping carrier for customer
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
  - name: shipping_name
    description: Customer's name for shipping purposes
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
  - name: shipping_phone
    description: Customer's phone number for shipping
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
  - name: shipping_tracking_number
    description: Tracking number for customer's shipment
    cocoon_meta:
      missing_acceptable: Not applicable if no shipment is involved
Some tables log change events, which may be redundant to query. Instead, we take a snapshot of the latest.

We identify the primary key (PK) and foreign key (FK) from tables. We build a join graph that connects FK to PK.

Join Graph (FK to PK)

%3 stg_refund_data stg_refund_data stg_balance_transaction_data stg_balance_transaction_data stg_refund_data->stg_balance_transaction_data stg_refund_data->stg_balance_transaction_data stg_charge_data stg_charge_data stg_refund_data->stg_charge_data stg_price_data stg_price_data stg_invoice_line_item_data stg_invoice_line_item_data stg_price_data->stg_invoice_line_item_data stg_customer_data stg_customer_data stg_payment_method_card_data stg_payment_method_card_data stg_payment_method_data stg_payment_method_data stg_payment_method_card_data->stg_payment_method_data stg_credit_note_line_item_data stg_credit_note_line_item_data stg_credit_note_line_item_data->stg_invoice_line_item_data stg_credit_note_data stg_credit_note_data stg_credit_note_line_item_data->stg_credit_note_data stg_card_data stg_card_data stg_card_data->stg_payment_method_data stg_payment_intent_data stg_payment_intent_data stg_payment_intent_data->stg_customer_data stg_payment_intent_data->stg_payment_method_data stg_payment_intent_data->stg_charge_data stg_payment_method_data->stg_customer_data stg_plan_data stg_plan_data stg_invoice_line_item_data->stg_plan_data stg_subscription_data stg_subscription_data stg_invoice_line_item_data->stg_subscription_data stg_fee_data stg_fee_data stg_fee_data->stg_balance_transaction_data stg_invoice_data stg_invoice_data stg_invoice_data->stg_customer_data stg_invoice_data->stg_invoice_line_item_data stg_invoice_data->stg_subscription_data stg_transfer_data stg_transfer_data stg_payout_data stg_payout_data stg_transfer_data->stg_payout_data stg_transfer_data->stg_balance_transaction_data stg_payout_data->stg_balance_transaction_data stg_payout_data->stg_balance_transaction_data stg_account_data stg_account_data stg_payout_data->stg_account_data stg_balance_transaction_data->stg_payout_data stg_balance_transaction_data->stg_charge_data stg_balance_transaction_data->stg_account_data stg_charge_data->stg_customer_data stg_charge_data->stg_payment_intent_data stg_subscription_history_data stg_subscription_history_data stg_subscription_history_data->stg_customer_data stg_subscription_history_data->stg_payment_method_data stg_subscription_history_data->stg_subscription_data stg_dispute_data stg_dispute_data stg_dispute_data->stg_balance_transaction_data stg_dispute_data->stg_charge_data stg_dispute_data->stg_account_data stg_credit_note_data->stg_refund_data stg_subscription_data->stg_customer_data stg_subscription_data->stg_payment_method_data

cocoon_join.yml (Document the joins)

join_graph:
- table_name: stg_customer_data
  primary_key: customer_id
  foreign_keys: []
- table_name: stg_charge_data
  foreign_keys:
  - column: customer_id
    reference:
      table_name: stg_customer_data
      column: customer_id
  - column: payment_intent_id
    reference:
      table_name: stg_payment_intent_data
      column: payment_intent_id
  primary_key: charge_id
- table_name: stg_invoice_data
  foreign_keys:
  - column: customer_id
    reference:
      table_name: stg_customer_data
      column: customer_id
  - column: line_item_id
    reference:
      table_name: stg_invoice_line_item_data
      column: line_item_id
  - column: subscription_id
    reference:
      table_name: stg_subscription_data
      column: subscription_id
- table_name: stg_payment_intent_data
  foreign_keys:
  - column: customer_id
    reference:
      table_name: stg_customer_data
      column: customer_id
  - column: error_charge_id
    reference:
      table_name: stg_charge_data
      column: charge_id
  - column: payment_method_id
    reference:
      table_name: stg_payment_method_data
      column: payment_method_id
  primary_key: payment_intent_id
- table_name: stg_payment_method_data
  foreign_keys:
  - column: customer_id
    reference:
      table_name: stg_customer_data
      column: customer_id
  primary_key: payment_method_id
- table_name: stg_subscription_history_data
  foreign_keys:
  - column: customer_id
    reference:
      table_name: stg_customer_data
      column: customer_id
  - column: subscription_id
    reference:
      table_name: stg_subscription_data
      column: subscription_id
  - column: default_payment_source_id
    reference:
      table_name: stg_payment_method_data
      column: payment_method_id
- table_name: stg_subscription_data
  foreign_keys:
  - column: customer_id
    reference:
      table_name: stg_customer_data
      column: customer_id
  - column: default_payment_source_id
    reference:
      table_name: stg_payment_method_data
      column: payment_method_id
  primary_key: subscription_id
- table_name: stg_refund_data
  primary_key: refund_id
  foreign_keys:
  - column: balance_transaction_id
    reference:
      table_name: stg_balance_transaction_data
      column: transaction_id
  - column: failure_balance_transaction_id
    reference:
      table_name: stg_balance_transaction_data
      column: transaction_id
  - column: charge_id
    reference:
      table_name: stg_charge_data
      column: charge_id
- table_name: stg_credit_note_data
  foreign_keys:
  - column: refund_id
    reference:
      table_name: stg_refund_data
      column: refund_id
  primary_key: credit_note_id
- table_name: stg_balance_transaction_data
  primary_key: transaction_id
  foreign_keys:
  - column: transaction_source_id
    reference:
      table_name: stg_charge_data
      column: charge_id
  - column: connected_account_id
    reference:
      table_name: stg_account_data
      column: account_id
  - column: payout_id
    reference:
      table_name: stg_payout_data
      column: payout_id
- table_name: stg_dispute_data
  foreign_keys:
  - column: dispute_transaction_id
    reference:
      table_name: stg_balance_transaction_data
      column: transaction_id
  - column: charge_id
    reference:
      table_name: stg_charge_data
      column: charge_id
  - column: connected_account_id
    reference:
      table_name: stg_account_data
      column: account_id
- table_name: stg_payout_data
  foreign_keys:
  - column: balance_transaction_id
    reference:
      table_name: stg_balance_transaction_data
      column: transaction_id
  - column: failure_transaction_id
    reference:
      table_name: stg_balance_transaction_data
      column: transaction_id
  - column: connected_account_id
    reference:
      table_name: stg_account_data
      column: account_id
  primary_key: payout_id
- table_name: stg_transfer_data
  foreign_keys:
  - column: balance_transaction_id
    reference:
      table_name: stg_balance_transaction_data
      column: transaction_id
  - column: payout_id
    reference:
      table_name: stg_payout_data
      column: payout_id
- table_name: stg_fee_data
  foreign_keys:
  - column: transaction_id
    reference:
      table_name: stg_balance_transaction_data
      column: transaction_id
- table_name: stg_account_data
  primary_key: account_id
  foreign_keys: []
- table_name: stg_invoice_line_item_data
  primary_key: line_item_id
  foreign_keys:
  - column: subscription_id
    reference:
      table_name: stg_subscription_data
      column: subscription_id
  - column: plan_id
    reference:
      table_name: stg_plan_data
      column: plan_id
- table_name: stg_credit_note_line_item_data
  foreign_keys:
  - column: line_item_id
    reference:
      table_name: stg_invoice_line_item_data
      column: line_item_id
  - column: credit_note_id
    reference:
      table_name: stg_credit_note_data
      column: credit_note_id
- table_name: stg_price_data
  foreign_keys:
  - column: invoice_item_id
    reference:
      table_name: stg_invoice_line_item_data
      column: line_item_id
- table_name: stg_plan_data
  primary_key: plan_id
  foreign_keys: []
- table_name: stg_card_data
  foreign_keys:
  - column: payment_method_id
    reference:
      table_name: stg_payment_method_data
      column: payment_method_id
- table_name: stg_payment_method_card_data
  foreign_keys:
  - column: payment_method_id
    reference:
      table_name: stg_payment_method_data
      column: payment_method_id
We identify the entities and relationships behind the tables, and tell the story among these relationships.

cocoon_er.yml (Document the ER model)

entities:
- entity_name: Customers
  entity_description: Represents individual customers with their personal and account
    information
  table_name: stg_customer_data
  primary_key: customer_id
- entity_name: PaymentIntents
  entity_description: Represents the intention to collect payment from a customer
  table_name: stg_payment_intent_data
  primary_key: payment_intent_id
- entity_name: Refunds
  entity_description: Represents refund transactions issued to customers
  table_name: stg_refund_data
  primary_key: refund_id
- entity_name: BalanceTransactions
  entity_description: Represents financial transactions affecting the account balance
  table_name: stg_balance_transaction_data
  primary_key: transaction_id
- entity_name: Charges
  entity_description: Represents individual charge attempts on customer payment methods
  table_name: stg_charge_data
  primary_key: charge_id
- entity_name: Account
  entity_description: Represents the Stripe business account and its settings
  table_name: stg_account_data
  primary_key: account_id
- entity_name: InvoiceLineItems
  entity_description: Represents individual line items on customer invoices
  table_name: stg_invoice_line_item_data
  primary_key: line_item_id
- entity_name: Subscriptions
  entity_description: Represents recurring payment agreements with customers
  table_name: stg_subscription_data
  primary_key: subscription_id
- entity_name: Plans
  entity_description: Represents pricing plans available for subscriptions
  table_name: stg_plan_data
  primary_key: plan_id
- entity_name: CreditNotes
  entity_description: Represents credit notes issued to customers for refunds or adjustments
  table_name: stg_credit_note_data
  primary_key: credit_note_id
- entity_name: PaymentMethods
  entity_description: Represents payment methods associated with customers
  table_name: stg_payment_method_data
  primary_key: payment_method_id
- entity_name: Payouts
  entity_description: Represents money transfers from Stripe to the connected bank
    account
  table_name: stg_payout_data
  primary_key: payout_id
relations:
- relation_name: CustomerPaymentProcessing
  relation_description: PaymentIntents are created for Customers using specific PaymentMethods,
    potentially resulting in Charges upon successful processing.
  table_name: stg_payment_intent_data
  entities:
  - PaymentIntents
  - Customers
  - Charges
  - PaymentMethods
- relation_name: RefundChargeBalanceUpdate
  relation_description: Refunds are issued against Charges and generate BalanceTransactions,
    updating the account balance for the merchant.
  table_name: stg_refund_data
  entities:
  - Refunds
  - BalanceTransactions
  - Charges
- relation_name: AccountFinancialTransactions
  relation_description: BalanceTransactions record financial activities, including
    Charges and Payouts, associated with an Account, tracking monetary movements and
    fees.
  table_name: stg_balance_transaction_data
  entities:
  - BalanceTransactions
  - Charges
  - Account
  - Payouts
- relation_name: CustomerChargeAttempts
  relation_description: Customers initiate Charges through PaymentIntents, representing
    attempted transactions that may succeed or fail.
  table_name: stg_charge_data
  entities:
  - Charges
  - Customers
  - PaymentIntents
- relation_name: SubscriptionInvoiceLineItems
  relation_description: InvoiceLineItems represent individual charges associated with
    Subscriptions, which are based on specific Plans.
  table_name: stg_invoice_line_item_data
  entities:
  - InvoiceLineItems
  - Subscriptions
  - Plans
- relation_name: CustomerSubscriptionBilling
  relation_description: Customers purchase Subscriptions, which are billed using specific
    PaymentMethods associated with the customer's account.
  table_name: stg_subscription_data
  entities:
  - Subscriptions
  - Customers
  - PaymentMethods
- relation_name: CreditNoteRefunds
  relation_description: Credit Notes are issued to customers and may be associated
    with Refunds for payments previously made.
  table_name: stg_credit_note_data
  entities:
  - CreditNotes
  - Refunds
- relation_name: CustomerPaymentMethods
  relation_description: This stores the PaymentMethods associated with Customers,
    including billing details and unique identifiers for each payment method.
  table_name: stg_payment_method_data
  entities:
  - PaymentMethods
  - Customers
- relation_name: AccountBalancePayouts
  relation_description: Payouts are financial transfers from BalanceTransactions,
    which are linked to an Account's available funds for withdrawal.
  table_name: stg_payout_data
  entities:
  - Payouts
  - BalanceTransactions
  - Account
- relation_name: CustomerInvoiceSubscriptionItems
  relation_description: Customers receive Invoices containing InvoiceLineItems, which
    are associated with Subscriptions for specific services or products.
  table_name: stg_invoice_data
  entities:
  - Customers
  - InvoiceLineItems
  - Subscriptions
- relation_name: CustomerSubscriptionBillingHistory
  relation_description: Customers purchase Subscriptions, which are billed using specific
    PaymentMethods, tracking the lifecycle from creation to cancellation.
  table_name: stg_subscription_history_data
  entities:
  - Customers
  - Subscriptions
  - PaymentMethods
- relation_name: AccountChargeDisputeFlow
  relation_description: Account initiates Charges, which generate BalanceTransactions.
    Disputes on Charges affect BalanceTransactions and Account balance.
  table_name: stg_dispute_data
  entities:
  - BalanceTransactions
  - Charges
  - Account
- relation_name: PayoutBalanceTransactions
  relation_description: Payouts are processed transactions that transfer funds to
    a bank account, each associated with a specific balance transaction.
  table_name: stg_transfer_data
  entities:
  - BalanceTransactions
  - Payouts
- relation_description: This table stores individual fee transactions, each representing
    a unique balance transaction with specific monetary and categorical details.
  table_name: stg_fee_data
  entities:
  - BalanceTransactions
- relation_name: CreditNoteLineItems
  relation_description: CreditNotes contain multiple InvoiceLineItems, representing
    individual items credited or refunded to customers.
  table_name: stg_credit_note_line_item_data
  entities:
  - InvoiceLineItems
  - CreditNotes
- relation_description: This table represents InvoiceLineItems, storing detailed pricing
    information for products or services that can be billed to customers.
  table_name: stg_price_data
  entities:
  - InvoiceLineItems
- relation_description: This table stores detailed information about various PaymentMethods
    used for transactions, including card details and processing attributes.
  table_name: stg_card_data
  entities:
  - PaymentMethods
- relation_description: This table stores credit card payment method details associated
    with unique payment method IDs for processing transactions.
  table_name: stg_payment_method_card_data
  entities:
  - PaymentMethods
story:
- relation_name: CustomerPaymentMethods
  story_line: Customers register various payment methods for future transactions.
- relation_name: CustomerSubscriptionBilling
  story_line: Customers purchase subscriptions using their registered payment methods.
- relation_name: SubscriptionInvoiceLineItems
  story_line: Subscriptions generate invoice line items based on plans.
- relation_name: CustomerInvoiceSubscriptionItems
  story_line: Customers receive invoices detailing their subscription charges.
- relation_name: CustomerPaymentProcessing
  story_line: Payment intents initiate charges using customer's payment methods.
- relation_name: CustomerChargeAttempts
  story_line: Charges are attempted through payment intents for customers.
- relation_name: AccountFinancialTransactions
  story_line: Successful charges create balance transactions in merchant's account.
- relation_name: CustomerSubscriptionBillingHistory
  story_line: System tracks subscription lifecycle from creation to cancellation.
- relation_name: RefundChargeBalanceUpdate
  story_line: Refunds reverse charges and update merchant's balance transactions.
- relation_name: CreditNoteRefunds
  story_line: Credit notes are issued for refunds on previous payments.
- relation_name: CreditNoteLineItems
  story_line: Credit notes itemize individual refunded or credited amounts.
- relation_name: AccountChargeDisputeFlow
  story_line: Disputed charges affect merchant's balance transactions and account.
- relation_name: AccountBalancePayouts
  story_line: Merchant initiates payouts from available account balance funds.
- relation_name: PayoutBalanceTransactions
  story_line: Payouts transfer funds to merchant's bank account.