diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5d5326c --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +#!bin/bash + +push: + git add . && git commit -a -m "update" && git push + +run: + dbt deps --profiles-dir=. --project-dir=. + #dbt run --profiles-dir=. --project-dir=. --full-refresh + dbt run --profiles-dir=. --project-dir=. --full-refresh --select orders + diff --git a/README.md b/README.md index 8292d5f..0444b3b 100644 --- a/README.md +++ b/README.md @@ -1 +1,19 @@ -# dbt-selly \ No newline at end of file +## Installing dbt + +1. Activate your venv and run `pip3 install dbt` +1. Copy `airbyte-normalization/sample_files/profiles.yml` over to `~/.dbt/profiles.yml` +1. Edit to configure your profiles accordingly + +## Running dbt + +1. `cd airbyte-normalization` +1. You can now run dbt commands, to check the setup is fine: `dbt debug` +1. To build the dbt tables in your warehouse: `dbt run` + +## Running dbt from Airbyte generated config + +1. You can also change directory (`cd /tmp/dev_root/workspace/1/0/normalize` for example) to one of the workspace generated by Airbyte within one of the `normalize` folder. +1. You should find `profiles.yml` and a bunch of other dbt files/folders created there. +1. To check everything is setup properly: `dbt debug --profiles-dir=$(pwd) --project-dir=$(pwd)` +1. You can modify the `.sql` files and run `dbt run --profiles-dir=$(pwd) --project-dir=$(pwd)` too +1. You can inspect compiled dbt `.sql` files before they are run in the destination engine in `normalize/build/compiled` or `normalize/build/run` folders \ No newline at end of file diff --git a/dbt_project.yml b/dbt_project.yml new file mode 100755 index 0000000..4869f0a --- /dev/null +++ b/dbt_project.yml @@ -0,0 +1,63 @@ +# This file is necessary to install dbt-utils with dbt deps +# the content will be overwritten by the transform function + +# Name your package! Package names should contain only lowercase characters +# and underscores. A good package name should reflect your organization's +# name or the intended use of these models +name: 'airbyte_utils' +version: '1.0' +config-version: 2 + +# This setting configures which "profile" dbt uses for this project. Profiles contain +# database connection information, and should be configured in the ~/.dbt/profiles.yml file +profile: 'normalize' + +# These configurations specify where dbt should look for different types of files. +# The `source-paths` config, for example, states that source models can be found +# in the "models/" directory. You probably won't need to change these! +source-paths: ["models"] +docs-paths: ["docs"] +analysis-paths: ["analysis"] +test-paths: ["tests"] +data-paths: ["data"] +macro-paths: ["macros"] + +target-path: "../build" # directory which will store compiled SQL files +log-path: "../logs" # directory which will store DBT logs +modules-path: "../dbt_modules" # directory which will store external DBT dependencies + +clean-targets: # directories to be removed by `dbt clean` + - "build" + - "dbt_modules" + +quoting: + database: true +# Temporarily disabling the behavior of the ExtendedNameTransformer on table/schema names, see (issue #1785) +# all schemas should be unquoted + schema: false + identifier: true + +# You can define configurations for models in the `source-paths` directory here. +# Using these configurations, you can enable or disable models, change how they +# are materialized, and more! +models: + airbyte_utils: + +materialized: table + generated: + airbyte_ctes: + +tags: airbyte_internal_cte + +materialized: ephemeral + airbyte_incremental: + +tags: incremental_tables + +materialized: incremental + +on_schema_change: sync_all_columns + airbyte_tables: + +tags: normalized_tables + +materialized: table + airbyte_views: + +tags: airbyte_internal_views + +materialized: view + +dispatch: + - macro_namespace: dbt_utils + search_order: ['airbyte_utils', 'dbt_utils'] diff --git a/destination_catalog.json b/destination_catalog.json new file mode 100644 index 0000000..0d9d850 --- /dev/null +++ b/destination_catalog.json @@ -0,0 +1 @@ +{"streams":[{"stream":{"name":"admin-tags","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"color":{"type":"string"},"active":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"searchString":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"cash-flows","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"hash":{"type":"string"},"user":{"type":"string"},"value":{"type":"number"},"action":{"type":"string"},"options":{"type":"string"},"category":{"type":"string"},"targetId":{"type":"string"},"createdAt":{"type":"string"},"isAudited":{"type":"boolean"},"updatedAt":{"type":"string"},"newBalance":{"type":"number"},"oldBalance":{"type":"number"},"targetType":{"type":"string"},"isProcessed":{"type":"boolean"},"processStatus":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"cities","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"code":{"type":"number"},"name":{"type":"string"},"slug":{"type":"string"},"order":{"type":"number"},"tncId":{"type":"number"},"region":{"type":"string"},"source":{"type":"string"},"tempId":{"type":"number"},"tncCode":{"type":"string"},"osirisId":{"type":"number"},"updatedAt":{"type":"string"},"searchString":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"customers","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"info":{"type":"string"},"name":{"type":"string"},"user":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"source":{"type":"string"},"location":{"type":"array"},"createdAt":{"type":"string"},"isDeleted":{"type":"boolean"},"statistic":{"type":"string"},"updatedAt":{"type":"string"},"searchString":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"districts","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"city":{"type":"string"},"code":{"type":"number"},"name":{"type":"string"},"slug":{"type":"string"},"tncId":{"type":"number"},"cityId":{"type":"number"},"source":{"type":"string"},"tncCode":{"type":"string"},"gidoCode":{"type":"number"},"osirisId":{"type":"number"},"updatedAt":{"type":"string"},"searchString":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"event-rewards","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"cash":{"type":"number"},"type":{"type":"string"},"user":{"type":"string"},"event":{"type":"string"},"status":{"type":"string"},"options":{"type":"string"},"createdAt":{"type":"string"},"updatedat":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"events","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"desc":{"type":"string"},"icon":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"cover":{"type":"string"},"endAt":{"type":"string"},"active":{"type":"boolean"},"notice":{"type":"string"},"screen":{"type":"string"},"article":{"type":"string"},"options":{"type":"string"},"startAt":{"type":"string"},"segments":{"type":"string"},"createdAt":{"type":"string"},"groupType":{"type":"string"},"suppliers":{"type":"array"},"updatedAt":{"type":"string"},"information":{"type":"array"},"displayEndAt":{"type":"string"},"isApplyForAll":{"type":"boolean"},"displayStartAt":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"inventories","json_schema":{"type":"object","properties":{"id":{"type":"string"},"_id":{"type":"string"},"code":{"type":"number"},"name":{"type":"string"},"slug":{"type":"string"},"active":{"type":"boolean"},"contact":{"type":"string"},"partner":{"type":"string"},"checksum":{"type":"string"},"location":{"type":"string"},"supplier":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"minimumValue":{"type":"number"},"searchString":{"type":"string"},"paymentMethods":{"type":"string"},"canIssueInvoice":{"type":"boolean"},"deliveryMethods":{"type":"array"},"canAutoSendEmail":{"type":"boolean"},"invoiceDeliveryMethod":{"type":"string"},"doesSupportSellyExpress":{"type":"boolean"},"priorityDeliveryServiceCodes":{"type":"array"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"membership","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"name":{"type":"string"},"color":{"type":"string"},"guide":{"type":"string"},"level":{"type":"number"},"sales":{"type":"number"},"active":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"updatedat":{"type":"string"},"transaction":{"type":"number"},"bonusPercent":{"type":"number"},"bonuspercent":{"type":"number"},"transactionMinValue":{"type":"number"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"membership-histories","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"new":{"type":"string"},"old":{"type":"string"},"type":{"type":"string"},"user":{"type":"string"},"createdAt":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"membership-orders","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"user":{"type":"string"},"status":{"type":"string"},"percent":{"type":"number"},"targetID":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"commission":{"type":"number"},"isRejected":{"type":"boolean"},"membershipName":{"type":"string"},"membershipLevel":{"type":"number"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"order-deliveries","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"code":{"type":"string"},"order":{"type":"string"},"title":{"type":"string"},"status":{"type":"string"},"service":{"type":"string"},"customer":{"type":"string"},"delivery":{"type":"string"},"location":{"type":"string"},"createdAt":{"type":"string"},"promotion":{"type":"string"},"updatedAt":{"type":"string"},"trackingCode":{"type":"string"},"trackingTime":{"type":"string"},"isAdminChange":{"type":"boolean"},"trackingOrderCode":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"order-histories","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"order":{"type":"string"},"status":{"type":"string"},"createdAt":{"type":"string"},"timestamp":{"type":"number"},"updatedAt":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"order-items","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"sku":{"type":"string"},"date":{"type":"string"},"user":{"type":"string"},"brand":{"type":"string"},"order":{"type":"string"},"price":{"type":"string"},"status":{"type":"string"},"teamId":{"type":"string"},"product":{"type":"string"},"voucher":{"type":"string"},"customer":{"type":"string"},"quantity":{"type":"number"},"createdAt":{"type":"string"},"inventory":{"type":"string"},"totalSell":{"type":"number"},"updatedAt":{"type":"string"},"cashbackAt":{"type":"string"},"promotions":{"type":"array"},"totalPrice":{"type":"number"},"deliveredAt":{"type":"string"},"teamMemberId":{"type":"string"},"isAssignCoupon":{"type":"boolean"},"totalPromotion":{"type":"number"},"inWholesaleRange":{"type":"boolean"},"voucherCashTotal":{"type":"number"},"wholesaleRangeId":{"type":"string"},"totalWholesaleBonus":{"type":"number"},"totalSellyWholesaleBonus":{"type":"number"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"orders","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"code":{"type":"string"},"date":{"type":"string"},"hour":{"type":"number"},"note":{"type":"string"},"tags":{"type":"array"},"user":{"type":"string"},"price":{"type":"string"},"banned":{"type":"boolean"},"reason":{"type":"string"},"source":{"type":"string"},"status":{"type":"string"},"teamId":{"type":"string"},"payment":{"type":"string"},"remarks":{"type":"string"},"customer":{"type":"string"},"delivery":{"type":"string"},"isCalled":{"type":"boolean"},"merchant":{"type":"string"},"pickupAt":{"type":"string"},"supplier":{"type":"string"},"createdAt":{"type":"string"},"inventory":{"type":"string"},"invoiceId":{"type":"string"},"isDeleted":{"type":"boolean"},"promotion":{"type":"string"},"requestId":{"type":"string"},"restockAt":{"type":"string"},"sendEmail":{"type":"string"},"totalItem":{"type":"number"},"updatedAt":{"type":"string"},"userAgent":{"type":"string"},"wholesale":{"type":"boolean"},"approvedAt":{"type":"string"},"cashbackAt":{"type":"string"},"isPreorder":{"type":"boolean"},"isReviewed":{"type":"boolean"},"rejectedAt":{"type":"string"},"deliveredAt":{"type":"string"},"deliveringAt":{"type":"string"},"deliveryCode":{"type":"string"},"searchString":{"type":"string"},"staffApprove":{"type":"string"},"teamMemberId":{"type":"string"},"processStatus":{"type":"string"},"hookTimeLastAt":{"type":"string"},"isAssignCoupon":{"type":"boolean"},"isAutoApproved":{"type":"boolean"},"outboundRequest":{"type":"string"},"trackingCodeURL":{"type":"string"},"waitingCancelBy":{"type":"string"},"isChangeDelivery":{"type":"boolean"},"estimateCashbackAt":{"type":"string"},"fromNewActiveBuyer":{"type":"boolean"},"isWaitingCancelled":{"type":"boolean"},"fromNewActiveSeller":{"type":"boolean"},"waitingCancelReason":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"product-categories","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"icon":{"type":"string"},"name":{"type":"string"},"color":{"type":"string"},"order":{"type":"number"},"active":{"type":"boolean"},"covers":{"type":"array"},"featured":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"totalProduct":{"type":"number"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"product-sku","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"sku":{"type":"string"},"info":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"brand":{"type":"string"},"cover":{"type":"string"},"price":{"type":"string"},"active":{"type":"boolean"},"author":{"type":"string"},"source":{"type":"string"},"display":{"type":"boolean"},"picture":{"type":"string"},"product":{"type":"string"},"version":{"type":"number"},"groupSku":{"type":"string"},"unitCode":{"type":"string"},"createdAt":{"type":"string"},"restockAt":{"type":"string"},"statistic":{"type":"string"},"updatedAt":{"type":"string"},"couponInfo":{"type":"string"},"properties":{"type":"array"},"canPreorder":{"type":"boolean"},"supplierSku":{"type":"string"},"isOutOfStock":{"type":"boolean"},"pricePercent":{"type":"string"},"searchString":{"type":"string"},"displayInventory":{"type":"boolean"},"showRemainingQuantity":{"type":"boolean"},"quantity_aibyte_transform":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"product-sku-versions","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"sku":{"type":"string"},"info":{"type":"string"},"name":{"type":"string"},"price":{"type":"string"},"source":{"type":"string"},"codeSku":{"type":"string"},"picture":{"type":"string"},"product":{"type":"string"},"version":{"type":"number"},"createdAt":{"type":"string"},"properties":{"type":"array"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"product-sub-categories","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"name":{"type":"string"},"order":{"type":"number"},"active":{"type":"boolean"},"parent":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"searchString":{"type":"string"},"totalProduct":{"type":"number"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"products","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"desc":{"type":"string"},"info":{"type":"string"},"name":{"type":"string"},"temp":{"type":"string"},"brand":{"type":"string"},"order":{"type":"string"},"price":{"type":"string"},"score":{"type":"string"},"active":{"type":"boolean"},"author":{"type":"string"},"guides":{"type":"array"},"photos":{"type":"array"},"videos":{"type":"array"},"quantity":{"type":"number"},"createdAt":{"type":"string"},"documents":{"type":"array"},"shareDesc":{"type":"string"},"statistic":{"type":"string"},"updatedAt":{"type":"string"},"categories":{"type":"array"},"properties":{"type":"array"},"reActiveAt":{"type":"string"},"inventories":{"type":"array"},"isOutOfStock":{"type":"boolean"},"pricePercent":{"type":"string"},"searchString":{"type":"string"},"subCategories":{"type":"array"},"inactiveReason":{"type":"string"},"propertiesMain":{"type":"string"},"shareStatistic":{"type":"string"},"canIssueInvoice":{"type":"boolean"},"pendingInactive":{"type":"boolean"},"reviewStatistic":{"type":"string"},"pendingInactiveAt":{"type":"string"},"highlightProperties":{"type":"array"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"promotion-orders","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"user":{"type":"string"},"order":{"type":"string"},"title":{"type":"string"},"status":{"type":"string"},"supplier":{"type":"string"},"createdAt":{"type":"string"},"promotion":{"type":"string"},"updatedAt":{"type":"string"},"cashbackAt":{"type":"string"},"commission":{"type":"number"},"isRejected":{"type":"boolean"},"quantityPromotion":{"type":"number"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"promotions","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"rest":{"type":"number"},"type":{"type":"string"},"endAt":{"type":"string"},"title":{"type":"string"},"active":{"type":"boolean"},"options":{"type":"string"},"startAt":{"type":"string"},"applyFor":{"type":"string"},"quantity":{"type":"number"},"articleID":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"searchString":{"type":"string"},"sharePercent":{"type":"string"},"conditionForUser":{"type":"string"},"isUnlimitedQuantity":{"type":"boolean"},"isApplyForOrderWholesale":{"type":"boolean"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"referrals","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"user":{"type":"string"},"invitee":{"type":"string"},"createdAt":{"type":"string"},"fromSystem":{"type":"boolean"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"suppliers","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"tax":{"type":"string"},"bank":{"type":"string"},"logo":{"type":"string"},"name":{"type":"string"},"active":{"type":"boolean"},"checkSum":{"type":"string"},"checksum":{"type":"string"},"location":{"type":"string"},"contracts":{"type":"array"},"createdAt":{"type":"string"},"documents":{"type":"array"},"statistic":{"type":"string"},"updatedAt":{"type":"string"},"categories":{"type":"array"},"inventories":{"type":"array"},"identifyCode":{"type":"number"},"searchString":{"type":"string"},"contractNumber":{"type":"string"},"reviewStatistic":{"type":"string"},"contractSignedAt":{"type":"string"},"emailForInvoices":{"type":"array"},"contractExpiredAt":{"type":"string"},"sendInvoiceRequestEveryDay":{"type":"boolean"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"team-activities","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"team":{"type":"string"},"action":{"type":"string"},"options":{"type":"string"},"targetId":{"type":"string"},"createdAt":{"type":"string"},"createdBy":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"team-bonus","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"team":{"type":"string"},"user":{"type":"string"},"status":{"type":"string"},"percent":{"type":"number"},"targetId":{"type":"string"},"teamName":{"type":"string"},"createdAt":{"type":"string"},"teamLevel":{"type":"number"},"updatedAt":{"type":"string"},"commission":{"type":"number"},"teamMember":{"type":"string"},"teamPromotion":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"team-members","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"role":{"type":"string"},"team":{"type":"string"},"user":{"type":"string"},"isLeft":{"type":"boolean"},"leftAt":{"type":"string"},"joinedAt":{"type":"string"},"roleCode":{"type":"number"},"createdAt":{"type":"string"},"statistic":{"type":"string"},"updatedAt":{"type":"string"},"isRemovedBy":{"type":"string"},"firstOrderAt":{"type":"string"},"searchString":{"type":"string"},"isMemberHomegrown":{"type":"boolean"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"teams","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"code":{"type":"string"},"desc":{"type":"string"},"logo":{"type":"string"},"name":{"type":"string"},"level":{"type":"string"},"active":{"type":"boolean"},"isFull":{"type":"boolean"},"cityCode":{"type":"number"},"adminUser":{"type":"string"},"createdAt":{"type":"string"},"statistic":{"type":"string"},"updatedAt":{"type":"string"},"inviteLink":{"type":"string"},"information":{"type":"string"},"searchString":{"type":"string"},"inactiveReason":{"type":"string"},"changingNameCount":{"type":"number"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"user-identifications","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"dob":{"type":"string"},"name":{"type":"string"},"note":{"type":"string"},"type":{"type":"string"},"user":{"type":"string"},"gender":{"type":"string"},"nation":{"type":"string"},"number":{"type":"string"},"status":{"type":"string"},"address":{"type":"string"},"dobDate":{"type":"string"},"backSide":{"type":"string"},"birthday":{"type":"string"},"createdAt":{"type":"string"},"frontSide":{"type":"string"},"issueDate":{"type":"string"},"updatedAt":{"type":"string"},"expiryDate":{"type":"string"},"issuePlace":{"type":"string"},"timeUpdate":{"type":"number"},"detectInformation":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"users","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"code":{"type":"string"},"info":{"type":"string"},"name":{"type":"string"},"team":{"type":"string"},"zalo":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"avatar":{"type":"string"},"banned":{"type":"boolean"},"segment":{"type":"string"},"facebook":{"type":"string"},"hasOrder":{"type":"boolean"},"referral":{"type":"string"},"segments":{"type":"array"},"createdAt":{"type":"string"},"statistic":{"type":"string"},"updatedAt":{"type":"string"},"membership":{"type":"string"},"lastOrderAt":{"type":"string"},"firstOrderAt":{"type":"string"},"registerFrom":{"type":"string"},"searchString":{"type":"string"},"adjustTracker":{"type":"string"},"isUpdatedInfo":{"type":"boolean"},"identification":{"type":"string"},"lastActivatedAt":{"type":"string"},"lastViewNotificationAt":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]},{"stream":{"name":"wards","json_schema":{"type":"object","properties":{"_id":{"type":"string"},"city":{"type":"string"},"code":{"type":"number"},"name":{"type":"string"},"slug":{"type":"string"},"tncId":{"type":"number"},"cityId":{"type":"number"},"source":{"type":"string"},"tncCode":{"type":"string"},"district":{"type":"string"},"gidoCode":{"type":"number"},"osirisId":{"type":"number"},"updatedAt":{"type":"string"},"districtId":{"type":"number"},"provinceId":{"type":"number"},"searchString":{"type":"string"}}},"supported_sync_modes":["full_refresh","incremental"],"default_cursor_field":[],"source_defined_primary_key":[],"namespace":"unibag"},"sync_mode":"full_refresh","cursor_field":[],"destination_sync_mode":"overwrite","primary_key":[]}]} \ No newline at end of file diff --git a/destination_config.json b/destination_config.json new file mode 100644 index 0000000..97b5347 --- /dev/null +++ b/destination_config.json @@ -0,0 +1 @@ +{"ssl":false,"host":"localhost","port":5555,"schema":"public","database":"selly_etl","password":"123","username":"selly","tunnel_method":{"tunnel_method":"NO_TUNNEL"}} \ No newline at end of file diff --git a/macros/cross_db_utils/array.sql b/macros/cross_db_utils/array.sql new file mode 100644 index 0000000..4bc642f --- /dev/null +++ b/macros/cross_db_utils/array.sql @@ -0,0 +1,166 @@ +{# + Adapter Macros for the following functions: + - Bigquery: unnest() -> https://cloud.google.com/bigquery/docs/reference/standard-sql/arrays#flattening-arrays-and-repeated-fields + - Snowflake: flatten() -> https://docs.snowflake.com/en/sql-reference/functions/flatten.html + - Redshift: -> https://blog.getdbt.com/how-to-unnest-arrays-in-redshift/ + - postgres: unnest() -> https://www.postgresqltutorial.com/postgresql-array/ + - MSSQL: openjson() –> https://docs.microsoft.com/en-us/sql/relational-databases/json/validate-query-and-change-json-data-with-built-in-functions-sql-server?view=sql-server-ver15 +#} + +{# cross_join_unnest ------------------------------------------------- #} + +{% macro cross_join_unnest(stream_name, array_col) -%} + {{ adapter.dispatch('cross_join_unnest')(stream_name, array_col) }} +{%- endmacro %} + +{% macro default__cross_join_unnest(stream_name, array_col) -%} + {% do exceptions.warn("Undefined macro cross_join_unnest for this destination engine") %} +{%- endmacro %} + +{% macro bigquery__cross_join_unnest(stream_name, array_col) -%} + cross join unnest({{ array_col }}) as {{ array_col }} +{%- endmacro %} + +{% macro oracle__cross_join_unnest(stream_name, array_col) -%} + {% do exceptions.warn("Normalization does not support unnesting for Oracle yet.") %} +{%- endmacro %} + +{% macro postgres__cross_join_unnest(stream_name, array_col) -%} + cross join jsonb_array_elements( + case jsonb_typeof({{ array_col }}) + when 'array' then {{ array_col }} + else '[]' end + ) as _airbyte_nested_data +{%- endmacro %} + +{% macro mysql__cross_join_unnest(stream_name, array_col) -%} + left join joined on _airbyte_{{ stream_name }}_hashid = joined._airbyte_hashid +{%- endmacro %} + +{% macro redshift__cross_join_unnest(stream_name, array_col) -%} + left join joined on _airbyte_{{ stream_name }}_hashid = joined._airbyte_hashid +{%- endmacro %} + +{% macro snowflake__cross_join_unnest(stream_name, array_col) -%} + cross join table(flatten({{ array_col }})) as {{ array_col }} +{%- endmacro %} + +{% macro sqlserver__cross_join_unnest(stream_name, array_col) -%} +{# https://docs.microsoft.com/en-us/sql/relational-databases/json/convert-json-data-to-rows-and-columns-with-openjson-sql-server?view=sql-server-ver15#option-1---openjson-with-the-default-output #} + CROSS APPLY ( + SELECT [value] = CASE + WHEN [type] = 4 THEN (SELECT [value] FROM OPENJSON([value])) + WHEN [type] = 5 THEN [value] + END + FROM OPENJSON({{ array_col }}) + ) AS {{ array_col }} +{%- endmacro %} + +{# unnested_column_value -- this macro is related to unnest_cte #} + +{% macro unnested_column_value(column_col) -%} + {{ adapter.dispatch('unnested_column_value')(column_col) }} +{%- endmacro %} + +{% macro default__unnested_column_value(column_col) -%} + {{ column_col }} +{%- endmacro %} + +{% macro postgres__unnested_column_value(column_col) -%} + _airbyte_nested_data +{%- endmacro %} + +{% macro snowflake__unnested_column_value(column_col) -%} + {{ column_col }}.value +{%- endmacro %} + +{% macro redshift__unnested_column_value(column_col) -%} + _airbyte_nested_data +{%- endmacro %} + +{% macro mysql__unnested_column_value(column_col) -%} + _airbyte_nested_data +{%- endmacro %} + +{% macro oracle__unnested_column_value(column_col) -%} + {{ column_col }} +{%- endmacro %} + +{% macro sqlserver__unnested_column_value(column_col) -%} + {# unnested array/sub_array will be located in `value` column afterwards, we need to address to it #} + {{ column_col }}.value +{%- endmacro %} + +{# unnest_cte ------------------------------------------------- #} + +{% macro unnest_cte(from_table, stream_name, column_col) -%} + {{ adapter.dispatch('unnest_cte')(from_table, stream_name, column_col) }} +{%- endmacro %} + +{% macro default__unnest_cte(from_table, stream_name, column_col) -%}{%- endmacro %} + +{# -- based on https://blog.getdbt.com/how-to-unnest-arrays-in-redshift/ #} +{% macro redshift__unnest_cte(from_table, stream_name, column_col) -%} + {%- if not execute -%} + {{ return('') }} + {% endif %} + {%- call statement('max_json_array_length', fetch_result=True) -%} + with max_value as ( + select max(json_array_length({{ column_col }}, true)) as max_number_of_items + from {{ from_table }} + ) + select + case when max_number_of_items is not null and max_number_of_items > 1 + then max_number_of_items + else 1 end as max_number_of_items + from max_value + {%- endcall -%} + {%- set max_length = load_result('max_json_array_length') -%} +with numbers as ( + {{dbt_utils.generate_series(max_length["data"][0][0])}} +), +joined as ( + select + _airbyte_{{ stream_name }}_hashid as _airbyte_hashid, + json_extract_array_element_text({{ column_col }}, numbers.generated_number::int - 1, true) as _airbyte_nested_data + from {{ from_table }} + cross join numbers + -- only generate the number of records in the cross join that corresponds + -- to the number of items in {{ from_table }}.{{ column_col }} + where numbers.generated_number <= json_array_length({{ column_col }}, true) +) +{%- endmacro %} + +{% macro mysql__unnest_cte(from_table, stream_name, column_col) -%} + {%- if not execute -%} + {{ return('') }} + {% endif %} + + {%- call statement('max_json_array_length', fetch_result=True) -%} + with max_value as ( + select max(json_length({{ column_col }})) as max_number_of_items + from {{ from_table }} + ) + select + case when max_number_of_items is not null and max_number_of_items > 1 + then max_number_of_items + else 1 end as max_number_of_items + from max_value + {%- endcall -%} + + {%- set max_length = load_result('max_json_array_length') -%} + with numbers as ( + {{ dbt_utils.generate_series(max_length["data"][0][0]) }} + ), + joined as ( + select + _airbyte_{{ stream_name }}_hashid as _airbyte_hashid, + {# -- json_extract(column_col, '$[i][0]') as _airbyte_nested_data #} + json_extract({{ column_col }}, concat("$[", numbers.generated_number - 1, "][0]")) as _airbyte_nested_data + from {{ from_table }} + cross join numbers + -- only generate the number of records in the cross join that corresponds + -- to the number of items in {{ from_table }}.{{ column_col }} + where numbers.generated_number <= json_length({{ column_col }}) + ) +{%- endmacro %} diff --git a/macros/cross_db_utils/concat.sql b/macros/cross_db_utils/concat.sql new file mode 100644 index 0000000..536cebc --- /dev/null +++ b/macros/cross_db_utils/concat.sql @@ -0,0 +1,23 @@ +{# + concat in dbt 0.6.4 used to work fine for bigquery but the new implementaion in 0.7.3 is less scalable (can not handle too many columns) + Therefore, we revert the implementation here and add versions for missing destinations +#} + +{% macro concat(fields) -%} + {{ adapter.dispatch('concat')(fields) }} +{%- endmacro %} + +{% macro bigquery__concat(fields) -%} + {#-- concat() in SQL bigquery scales better with number of columns than using the '||' operator --#} + concat({{ fields|join(', ') }}) +{%- endmacro %} + +{% macro sqlserver__concat(fields) -%} + {#-- CONCAT() in SQL SERVER accepts from 2 to 254 arguments, we use batches for the main concat, to overcome the limit. --#} + {% set concat_chunks = [] %} + {% for chunk in fields|batch(253) -%} + {% set _ = concat_chunks.append( "concat(" ~ chunk|join(', ') ~ ",'')" ) %} + {% endfor %} + + concat({{ concat_chunks|join(', ') }}, '') +{%- endmacro %} diff --git a/macros/cross_db_utils/current_timestamp.sql b/macros/cross_db_utils/current_timestamp.sql new file mode 100644 index 0000000..a9df34c --- /dev/null +++ b/macros/cross_db_utils/current_timestamp.sql @@ -0,0 +1,7 @@ +{% macro mysql__current_timestamp() %} + CURRENT_TIMESTAMP +{% endmacro %} + +{% macro oracle__current_timestamp() %} + CURRENT_TIMESTAMP +{% endmacro %} diff --git a/macros/cross_db_utils/datatypes.sql b/macros/cross_db_utils/datatypes.sql new file mode 100644 index 0000000..080aea5 --- /dev/null +++ b/macros/cross_db_utils/datatypes.sql @@ -0,0 +1,181 @@ +{# json ------------------------------------------------- #} + +{%- macro type_json() -%} + {{ adapter.dispatch('type_json')() }} +{%- endmacro -%} + +{% macro default__type_json() %} + string +{% endmacro %} + +{%- macro redshift__type_json() -%} + varchar +{%- endmacro -%} + +{% macro postgres__type_json() %} + jsonb +{% endmacro %} + +{%- macro oracle__type_json() -%} + varchar2(4000) +{%- endmacro -%} + +{% macro snowflake__type_json() %} + variant +{% endmacro %} + +{%- macro mysql__type_json() -%} + json +{%- endmacro -%} + +{%- macro sqlserver__type_json() -%} + VARCHAR(max) +{%- endmacro -%} + +{% macro clickhouse__type_json() %} + String +{% endmacro %} + + +{# string ------------------------------------------------- #} + +{%- macro mysql__type_string() -%} + char +{%- endmacro -%} + +{%- macro oracle__type_string() -%} + varchar2(4000) +{%- endmacro -%} + +{% macro sqlserver__type_string() %} + VARCHAR(max) +{%- endmacro -%} + +{%- macro clickhouse__type_string() -%} + String +{%- endmacro -%} + + +{# float ------------------------------------------------- #} +{% macro mysql__type_float() %} + float +{% endmacro %} + +{% macro oracle__type_float() %} + float +{% endmacro %} + +{% macro clickhouse__type_float() %} + Float64 +{% endmacro %} + + +{# int ------------------------------------------------- #} +{% macro default__type_int() %} + signed +{% endmacro %} + +{% macro oracle__type_int() %} + int +{% endmacro %} + +{% macro clickhouse__type_int() %} + INT +{% endmacro %} + + +{# bigint ------------------------------------------------- #} +{% macro mysql__type_bigint() %} + signed +{% endmacro %} + +{% macro oracle__type_bigint() %} + numeric +{% endmacro %} + +{% macro clickhouse__type_bigint() %} + BIGINT +{% endmacro %} + + +{# numeric ------------------------------------------------- --#} +{% macro mysql__type_numeric() %} + float +{% endmacro %} + +{% macro clickhouse__type_numeric() %} + Float64 +{% endmacro %} + + +{# timestamp ------------------------------------------------- --#} +{% macro mysql__type_timestamp() %} + time +{% endmacro %} + +{%- macro sqlserver__type_timestamp() -%} + {#-- in TSQL timestamp is really datetime --#} + {#-- https://docs.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver15#DateandTimeDataTypes --#} + datetime +{%- endmacro -%} + +{% macro clickhouse__type_timestamp() %} + DateTime64 +{% endmacro %} + + +{# timestamp with time zone ------------------------------------------------- #} + +{%- macro type_timestamp_with_timezone() -%} + {{ adapter.dispatch('type_timestamp_with_timezone')() }} +{%- endmacro -%} + +{% macro default__type_timestamp_with_timezone() %} + timestamp with time zone +{% endmacro %} + +{% macro bigquery__type_timestamp_with_timezone() %} + timestamp +{% endmacro %} + +{#-- MySQL doesnt allow cast operation to work with TIMESTAMP so we have to use char --#} +{%- macro mysql__type_timestamp_with_timezone() -%} + char +{%- endmacro -%} + +{% macro oracle__type_timestamp_with_timezone() %} + varchar2(4000) +{% endmacro %} + +{%- macro sqlserver__type_timestamp_with_timezone() -%} + {#-- in TSQL timestamp is really datetime or datetime2 --#} + {#-- https://docs.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver15#DateandTimeDataTypes --#} + datetime +{%- endmacro -%} + +{% macro clickhouse__type_timestamp_with_timezone() %} + DateTime64 +{% endmacro %} + + +{# date ------------------------------------------------- #} + +{%- macro type_date() -%} + {{ adapter.dispatch('type_date')() }} +{%- endmacro -%} + +{% macro default__type_date() %} + date +{% endmacro %} + +{% macro oracle__type_date() %} + varchar2(4000) +{% endmacro %} + +{%- macro sqlserver__type_date() -%} + date +{%- endmacro -%} + +{% macro clickhouse__type_date() %} + Date +{% endmacro %} diff --git a/macros/cross_db_utils/except.sql b/macros/cross_db_utils/except.sql new file mode 100644 index 0000000..a0f0c15 --- /dev/null +++ b/macros/cross_db_utils/except.sql @@ -0,0 +1,7 @@ +{% macro mysql__except() %} + {% do exceptions.warn("MySQL does not support EXCEPT operator") %} +{% endmacro %} + +{% macro oracle__except() %} + minus +{% endmacro %} diff --git a/macros/cross_db_utils/hash.sql b/macros/cross_db_utils/hash.sql new file mode 100644 index 0000000..1848887 --- /dev/null +++ b/macros/cross_db_utils/hash.sql @@ -0,0 +1,5 @@ +{# converting hash in varchar _macro #} + +{% macro sqlserver__hash(field) -%} + convert(varchar(32), HashBytes('md5', coalesce(cast({{field}} as {{dbt_utils.type_string()}}), '')), 2) +{%- endmacro %} \ No newline at end of file diff --git a/macros/cross_db_utils/json_operations.sql b/macros/cross_db_utils/json_operations.sql new file mode 100644 index 0000000..619eaf4 --- /dev/null +++ b/macros/cross_db_utils/json_operations.sql @@ -0,0 +1,226 @@ +{# + Adapter Macros for the following functions: + - Bigquery: JSON_EXTRACT(json_string_expr, json_path_format) -> https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions + - Snowflake: JSON_EXTRACT_PATH_TEXT( , '' ) -> https://docs.snowflake.com/en/sql-reference/functions/json_extract_path_text.html + - Redshift: json_extract_path_text('json_string', 'path_elem' [,'path_elem'[, ...] ] [, null_if_invalid ] ) -> https://docs.aws.amazon.com/redshift/latest/dg/JSON_EXTRACT_PATH_TEXT.html + - Postgres: json_extract_path_text(, 'path' [, 'path' [, ...}}) -> https://www.postgresql.org/docs/12/functions-json.html + - MySQL: JSON_EXTRACT(json_doc, 'path' [, 'path'] ...) -> https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html + - ClickHouse: JSONExtractString(json_doc, 'path' [, 'path'] ...) -> https://clickhouse.com/docs/en/sql-reference/functions/json-functions/ +#} + +{# format_json_path -------------------------------------------------- #} +{% macro format_json_path(json_path_list) -%} + {{ adapter.dispatch('format_json_path')(json_path_list) }} +{%- endmacro %} + +{% macro default__format_json_path(json_path_list) -%} + {{ '.' ~ json_path_list|join('.') }} +{%- endmacro %} + +{% macro oracle__format_json_path(json_path_list) -%} + {{ '\'$."' ~ json_path_list|join('."') ~ '"\'' }} +{%- endmacro %} + +{% macro bigquery__format_json_path(json_path_list) -%} + {%- set str_list = [] -%} + {%- for json_path in json_path_list -%} + {%- if str_list.append(json_path.replace('"', '\\"')) -%} {%- endif -%} + {%- endfor -%} + {{ '"$[\'' ~ str_list|join('\'][\'') ~ '\']"' }} +{%- endmacro %} + +{% macro postgres__format_json_path(json_path_list) -%} + {%- set str_list = [] -%} + {%- for json_path in json_path_list -%} + {%- if str_list.append(json_path.replace("'", "''")) -%} {%- endif -%} + {%- endfor -%} + {{ "'" ~ str_list|join("','") ~ "'" }} +{%- endmacro %} + +{% macro mysql__format_json_path(json_path_list) -%} + {# -- '$."x"."y"."z"' #} + {{ "'$.\"" ~ json_path_list|join(".") ~ "\"'" }} +{%- endmacro %} + +{% macro redshift__format_json_path(json_path_list) -%} + {%- set str_list = [] -%} + {%- for json_path in json_path_list -%} + {%- if str_list.append(json_path.replace("'", "''")) -%} {%- endif -%} + {%- endfor -%} + {{ "'" ~ str_list|join("','") ~ "'" }} +{%- endmacro %} + +{% macro snowflake__format_json_path(json_path_list) -%} + {%- set str_list = [] -%} + {%- for json_path in json_path_list -%} + {%- if str_list.append(json_path.replace("'", "''").replace('"', '""')) -%} {%- endif -%} + {%- endfor -%} + {{ "'\"" ~ str_list|join('"."') ~ "\"'" }} +{%- endmacro %} + +{% macro sqlserver__format_json_path(json_path_list) -%} + {# -- '$."x"."y"."z"' #} + {%- set str_list = [] -%} + {%- for json_path in json_path_list -%} + {%- if str_list.append(json_path.replace("'", "''").replace('"', '\\"')) -%} {%- endif -%} + {%- endfor -%} + {{ "'$.\"" ~ str_list|join(".") ~ "\"'" }} +{%- endmacro %} + +{% macro clickhouse__format_json_path(json_path_list) -%} + {%- set str_list = [] -%} + {%- for json_path in json_path_list -%} + {%- if str_list.append(json_path.replace("'", "''").replace('"', '\\"')) -%} {%- endif -%} + {%- endfor -%} + {{ "'" ~ str_list|join("','") ~ "'" }} +{%- endmacro %} + +{# json_extract ------------------------------------------------- #} + +{% macro json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + {{ adapter.dispatch('json_extract')(from_table, json_column, json_path_list, normalized_json_path) }} +{%- endmacro %} + +{% macro default__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + json_extract({{ from_table}}.{{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{% macro oracle__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + json_value({{ json_column }}, {{ format_json_path(normalized_json_path) }}) +{%- endmacro %} + +{% macro bigquery__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + {%- if from_table|string() == '' %} + json_extract({{ json_column }}, {{ format_json_path(normalized_json_path) }}) + {% else %} + json_extract({{ from_table}}.{{ json_column }}, {{ format_json_path(normalized_json_path) }}) + {% endif -%} +{%- endmacro %} + +{% macro postgres__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + {%- if from_table|string() == '' %} + jsonb_extract_path({{ json_column }}, {{ format_json_path(json_path_list) }}) + {% else %} + jsonb_extract_path({{ from_table }}.{{ json_column }}, {{ format_json_path(json_path_list) }}) + {% endif -%} +{%- endmacro %} + +{% macro mysql__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + {%- if from_table|string() == '' %} + json_extract({{ json_column }}, {{ format_json_path(normalized_json_path) }}) + {% else %} + json_extract({{ from_table }}.{{ json_column }}, {{ format_json_path(normalized_json_path) }}) + {% endif -%} +{%- endmacro %} + +{% macro redshift__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + {%- if from_table|string() == '' %} + case when json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true) != '' then json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true) end + {% else %} + case when json_extract_path_text({{ from_table }}.{{ json_column }}, {{ format_json_path(json_path_list) }}, true) != '' then json_extract_path_text({{ from_table }}.{{ json_column }}, {{ format_json_path(json_path_list) }}, true) end + {% endif -%} +{%- endmacro %} + +{% macro snowflake__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + {%- if from_table|string() == '' %} + get_path(parse_json({{ json_column }}), {{ format_json_path(json_path_list) }}) + {% else %} + get_path(parse_json({{ from_table }}.{{ json_column }}), {{ format_json_path(json_path_list) }}) + {% endif -%} +{%- endmacro %} + +{% macro sqlserver__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + json_query({{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{% macro clickhouse__json_extract(from_table, json_column, json_path_list, normalized_json_path) -%} + {%- if from_table|string() == '' %} + JSONExtractRaw({{ json_column }}, {{ format_json_path(json_path_list) }}) + {% else %} + JSONExtractRaw({{ from_table }}.{{ json_column }}, {{ format_json_path(json_path_list) }}) + {% endif -%} +{%- endmacro %} + +{# json_extract_scalar ------------------------------------------------- #} + +{% macro json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + {{ adapter.dispatch('json_extract_scalar')(json_column, json_path_list, normalized_json_path) }} +{%- endmacro %} + +{% macro default__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + json_extract_scalar({{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{% macro oracle__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + json_value({{ json_column }}, {{ format_json_path(normalized_json_path) }}) +{%- endmacro %} + +{% macro bigquery__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + json_extract_scalar({{ json_column }}, {{ format_json_path(normalized_json_path) }}) +{%- endmacro %} + +{% macro postgres__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + jsonb_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{% macro mysql__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + json_value({{ json_column }}, {{ format_json_path(normalized_json_path) }}) +{%- endmacro %} + +{% macro redshift__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + case when json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true) != '' then json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true) end +{%- endmacro %} + +{% macro snowflake__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + to_varchar(get_path(parse_json({{ json_column }}), {{ format_json_path(json_path_list) }})) +{%- endmacro %} + +{% macro sqlserver__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + json_value({{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{% macro clickhouse__json_extract_scalar(json_column, json_path_list, normalized_json_path) -%} + JSONExtractRaw({{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{# json_extract_array ------------------------------------------------- #} + +{% macro json_extract_array(json_column, json_path_list, normalized_json_path) -%} + {{ adapter.dispatch('json_extract_array')(json_column, json_path_list, normalized_json_path) }} +{%- endmacro %} + +{% macro default__json_extract_array(json_column, json_path_list, normalized_json_path) -%} + json_extract_array({{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{% macro oracle__json_extract_array(json_column, json_path_list, normalized_json_path) -%} + json_value({{ json_column }}, {{ format_json_path(normalized_json_path) }}) +{%- endmacro %} + +{% macro bigquery__json_extract_array(json_column, json_path_list, normalized_json_path) -%} + json_extract_array({{ json_column }}, {{ format_json_path(normalized_json_path) }}) +{%- endmacro %} + +{% macro postgres__json_extract_array(json_column, json_path_list, normalized_json_path) -%} + jsonb_extract_path({{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{% macro mysql__json_extract_array(json_column, json_path_list, normalized_json_path) -%} + json_extract({{ json_column }}, {{ format_json_path(normalized_json_path) }}) +{%- endmacro %} + +{% macro redshift__json_extract_array(json_column, json_path_list, normalized_json_path) -%} + json_extract_path_text({{ json_column }}, {{ format_json_path(json_path_list) }}, true) +{%- endmacro %} + +{% macro snowflake__json_extract_array(json_column, json_path_list, normalized_json_path) -%} + get_path(parse_json({{ json_column }}), {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{% macro sqlserver__json_extract_array(json_column, json_path_list, normalized_json_path) -%} + json_query({{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} + +{% macro clickhouse__json_extract_array(json_column, json_path_list, normalized_json_path) -%} + JSONExtractArrayRaw({{ json_column }}, {{ format_json_path(json_path_list) }}) +{%- endmacro %} diff --git a/macros/cross_db_utils/quote.sql b/macros/cross_db_utils/quote.sql new file mode 100644 index 0000000..8786249 --- /dev/null +++ b/macros/cross_db_utils/quote.sql @@ -0,0 +1,16 @@ +{# quote ---------------------------------- #} +{% macro quote(column_name) -%} + {{ adapter.dispatch('quote')(column_name) }} +{%- endmacro %} + +{% macro default__quote(column_name) -%} + adapter.quote(column_name) +{%- endmacro %} + +{% macro oracle__quote(column_name) -%} + {{ '\"' ~ column_name ~ '\"'}} +{%- endmacro %} + +{% macro clickhouse__quote(column_name) -%} + {{ '\"' ~ column_name ~ '\"'}} +{%- endmacro %} diff --git a/macros/cross_db_utils/surrogate_key.sql b/macros/cross_db_utils/surrogate_key.sql new file mode 100644 index 0000000..9de2965 --- /dev/null +++ b/macros/cross_db_utils/surrogate_key.sql @@ -0,0 +1,25 @@ +{# surrogate_key ---------------------------------- #} + +{% macro oracle__surrogate_key(field_list) -%} + ora_hash( + {%- for field in field_list %} + {% if not loop.last %} + {{ field }} || '~' || + {% else %} + {{ field }} + {% endif %} + {%- endfor %} + ) +{%- endmacro %} + +{% macro clickhouse__surrogate_key(field_list) -%} + assumeNotNull(hex(MD5( + {%- for field in field_list %} + {% if not loop.last %} + toString({{ field }}) || '~' || + {% else %} + toString({{ field }}) + {% endif %} + {%- endfor %} + ))) +{%- endmacro %} diff --git a/macros/cross_db_utils/type_conversions.sql b/macros/cross_db_utils/type_conversions.sql new file mode 100644 index 0000000..89dd68b --- /dev/null +++ b/macros/cross_db_utils/type_conversions.sql @@ -0,0 +1,67 @@ + +{# boolean_to_string ------------------------------------------------- #} +{% macro boolean_to_string(boolean_column) -%} + {{ adapter.dispatch('boolean_to_string')(boolean_column) }} +{%- endmacro %} + +{% macro default__boolean_to_string(boolean_column) -%} + {{ boolean_column }} +{%- endmacro %} + +{% macro redshift__boolean_to_string(boolean_column) -%} + case when {{ boolean_column }} then 'true' else 'false' end +{%- endmacro %} + +{# array_to_string ------------------------------------------------- #} +{% macro array_to_string(array_column) -%} + {{ adapter.dispatch('array_to_string')(array_column) }} +{%- endmacro %} + +{% macro default__array_to_string(array_column) -%} + {{ array_column }} +{%- endmacro %} + +{% macro bigquery__array_to_string(array_column) -%} + array_to_string({{ array_column }}, "|", "") +{%- endmacro %} + +{% macro oracle__array_to_string(array_column) -%} + cast({{ array_column }} as varchar2(4000)) +{%- endmacro %} + +{% macro sqlserver__array_to_string(array_column) -%} + cast({{ array_column }} as {{dbt_utils.type_string()}}) +{%- endmacro %} + +{# cast_to_boolean ------------------------------------------------- #} +{% macro cast_to_boolean(field) -%} + {{ adapter.dispatch('cast_to_boolean')(field) }} +{%- endmacro %} + +{% macro default__cast_to_boolean(field) -%} + cast({{ field }} as boolean) +{%- endmacro %} + +{# -- MySQL does not support cast function converting string directly to boolean (an alias of tinyint(1), https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_cast #} +{% macro mysql__cast_to_boolean(field) -%} + IF(lower({{ field }}) = 'true', true, false) +{%- endmacro %} + +{# -- Redshift does not support converting string directly to boolean, it must go through int first #} +{% macro redshift__cast_to_boolean(field) -%} + cast(decode({{ field }}, 'true', '1', 'false', '0')::integer as boolean) +{%- endmacro %} + +{# -- MS SQL Server does not support converting string directly to boolean, it must be casted as bit #} +{% macro sqlserver__cast_to_boolean(field) -%} + cast({{ field }} as bit) +{%- endmacro %} + +{# empty_string_to_null ------------------------------------------------- #} +{% macro empty_string_to_null(field) -%} + {{ return(adapter.dispatch('empty_string_to_null')(field)) }} +{%- endmacro %} + +{%- macro default__empty_string_to_null(field) -%} + nullif({{ field }}, '') +{%- endmacro %} diff --git a/macros/get_custom_schema.sql b/macros/get_custom_schema.sql new file mode 100644 index 0000000..77e83c7 --- /dev/null +++ b/macros/get_custom_schema.sql @@ -0,0 +1,4 @@ +-- see https://docs.getdbt.com/docs/building-a-dbt-project/building-models/using-custom-schemas/#an-alternative-pattern-for-generating-schema-names +{% macro generate_schema_name(custom_schema_name, node) -%} + {{ generate_schema_name_for_env(custom_schema_name, node) }} +{%- endmacro %} diff --git a/macros/incremental.sql b/macros/incremental.sql new file mode 100644 index 0000000..f70b479 --- /dev/null +++ b/macros/incremental.sql @@ -0,0 +1,51 @@ +{# + These macros control how incremental models are updated in Airbyte's normalization step + - get_max_normalized_cursor retrieve the value of the last normalized data + - incremental_clause controls the predicate to filter on new data to process incrementally +#} + +{% macro incremental_clause(col_emitted_at) -%} + {{ adapter.dispatch('incremental_clause')(col_emitted_at) }} +{%- endmacro %} + +{%- macro default__incremental_clause(col_emitted_at) -%} +{% if is_incremental() %} +and coalesce( + cast({{ col_emitted_at }} as {{ type_timestamp_with_timezone() }}) >= (select max(cast({{ col_emitted_at }} as {{ type_timestamp_with_timezone() }})) from {{ this }}), + {# -- if {{ col_emitted_at }} is NULL in either table, the previous comparison would evaluate to NULL, #} + {# -- so we coalesce and make sure the row is always returned for incremental processing instead #} + true) +{% endif %} +{%- endmacro -%} + +{# -- see https://on-systems.tech/113-beware-dbt-incremental-updates-against-snowflake-external-tables/ #} +{%- macro snowflake__incremental_clause(col_emitted_at) -%} +{% if is_incremental() %} + {% if get_max_normalized_cursor(col_emitted_at) %} +and cast({{ col_emitted_at }} as {{ type_timestamp_with_timezone() }}) >= + cast('{{ get_max_normalized_cursor(col_emitted_at) }}' as {{ type_timestamp_with_timezone() }}) + {% endif %} +{% endif %} +{%- endmacro -%} + +{%- macro sqlserver__incremental_clause(col_emitted_at) -%} +{% if is_incremental() %} +and ((select max(cast({{ col_emitted_at }} as {{ type_timestamp_with_timezone() }})) from {{ this }}) is null + or cast({{ col_emitted_at }} as {{ type_timestamp_with_timezone() }}) >= + (select max(cast({{ col_emitted_at }} as {{ type_timestamp_with_timezone() }})) from {{ this }})) +{% endif %} +{%- endmacro -%} + +{% macro get_max_normalized_cursor(col_emitted_at) %} +{% if execute and is_incremental() %} + {% if env_var('INCREMENTAL_CURSOR', 'UNSET') == 'UNSET' %} + {% set query %} + select max(cast({{ col_emitted_at }} as {{ type_timestamp_with_timezone() }})) from {{ this }} + {% endset %} + {% set max_cursor = run_query(query).columns[0][0] %} + {% do return(max_cursor) %} + {% else %} + {% do return(env_var('INCREMENTAL_CURSOR')) %} + {% endif %} +{% endif %} +{% endmacro %} diff --git a/macros/schema_tests/equal_rowcount.sql b/macros/schema_tests/equal_rowcount.sql new file mode 100644 index 0000000..0dd4dc6 --- /dev/null +++ b/macros/schema_tests/equal_rowcount.sql @@ -0,0 +1,34 @@ +{% macro oracle__test_equal_rowcount(model, compare_model) %} + +{#-- Needs to be set at parse time, before we return '' below --#} +{{ config(fail_calc = 'coalesce(diff_count, 0)') }} + +{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #} +{%- if not execute -%} + {{ return('') }} +{% endif %} + +with a as ( + + select count(*) as count_a from {{ model }} + +), +b as ( + + select count(*) as count_b from {{ compare_model }} + +), +final as ( + + select + count_a, + count_b, + abs(count_a - count_b) as diff_count + from a + cross join b + +) + +select diff_count from final + +{% endmacro %} diff --git a/macros/schema_tests/equality.sql b/macros/schema_tests/equality.sql new file mode 100644 index 0000000..ef83a02 --- /dev/null +++ b/macros/schema_tests/equality.sql @@ -0,0 +1,107 @@ +{# +-- Adapted from https://github.com/dbt-labs/dbt-utils/blob/0-19-0-updates/macros/schema_tests/equality.sql +-- dbt-utils version: 0.6.4 +-- This macro needs to be updated accordingly when dbt-utils is upgraded. +-- This is needed because MySQL does not support the EXCEPT operator! +#} + +{% macro mysql__test_equality(model, compare_model, compare_columns=None) %} + + {%- if not execute -%} + {{ return('') }} + {% endif %} + + {%- do dbt_utils._is_relation(model, 'test_equality') -%} + + {%- if not compare_columns -%} + {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%} + {%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') -%} + {%- endif -%} + + {% set compare_cols_csv = compare_columns | join(', ') %} + + with a as ( + select * from {{ model }} + ), + + b as ( + select * from {{ compare_model }} + ), + + a_minus_b as ( + select {{ compare_cols_csv }} from a + where ({{ compare_cols_csv }}) not in + (select {{ compare_cols_csv }} from b) + ), + + b_minus_a as ( + select {{ compare_cols_csv }} from b + where ({{ compare_cols_csv }}) not in + (select {{ compare_cols_csv }} from a) + ), + + unioned as ( + select * from a_minus_b + union all + select * from b_minus_a + ), + + final as ( + select (select count(*) from unioned) + + (select abs( + (select count(*) from a_minus_b) - + (select count(*) from b_minus_a) + )) + as count + ) + + select count from final + +{% endmacro %} + +{% macro oracle__test_equality(model) %} + {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #} + {%- if not execute -%} + {{ return('') }} + {% endif %} + + -- setup + {%- do dbt_utils._is_relation(model, 'test_equality') -%} + + {#- + If the compare_cols arg is provided, we can run this test without querying the + information schema — this allows the model to be an ephemeral model + -#} + {%- set compare_columns = kwargs.get('compare_columns', None) -%} + + {%- if not compare_columns -%} + {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%} + {%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') -%} + {%- endif -%} + + {% set compare_model = kwargs.get('compare_model', kwargs.get('arg')) %} + {% set compare_cols_csv = compare_columns | join(', ') %} + + with a as ( + select * from {{ model }} + ), + b as ( + select * from {{ compare_model }} + ), + a_minus_b as ( + select {{compare_cols_csv}} from a + {{ dbt_utils.except() }} + select {{compare_cols_csv}} from b + ), + b_minus_a as ( + select {{compare_cols_csv}} from b + {{ dbt_utils.except() }} + select {{compare_cols_csv}} from a + ), + unioned as ( + select * from a_minus_b + union all + select * from b_minus_a + ) + select count(*) from unioned +{% endmacro %} diff --git a/macros/should_full_refresh.sql b/macros/should_full_refresh.sql new file mode 100644 index 0000000..ff2c6d5 --- /dev/null +++ b/macros/should_full_refresh.sql @@ -0,0 +1,51 @@ +{# + This overrides the behavior of the macro `should_full_refresh` so full refresh are triggered if: + - the dbt cli is run with --full-refresh flag or the model is configured explicitly to full_refresh + - the column _airbyte_ab_id does not exists in the normalized tables and make sure it is well populated. +#} + +{%- macro need_full_refresh(col_ab_id, target_table=this) -%} + {%- if not execute -%} + {{ return(false) }} + {%- endif -%} + {%- set found_column = [] %} + {%- set cols = adapter.get_columns_in_relation(target_table) -%} + {%- for col in cols -%} + {%- if col.column == col_ab_id -%} + {% do found_column.append(col.column) %} + {%- endif -%} + {%- endfor -%} + {%- if found_column -%} + {{ return(false) }} + {%- else -%} + {{ dbt_utils.log_info(target_table ~ "." ~ col_ab_id ~ " does not exist yet. The table will be created or rebuilt with dbt.full_refresh") }} + {{ return(true) }} + {%- endif -%} +{%- endmacro -%} + +{%- macro should_full_refresh() -%} + {% set config_full_refresh = config.get('full_refresh') %} + {%- if config_full_refresh is none -%} + {% set config_full_refresh = flags.FULL_REFRESH %} + {%- endif -%} + {%- if not config_full_refresh -%} + {% set config_full_refresh = need_full_refresh(get_col_ab_id(), this) %} + {%- endif -%} + {% do return(config_full_refresh) %} +{%- endmacro -%} + +{%- macro get_col_ab_id() -%} + {{ adapter.dispatch('get_col_ab_id')() }} +{%- endmacro -%} + +{%- macro default__get_col_ab_id() -%} + _airbyte_ab_id +{%- endmacro -%} + +{%- macro oracle__get_col_ab_id() -%} + "_AIRBYTE_AB_ID" +{%- endmacro -%} + +{%- macro snowflake__get_col_ab_id() -%} + _AIRBYTE_AB_ID +{%- endmacro -%} diff --git a/macros/star_intersect.sql b/macros/star_intersect.sql new file mode 100644 index 0000000..3f3d06c --- /dev/null +++ b/macros/star_intersect.sql @@ -0,0 +1,46 @@ +{# + Similar to the star macro here: https://github.com/dbt-labs/dbt-utils/blob/main/macros/sql/star.sql + + This star_intersect macro takes an additional 'intersect' relation as argument. + Its behavior is to select columns from both 'intersect' and 'from' relations with the following rules: + - if the columns are existing in both 'from' and the 'intersect' relations, then the column from 'intersect' is used + - if it's not in the both relation, then only the column in the 'from' relation is used +#} +{% macro star_intersect(from, intersect, from_alias=False, intersect_alias=False, except=[]) -%} + {%- do dbt_utils._is_relation(from, 'star_intersect') -%} + {%- do dbt_utils._is_ephemeral(from, 'star_intersect') -%} + {%- do dbt_utils._is_relation(intersect, 'star_intersect') -%} + {%- do dbt_utils._is_ephemeral(intersect, 'star_intersect') -%} + + {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #} + {%- if not execute -%} + {{ return('') }} + {% endif %} + + {%- set include_cols = [] %} + {%- set cols = adapter.get_columns_in_relation(from) -%} + {%- set except = except | map("lower") | list %} + {%- for col in cols -%} + {%- if col.column|lower not in except -%} + {% do include_cols.append(col.column) %} + {%- endif %} + {%- endfor %} + + {%- set include_intersect_cols = [] %} + {%- set intersect_cols = adapter.get_columns_in_relation(intersect) -%} + {%- for col in intersect_cols -%} + {%- if col.column|lower not in except -%} + {% do include_intersect_cols.append(col.column) %} + {%- endif %} + {%- endfor %} + + {%- for col in include_cols %} + {%- if col in include_intersect_cols -%} + {%- if intersect_alias %}{{ intersect_alias }}.{% else %}{%- endif -%}{{ adapter.quote(col)|trim }} + {%- if not loop.last %},{{ '\n ' }}{% endif %} + {%- else %} + {%- if from_alias %}{{ from_alias }}.{% else %}{{ from }}.{%- endif -%}{{ adapter.quote(col)|trim }} as {{ adapter.quote(col)|trim }} + {%- if not loop.last %},{{ '\n ' }}{% endif %} + {%- endif %} + {%- endfor -%} +{%- endmacro %} diff --git a/models/generated/airbyte_ctes/unibag/admin_tags_ab1.sql b/models/generated/airbyte_ctes/unibag/admin_tags_ab1.sql new file mode 100644 index 0000000..c0e6cf2 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/admin_tags_ab1.sql @@ -0,0 +1,24 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_admin_tags') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }}, + {{ json_extract_scalar('_airbyte_data', ['color'], ['color']) }} as color, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_admin_tags') }} as table_alias +-- admin_tags +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/admin_tags_ab2.sql b/models/generated/airbyte_ctes/unibag/admin_tags_ab2.sql new file mode 100644 index 0000000..6aeb0d2 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/admin_tags_ab2.sql @@ -0,0 +1,24 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('admin_tags_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }}, + cast(color as {{ dbt_utils.type_string() }}) as color, + {{ cast_to_boolean('active') }} as active, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('admin_tags_ab1') }} +-- admin_tags +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/admin_tags_ab3.sql b/models/generated/airbyte_ctes/unibag/admin_tags_ab3.sql new file mode 100644 index 0000000..ff25742 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/admin_tags_ab3.sql @@ -0,0 +1,24 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('admin_tags_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('name'), + adapter.quote('type'), + 'color', + boolean_to_string('active'), + 'createdat', + 'updatedat', + 'searchstring', + ]) }} as _airbyte_admin_tags_hashid, + tmp.* +from {{ ref('admin_tags_ab2') }} tmp +-- admin_tags +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/cash_flows_ab1.sql b/models/generated/airbyte_ctes/unibag/cash_flows_ab1.sql new file mode 100644 index 0000000..0bd7698 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/cash_flows_ab1.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_cash_flows') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['hash'], ['hash']) }} as hash, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['value'], ['value']) }} as {{ adapter.quote('value') }}, + {{ json_extract_scalar('_airbyte_data', ['action'], ['action']) }} as {{ adapter.quote('action') }}, + {{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }}, + {{ json_extract_scalar('_airbyte_data', ['category'], ['category']) }} as category, + {{ json_extract_scalar('_airbyte_data', ['targetId'], ['targetId']) }} as targetid, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['isAudited'], ['isAudited']) }} as isaudited, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['newBalance'], ['newBalance']) }} as newbalance, + {{ json_extract_scalar('_airbyte_data', ['oldBalance'], ['oldBalance']) }} as oldbalance, + {{ json_extract_scalar('_airbyte_data', ['targetType'], ['targetType']) }} as targettype, + {{ json_extract_scalar('_airbyte_data', ['isProcessed'], ['isProcessed']) }} as isprocessed, + {{ json_extract_scalar('_airbyte_data', ['processStatus'], ['processStatus']) }} as processstatus, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_cash_flows') }} as table_alias +-- cash_flows +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/cash_flows_ab2.sql b/models/generated/airbyte_ctes/unibag/cash_flows_ab2.sql new file mode 100644 index 0000000..25e9b92 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/cash_flows_ab2.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('cash_flows_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(hash as {{ dbt_utils.type_string() }}) as hash, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast({{ adapter.quote('value') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('value') }}, + cast({{ adapter.quote('action') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('action') }}, + cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }}, + cast(category as {{ dbt_utils.type_string() }}) as category, + cast(targetid as {{ dbt_utils.type_string() }}) as targetid, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + {{ cast_to_boolean('isaudited') }} as isaudited, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(newbalance as {{ dbt_utils.type_float() }}) as newbalance, + cast(oldbalance as {{ dbt_utils.type_float() }}) as oldbalance, + cast(targettype as {{ dbt_utils.type_string() }}) as targettype, + {{ cast_to_boolean('isprocessed') }} as isprocessed, + cast(processstatus as {{ dbt_utils.type_string() }}) as processstatus, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('cash_flows_ab1') }} +-- cash_flows +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/cash_flows_ab3.sql b/models/generated/airbyte_ctes/unibag/cash_flows_ab3.sql new file mode 100644 index 0000000..c4f4b73 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/cash_flows_ab3.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('cash_flows_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'hash', + adapter.quote('user'), + adapter.quote('value'), + adapter.quote('action'), + adapter.quote('options'), + 'category', + 'targetid', + 'createdat', + boolean_to_string('isaudited'), + 'updatedat', + 'newbalance', + 'oldbalance', + 'targettype', + boolean_to_string('isprocessed'), + 'processstatus', + ]) }} as _airbyte_cash_flows_hashid, + tmp.* +from {{ ref('cash_flows_ab2') }} tmp +-- cash_flows +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/cities_ab1.sql b/models/generated/airbyte_ctes/unibag/cities_ab1.sql new file mode 100644 index 0000000..5e51367 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/cities_ab1.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_cities') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['slug'], ['slug']) }} as slug, + {{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }}, + {{ json_extract_scalar('_airbyte_data', ['tncId'], ['tncId']) }} as tncid, + {{ json_extract_scalar('_airbyte_data', ['region'], ['region']) }} as region, + {{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }}, + {{ json_extract_scalar('_airbyte_data', ['tempId'], ['tempId']) }} as tempid, + {{ json_extract_scalar('_airbyte_data', ['tncCode'], ['tncCode']) }} as tnccode, + {{ json_extract_scalar('_airbyte_data', ['osirisId'], ['osirisId']) }} as osirisid, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_cities') }} as table_alias +-- cities +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/cities_ab2.sql b/models/generated/airbyte_ctes/unibag/cities_ab2.sql new file mode 100644 index 0000000..3f37336 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/cities_ab2.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('cities_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(code as {{ dbt_utils.type_float() }}) as code, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast(slug as {{ dbt_utils.type_string() }}) as slug, + cast({{ adapter.quote('order') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('order') }}, + cast(tncid as {{ dbt_utils.type_float() }}) as tncid, + cast(region as {{ dbt_utils.type_string() }}) as region, + cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }}, + cast(tempid as {{ dbt_utils.type_float() }}) as tempid, + cast(tnccode as {{ dbt_utils.type_string() }}) as tnccode, + cast(osirisid as {{ dbt_utils.type_float() }}) as osirisid, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('cities_ab1') }} +-- cities +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/cities_ab3.sql b/models/generated/airbyte_ctes/unibag/cities_ab3.sql new file mode 100644 index 0000000..99965ed --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/cities_ab3.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('cities_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'code', + adapter.quote('name'), + 'slug', + adapter.quote('order'), + 'tncid', + 'region', + adapter.quote('source'), + 'tempid', + 'tnccode', + 'osirisid', + 'updatedat', + 'searchstring', + ]) }} as _airbyte_cities_hashid, + tmp.* +from {{ ref('cities_ab2') }} tmp +-- cities +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/customers_ab1.sql b/models/generated/airbyte_ctes/unibag/customers_ab1.sql new file mode 100644 index 0000000..977ea06 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/customers_ab1.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_customers') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['info'], ['info']) }} as info, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['email'], ['email']) }} as email, + {{ json_extract_scalar('_airbyte_data', ['phone'], ['phone']) }} as phone, + {{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }}, + {{ json_extract_array('_airbyte_data', ['location'], ['location']) }} as {{ adapter.quote('location') }}, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['isDeleted'], ['isDeleted']) }} as isdeleted, + {{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_customers') }} as table_alias +-- customers +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/customers_ab2.sql b/models/generated/airbyte_ctes/unibag/customers_ab2.sql new file mode 100644 index 0000000..c4ca101 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/customers_ab2.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('customers_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(info as {{ dbt_utils.type_string() }}) as info, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast(email as {{ dbt_utils.type_string() }}) as email, + cast(phone as {{ dbt_utils.type_string() }}) as phone, + cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }}, + {{ adapter.quote('location') }}, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + {{ cast_to_boolean('isdeleted') }} as isdeleted, + cast(statistic as {{ dbt_utils.type_string() }}) as statistic, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('customers_ab1') }} +-- customers +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/customers_ab3.sql b/models/generated/airbyte_ctes/unibag/customers_ab3.sql new file mode 100644 index 0000000..c980251 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/customers_ab3.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('customers_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'info', + adapter.quote('name'), + adapter.quote('user'), + 'email', + 'phone', + adapter.quote('source'), + array_to_string(adapter.quote('location')), + 'createdat', + boolean_to_string('isdeleted'), + 'statistic', + 'updatedat', + 'searchstring', + ]) }} as _airbyte_customers_hashid, + tmp.* +from {{ ref('customers_ab2') }} tmp +-- customers +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/districts_ab1.sql b/models/generated/airbyte_ctes/unibag/districts_ab1.sql new file mode 100644 index 0000000..d9d32cf --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/districts_ab1.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_districts') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['city'], ['city']) }} as city, + {{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['slug'], ['slug']) }} as slug, + {{ json_extract_scalar('_airbyte_data', ['tncId'], ['tncId']) }} as tncid, + {{ json_extract_scalar('_airbyte_data', ['cityId'], ['cityId']) }} as cityid, + {{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }}, + {{ json_extract_scalar('_airbyte_data', ['tncCode'], ['tncCode']) }} as tnccode, + {{ json_extract_scalar('_airbyte_data', ['gidoCode'], ['gidoCode']) }} as gidocode, + {{ json_extract_scalar('_airbyte_data', ['osirisId'], ['osirisId']) }} as osirisid, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_districts') }} as table_alias +-- districts +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/districts_ab2.sql b/models/generated/airbyte_ctes/unibag/districts_ab2.sql new file mode 100644 index 0000000..c7d5ef7 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/districts_ab2.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('districts_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(city as {{ dbt_utils.type_string() }}) as city, + cast(code as {{ dbt_utils.type_float() }}) as code, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast(slug as {{ dbt_utils.type_string() }}) as slug, + cast(tncid as {{ dbt_utils.type_float() }}) as tncid, + cast(cityid as {{ dbt_utils.type_float() }}) as cityid, + cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }}, + cast(tnccode as {{ dbt_utils.type_string() }}) as tnccode, + cast(gidocode as {{ dbt_utils.type_float() }}) as gidocode, + cast(osirisid as {{ dbt_utils.type_float() }}) as osirisid, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('districts_ab1') }} +-- districts +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/districts_ab3.sql b/models/generated/airbyte_ctes/unibag/districts_ab3.sql new file mode 100644 index 0000000..eea5d42 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/districts_ab3.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('districts_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'city', + 'code', + adapter.quote('name'), + 'slug', + 'tncid', + 'cityid', + adapter.quote('source'), + 'tnccode', + 'gidocode', + 'osirisid', + 'updatedat', + 'searchstring', + ]) }} as _airbyte_districts_hashid, + tmp.* +from {{ ref('districts_ab2') }} tmp +-- districts +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/event_rewards_ab1.sql b/models/generated/airbyte_ctes/unibag/event_rewards_ab1.sql new file mode 100644 index 0000000..fa06cec --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/event_rewards_ab1.sql @@ -0,0 +1,25 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_event_rewards') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['cash'], ['cash']) }} as cash, + {{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }}, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['event'], ['event']) }} as {{ adapter.quote('event') }}, + {{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status, + {{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }}, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['updatedat'], ['updatedat']) }} as updatedat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_event_rewards') }} as table_alias +-- event_rewards +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/event_rewards_ab2.sql b/models/generated/airbyte_ctes/unibag/event_rewards_ab2.sql new file mode 100644 index 0000000..bfcdc1a --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/event_rewards_ab2.sql @@ -0,0 +1,25 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('event_rewards_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(cash as {{ dbt_utils.type_float() }}) as cash, + cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }}, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast({{ adapter.quote('event') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('event') }}, + cast(status as {{ dbt_utils.type_string() }}) as status, + cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }}, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('event_rewards_ab1') }} +-- event_rewards +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/event_rewards_ab3.sql b/models/generated/airbyte_ctes/unibag/event_rewards_ab3.sql new file mode 100644 index 0000000..95be1f6 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/event_rewards_ab3.sql @@ -0,0 +1,25 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('event_rewards_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'cash', + adapter.quote('type'), + adapter.quote('user'), + adapter.quote('event'), + 'status', + adapter.quote('options'), + 'createdat', + 'updatedat', + ]) }} as _airbyte_event_rewards_hashid, + tmp.* +from {{ ref('event_rewards_ab2') }} tmp +-- event_rewards +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/events_ab1.sql b/models/generated/airbyte_ctes/unibag/events_ab1.sql new file mode 100644 index 0000000..3966a3a --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/events_ab1.sql @@ -0,0 +1,38 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_events') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['desc'], ['desc']) }} as {{ adapter.quote('desc') }}, + {{ json_extract_scalar('_airbyte_data', ['icon'], ['icon']) }} as icon, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }}, + {{ json_extract_scalar('_airbyte_data', ['cover'], ['cover']) }} as cover, + {{ json_extract_scalar('_airbyte_data', ['endAt'], ['endAt']) }} as endat, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['notice'], ['notice']) }} as notice, + {{ json_extract_scalar('_airbyte_data', ['screen'], ['screen']) }} as screen, + {{ json_extract_scalar('_airbyte_data', ['article'], ['article']) }} as article, + {{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }}, + {{ json_extract_scalar('_airbyte_data', ['startAt'], ['startAt']) }} as startat, + {{ json_extract_scalar('_airbyte_data', ['segments'], ['segments']) }} as segments, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['groupType'], ['groupType']) }} as grouptype, + {{ json_extract_array('_airbyte_data', ['suppliers'], ['suppliers']) }} as suppliers, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_array('_airbyte_data', ['information'], ['information']) }} as information, + {{ json_extract_scalar('_airbyte_data', ['displayEndAt'], ['displayEndAt']) }} as displayendat, + {{ json_extract_scalar('_airbyte_data', ['isApplyForAll'], ['isApplyForAll']) }} as isapplyforall, + {{ json_extract_scalar('_airbyte_data', ['displayStartAt'], ['displayStartAt']) }} as displaystartat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_events') }} as table_alias +-- events +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/events_ab2.sql b/models/generated/airbyte_ctes/unibag/events_ab2.sql new file mode 100644 index 0000000..3a43ded --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/events_ab2.sql @@ -0,0 +1,38 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('events_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('desc') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('desc') }}, + cast(icon as {{ dbt_utils.type_string() }}) as icon, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }}, + cast(cover as {{ dbt_utils.type_string() }}) as cover, + cast(endat as {{ dbt_utils.type_string() }}) as endat, + {{ cast_to_boolean('active') }} as active, + cast(notice as {{ dbt_utils.type_string() }}) as notice, + cast(screen as {{ dbt_utils.type_string() }}) as screen, + cast(article as {{ dbt_utils.type_string() }}) as article, + cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }}, + cast(startat as {{ dbt_utils.type_string() }}) as startat, + cast(segments as {{ dbt_utils.type_string() }}) as segments, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(grouptype as {{ dbt_utils.type_string() }}) as grouptype, + suppliers, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + information, + cast(displayendat as {{ dbt_utils.type_string() }}) as displayendat, + {{ cast_to_boolean('isapplyforall') }} as isapplyforall, + cast(displaystartat as {{ dbt_utils.type_string() }}) as displaystartat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('events_ab1') }} +-- events +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/events_ab3.sql b/models/generated/airbyte_ctes/unibag/events_ab3.sql new file mode 100644 index 0000000..d7029d7 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/events_ab3.sql @@ -0,0 +1,38 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('events_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('desc'), + 'icon', + adapter.quote('name'), + adapter.quote('type'), + 'cover', + 'endat', + boolean_to_string('active'), + 'notice', + 'screen', + 'article', + adapter.quote('options'), + 'startat', + 'segments', + 'createdat', + 'grouptype', + array_to_string('suppliers'), + 'updatedat', + array_to_string('information'), + 'displayendat', + boolean_to_string('isapplyforall'), + 'displaystartat', + ]) }} as _airbyte_events_hashid, + tmp.* +from {{ ref('events_ab2') }} tmp +-- events +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/inventories_ab1.sql b/models/generated/airbyte_ctes/unibag/inventories_ab1.sql new file mode 100644 index 0000000..e064db0 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/inventories_ab1.sql @@ -0,0 +1,38 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_inventories') }} +select + {{ json_extract_scalar('_airbyte_data', ['id'], ['id']) }} as {{ adapter.quote('id') }}, + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['slug'], ['slug']) }} as slug, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['contact'], ['contact']) }} as contact, + {{ json_extract_scalar('_airbyte_data', ['partner'], ['partner']) }} as partner, + {{ json_extract_scalar('_airbyte_data', ['checksum'], ['checksum']) }} as checksum, + {{ json_extract_scalar('_airbyte_data', ['location'], ['location']) }} as {{ adapter.quote('location') }}, + {{ json_extract_scalar('_airbyte_data', ['supplier'], ['supplier']) }} as supplier, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['minimumValue'], ['minimumValue']) }} as minimumvalue, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_scalar('_airbyte_data', ['paymentMethods'], ['paymentMethods']) }} as paymentmethods, + {{ json_extract_scalar('_airbyte_data', ['canIssueInvoice'], ['canIssueInvoice']) }} as canissueinvoice, + {{ json_extract_array('_airbyte_data', ['deliveryMethods'], ['deliveryMethods']) }} as deliverymethods, + {{ json_extract_scalar('_airbyte_data', ['canAutoSendEmail'], ['canAutoSendEmail']) }} as canautosendemail, + {{ json_extract_scalar('_airbyte_data', ['invoiceDeliveryMethod'], ['invoiceDeliveryMethod']) }} as invoicedeliverymethod, + {{ json_extract_scalar('_airbyte_data', ['doesSupportSellyExpress'], ['doesSupportSellyExpress']) }} as doessupportsellyexpress, + {{ json_extract_array('_airbyte_data', ['priorityDeliveryServiceCodes'], ['priorityDeliveryServiceCodes']) }} as prioritydeliveryservicecodes, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_inventories') }} as table_alias +-- inventories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/inventories_ab2.sql b/models/generated/airbyte_ctes/unibag/inventories_ab2.sql new file mode 100644 index 0000000..b8968d3 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/inventories_ab2.sql @@ -0,0 +1,38 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('inventories_ab1') }} +select + cast({{ adapter.quote('id') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('id') }}, + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(code as {{ dbt_utils.type_float() }}) as code, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast(slug as {{ dbt_utils.type_string() }}) as slug, + {{ cast_to_boolean('active') }} as active, + cast(contact as {{ dbt_utils.type_string() }}) as contact, + cast(partner as {{ dbt_utils.type_string() }}) as partner, + cast(checksum as {{ dbt_utils.type_string() }}) as checksum, + cast({{ adapter.quote('location') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('location') }}, + cast(supplier as {{ dbt_utils.type_string() }}) as supplier, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(minimumvalue as {{ dbt_utils.type_float() }}) as minimumvalue, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + cast(paymentmethods as {{ dbt_utils.type_string() }}) as paymentmethods, + {{ cast_to_boolean('canissueinvoice') }} as canissueinvoice, + deliverymethods, + {{ cast_to_boolean('canautosendemail') }} as canautosendemail, + cast(invoicedeliverymethod as {{ dbt_utils.type_string() }}) as invoicedeliverymethod, + {{ cast_to_boolean('doessupportsellyexpress') }} as doessupportsellyexpress, + prioritydeliveryservicecodes, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('inventories_ab1') }} +-- inventories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/inventories_ab3.sql b/models/generated/airbyte_ctes/unibag/inventories_ab3.sql new file mode 100644 index 0000000..c0e65e2 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/inventories_ab3.sql @@ -0,0 +1,38 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('inventories_ab2') }} +select + {{ dbt_utils.surrogate_key([ + adapter.quote('id'), + '_id', + 'code', + adapter.quote('name'), + 'slug', + boolean_to_string('active'), + 'contact', + 'partner', + 'checksum', + adapter.quote('location'), + 'supplier', + 'createdat', + 'updatedat', + 'minimumvalue', + 'searchstring', + 'paymentmethods', + boolean_to_string('canissueinvoice'), + array_to_string('deliverymethods'), + boolean_to_string('canautosendemail'), + 'invoicedeliverymethod', + boolean_to_string('doessupportsellyexpress'), + array_to_string('prioritydeliveryservicecodes'), + ]) }} as _airbyte_inventories_hashid, + tmp.* +from {{ ref('inventories_ab2') }} tmp +-- inventories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/membership_ab1.sql b/models/generated/airbyte_ctes/unibag/membership_ab1.sql new file mode 100644 index 0000000..ce7d6ce --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/membership_ab1.sql @@ -0,0 +1,30 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_membership') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['color'], ['color']) }} as color, + {{ json_extract_scalar('_airbyte_data', ['guide'], ['guide']) }} as guide, + {{ json_extract_scalar('_airbyte_data', ['level'], ['level']) }} as {{ adapter.quote('level') }}, + {{ json_extract_scalar('_airbyte_data', ['sales'], ['sales']) }} as sales, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['updatedat'], ['updatedat']) }} as updatedat_1, + {{ json_extract_scalar('_airbyte_data', ['transaction'], ['transaction']) }} as {{ adapter.quote('transaction') }}, + {{ json_extract_scalar('_airbyte_data', ['bonusPercent'], ['bonusPercent']) }} as bonuspercent, + {{ json_extract_scalar('_airbyte_data', ['bonuspercent'], ['bonuspercent']) }} as bonuspercent_1, + {{ json_extract_scalar('_airbyte_data', ['transactionMinValue'], ['transactionMinValue']) }} as transactionminvalue, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_membership') }} as table_alias +-- membership +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/membership_ab2.sql b/models/generated/airbyte_ctes/unibag/membership_ab2.sql new file mode 100644 index 0000000..60c1e91 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/membership_ab2.sql @@ -0,0 +1,30 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('membership_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast(color as {{ dbt_utils.type_string() }}) as color, + cast(guide as {{ dbt_utils.type_string() }}) as guide, + cast({{ adapter.quote('level') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('level') }}, + cast(sales as {{ dbt_utils.type_float() }}) as sales, + {{ cast_to_boolean('active') }} as active, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(updatedat_1 as {{ dbt_utils.type_string() }}) as updatedat_1, + cast({{ adapter.quote('transaction') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('transaction') }}, + cast(bonuspercent as {{ dbt_utils.type_float() }}) as bonuspercent, + cast(bonuspercent_1 as {{ dbt_utils.type_float() }}) as bonuspercent_1, + cast(transactionminvalue as {{ dbt_utils.type_float() }}) as transactionminvalue, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('membership_ab1') }} +-- membership +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/membership_ab3.sql b/models/generated/airbyte_ctes/unibag/membership_ab3.sql new file mode 100644 index 0000000..44e9ab5 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/membership_ab3.sql @@ -0,0 +1,30 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('membership_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('name'), + 'color', + 'guide', + adapter.quote('level'), + 'sales', + boolean_to_string('active'), + 'createdat', + 'updatedat', + 'updatedat_1', + adapter.quote('transaction'), + 'bonuspercent', + 'bonuspercent_1', + 'transactionminvalue', + ]) }} as _airbyte_membership_hashid, + tmp.* +from {{ ref('membership_ab2') }} tmp +-- membership +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/membership_histories_ab1.sql b/models/generated/airbyte_ctes/unibag/membership_histories_ab1.sql new file mode 100644 index 0000000..c920079 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/membership_histories_ab1.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_membership_histories') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['new'], ['new']) }} as {{ adapter.quote('new') }}, + {{ json_extract_scalar('_airbyte_data', ['old'], ['old']) }} as {{ adapter.quote('old') }}, + {{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }}, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_membership_histories') }} as table_alias +-- membership_histories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/membership_histories_ab2.sql b/models/generated/airbyte_ctes/unibag/membership_histories_ab2.sql new file mode 100644 index 0000000..2453c8d --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/membership_histories_ab2.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('membership_histories_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('new') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('new') }}, + cast({{ adapter.quote('old') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('old') }}, + cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }}, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('membership_histories_ab1') }} +-- membership_histories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/membership_histories_ab3.sql b/models/generated/airbyte_ctes/unibag/membership_histories_ab3.sql new file mode 100644 index 0000000..49f6c05 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/membership_histories_ab3.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('membership_histories_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('new'), + adapter.quote('old'), + adapter.quote('type'), + adapter.quote('user'), + 'createdat', + ]) }} as _airbyte_membership_histories_hashid, + tmp.* +from {{ ref('membership_histories_ab2') }} tmp +-- membership_histories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/membership_orders_ab1.sql b/models/generated/airbyte_ctes/unibag/membership_orders_ab1.sql new file mode 100644 index 0000000..1f7b78c --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/membership_orders_ab1.sql @@ -0,0 +1,28 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_membership_orders') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status, + {{ json_extract_scalar('_airbyte_data', ['percent'], ['percent']) }} as {{ adapter.quote('percent') }}, + {{ json_extract_scalar('_airbyte_data', ['targetID'], ['targetID']) }} as targetid, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['commission'], ['commission']) }} as commission, + {{ json_extract_scalar('_airbyte_data', ['isRejected'], ['isRejected']) }} as isrejected, + {{ json_extract_scalar('_airbyte_data', ['membershipName'], ['membershipName']) }} as membershipname, + {{ json_extract_scalar('_airbyte_data', ['membershipLevel'], ['membershipLevel']) }} as membershiplevel, + {{ json_extract_scalar('_airbyte_data', ['membershipPromotion'], ['membershipPromotion']) }} as membershippromotion, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_membership_orders') }} as table_alias +-- membership_orders +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/membership_orders_ab2.sql b/models/generated/airbyte_ctes/unibag/membership_orders_ab2.sql new file mode 100644 index 0000000..9235cee --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/membership_orders_ab2.sql @@ -0,0 +1,28 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('membership_orders_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast(status as {{ dbt_utils.type_string() }}) as status, + cast({{ adapter.quote('percent') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('percent') }}, + cast(targetid as {{ dbt_utils.type_string() }}) as targetid, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(commission as {{ dbt_utils.type_float() }}) as commission, + {{ cast_to_boolean('isrejected') }} as isrejected, + cast(membershipname as {{ dbt_utils.type_string() }}) as membershipname, + cast(membershiplevel as {{ dbt_utils.type_float() }}) as membershiplevel, + cast({{ adapter.quote('membershippromotion') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('membershippromotion') }}, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('membership_orders_ab1') }} +-- membership_orders +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/membership_orders_ab3.sql b/models/generated/airbyte_ctes/unibag/membership_orders_ab3.sql new file mode 100644 index 0000000..23d74cf --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/membership_orders_ab3.sql @@ -0,0 +1,28 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('membership_orders_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('user'), + 'status', + adapter.quote('percent'), + 'targetid', + 'createdat', + 'updatedat', + 'commission', + boolean_to_string('isrejected'), + 'membershipname', + 'membershiplevel', + 'membershippromotion' + ]) }} as _airbyte_membership_orders_hashid, + tmp.* +from {{ ref('membership_orders_ab2') }} tmp +-- membership_orders +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/order_deliveries_ab1.sql b/models/generated/airbyte_ctes/unibag/order_deliveries_ab1.sql new file mode 100644 index 0000000..916e13a --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/order_deliveries_ab1.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_order_deliveries') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code, + {{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }}, + {{ json_extract_scalar('_airbyte_data', ['title'], ['title']) }} as title, + {{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status, + {{ json_extract_scalar('_airbyte_data', ['service'], ['service']) }} as service, + {{ json_extract_scalar('_airbyte_data', ['customer'], ['customer']) }} as customer, + {{ json_extract_scalar('_airbyte_data', ['delivery'], ['delivery']) }} as delivery, + {{ json_extract_scalar('_airbyte_data', ['location'], ['location']) }} as {{ adapter.quote('location') }}, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['promotion'], ['promotion']) }} as promotion, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['trackingCode'], ['trackingCode']) }} as trackingcode, + {{ json_extract_scalar('_airbyte_data', ['trackingTime'], ['trackingTime']) }} as trackingtime, + {{ json_extract_scalar('_airbyte_data', ['isAdminChange'], ['isAdminChange']) }} as isadminchange, + {{ json_extract_scalar('_airbyte_data', ['trackingOrderCode'], ['trackingOrderCode']) }} as trackingordercode, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_order_deliveries') }} as table_alias +-- order_deliveries +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/order_deliveries_ab2.sql b/models/generated/airbyte_ctes/unibag/order_deliveries_ab2.sql new file mode 100644 index 0000000..be476dd --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/order_deliveries_ab2.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('order_deliveries_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(code as {{ dbt_utils.type_string() }}) as code, + cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }}, + cast(title as {{ dbt_utils.type_string() }}) as title, + cast(status as {{ dbt_utils.type_string() }}) as status, + cast(service as {{ dbt_utils.type_string() }}) as service, + cast(customer as {{ dbt_utils.type_string() }}) as customer, + cast(delivery as {{ dbt_utils.type_string() }}) as delivery, + cast({{ adapter.quote('location') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('location') }}, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(promotion as {{ dbt_utils.type_string() }}) as promotion, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(trackingcode as {{ dbt_utils.type_string() }}) as trackingcode, + cast(trackingtime as {{ dbt_utils.type_string() }}) as trackingtime, + {{ cast_to_boolean('isadminchange') }} as isadminchange, + cast(trackingordercode as {{ dbt_utils.type_string() }}) as trackingordercode, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('order_deliveries_ab1') }} +-- order_deliveries +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/order_deliveries_ab3.sql b/models/generated/airbyte_ctes/unibag/order_deliveries_ab3.sql new file mode 100644 index 0000000..783f982 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/order_deliveries_ab3.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('order_deliveries_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'code', + adapter.quote('order'), + 'title', + 'status', + 'service', + 'customer', + 'delivery', + adapter.quote('location'), + 'createdat', + 'promotion', + 'updatedat', + 'trackingcode', + 'trackingtime', + boolean_to_string('isadminchange'), + 'trackingordercode', + ]) }} as _airbyte_order_deliveries_hashid, + tmp.* +from {{ ref('order_deliveries_ab2') }} tmp +-- order_deliveries +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/order_histories_ab1.sql b/models/generated/airbyte_ctes/unibag/order_histories_ab1.sql new file mode 100644 index 0000000..a29935e --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/order_histories_ab1.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_order_histories') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }}, + {{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['timestamp'], ['timestamp']) }} as {{ adapter.quote('timestamp') }}, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_order_histories') }} as table_alias +-- order_histories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/order_histories_ab2.sql b/models/generated/airbyte_ctes/unibag/order_histories_ab2.sql new file mode 100644 index 0000000..6829844 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/order_histories_ab2.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('order_histories_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }}, + cast(status as {{ dbt_utils.type_string() }}) as status, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast({{ adapter.quote('timestamp') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('timestamp') }}, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('order_histories_ab1') }} +-- order_histories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/order_histories_ab3.sql b/models/generated/airbyte_ctes/unibag/order_histories_ab3.sql new file mode 100644 index 0000000..1f63e99 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/order_histories_ab3.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('order_histories_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('order'), + 'status', + 'createdat', + adapter.quote('timestamp'), + 'updatedat', + ]) }} as _airbyte_order_histories_hashid, + tmp.* +from {{ ref('order_histories_ab2') }} tmp +-- order_histories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/order_items_ab1.sql b/models/generated/airbyte_ctes/unibag/order_items_ab1.sql new file mode 100644 index 0000000..bc10213 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/order_items_ab1.sql @@ -0,0 +1,45 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_order_items') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['sku'], ['sku']) }} as sku, + {{ json_extract_scalar('_airbyte_data', ['date'], ['date']) }} as {{ adapter.quote('date') }}, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['brand'], ['brand']) }} as brand, + {{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }}, + {{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price, + {{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status, + {{ json_extract_scalar('_airbyte_data', ['teamId'], ['teamId']) }} as teamid, + {{ json_extract_scalar('_airbyte_data', ['product'], ['product']) }} as product, + {{ json_extract_scalar('_airbyte_data', ['voucher'], ['voucher']) }} as voucher, + {{ json_extract_scalar('_airbyte_data', ['customer'], ['customer']) }} as customer, + {{ json_extract_scalar('_airbyte_data', ['quantity'], ['quantity']) }} as quantity, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['inventory'], ['inventory']) }} as inventory, + {{ json_extract_scalar('_airbyte_data', ['totalSell'], ['totalSell']) }} as totalsell, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['cashbackAt'], ['cashbackAt']) }} as cashbackat, + {{ json_extract_array('_airbyte_data', ['promotions'], ['promotions']) }} as promotions, + {{ json_extract_scalar('_airbyte_data', ['totalPrice'], ['totalPrice']) }} as totalprice, + {{ json_extract_scalar('_airbyte_data', ['deliveredAt'], ['deliveredAt']) }} as deliveredat, + {{ json_extract_scalar('_airbyte_data', ['teamMemberId'], ['teamMemberId']) }} as teammemberid, + {{ json_extract_scalar('_airbyte_data', ['isAssignCoupon'], ['isAssignCoupon']) }} as isassigncoupon, + {{ json_extract_scalar('_airbyte_data', ['totalPromotion'], ['totalPromotion']) }} as totalpromotion, + {{ json_extract_scalar('_airbyte_data', ['inWholesaleRange'], ['inWholesaleRange']) }} as inwholesalerange, + {{ json_extract_scalar('_airbyte_data', ['voucherCashTotal'], ['voucherCashTotal']) }} as vouchercashtotal, + {{ json_extract_scalar('_airbyte_data', ['wholesaleRangeId'], ['wholesaleRangeId']) }} as wholesalerangeid, + {{ json_extract_scalar('_airbyte_data', ['totalWholesaleBonus'], ['totalWholesaleBonus']) }} as totalwholesalebonus, + {{ json_extract_scalar('_airbyte_data', ['totalSellyWholesaleBonus'], ['totalSellyWholesaleBonus']) }} as totalsellywholesalebonus, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_order_items') }} as table_alias +-- order_items +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/order_items_ab2.sql b/models/generated/airbyte_ctes/unibag/order_items_ab2.sql new file mode 100644 index 0000000..441ca5c --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/order_items_ab2.sql @@ -0,0 +1,45 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('order_items_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(sku as {{ dbt_utils.type_string() }}) as sku, + cast({{ adapter.quote('date') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('date') }}, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast(brand as {{ dbt_utils.type_string() }}) as brand, + cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }}, + cast(price as {{ dbt_utils.type_string() }}) as price, + cast(status as {{ dbt_utils.type_string() }}) as status, + cast(teamid as {{ dbt_utils.type_string() }}) as teamid, + cast(product as {{ dbt_utils.type_string() }}) as product, + cast(voucher as {{ dbt_utils.type_string() }}) as voucher, + cast(customer as {{ dbt_utils.type_string() }}) as customer, + cast(quantity as {{ dbt_utils.type_float() }}) as quantity, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(inventory as {{ dbt_utils.type_string() }}) as inventory, + cast(totalsell as {{ dbt_utils.type_float() }}) as totalsell, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(cashbackat as {{ dbt_utils.type_string() }}) as cashbackat, + promotions, + cast(totalprice as {{ dbt_utils.type_float() }}) as totalprice, + cast(deliveredat as {{ dbt_utils.type_string() }}) as deliveredat, + cast(teammemberid as {{ dbt_utils.type_string() }}) as teammemberid, + {{ cast_to_boolean('isassigncoupon') }} as isassigncoupon, + cast(totalpromotion as {{ dbt_utils.type_float() }}) as totalpromotion, + {{ cast_to_boolean('inwholesalerange') }} as inwholesalerange, + cast(vouchercashtotal as {{ dbt_utils.type_float() }}) as vouchercashtotal, + cast(wholesalerangeid as {{ dbt_utils.type_string() }}) as wholesalerangeid, + cast(totalwholesalebonus as {{ dbt_utils.type_float() }}) as totalwholesalebonus, + cast(totalsellywholesalebonus as {{ dbt_utils.type_float() }}) as totalsellywholesalebonus, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('order_items_ab1') }} +-- order_items +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/order_items_ab3.sql b/models/generated/airbyte_ctes/unibag/order_items_ab3.sql new file mode 100644 index 0000000..2f34c0b --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/order_items_ab3.sql @@ -0,0 +1,45 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('order_items_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'sku', + adapter.quote('date'), + adapter.quote('user'), + 'brand', + adapter.quote('order'), + 'price', + 'status', + 'teamid', + 'product', + 'voucher', + 'customer', + 'quantity', + 'createdat', + 'inventory', + 'totalsell', + 'updatedat', + 'cashbackat', + array_to_string('promotions'), + 'totalprice', + 'deliveredat', + 'teammemberid', + boolean_to_string('isassigncoupon'), + 'totalpromotion', + boolean_to_string('inwholesalerange'), + 'vouchercashtotal', + 'wholesalerangeid', + 'totalwholesalebonus', + 'totalsellywholesalebonus', + ]) }} as _airbyte_order_items_hashid, + tmp.* +from {{ ref('order_items_ab2') }} tmp +-- order_items +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/orders_ab1.sql b/models/generated/airbyte_ctes/unibag/orders_ab1.sql new file mode 100644 index 0000000..a4896c8 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/orders_ab1.sql @@ -0,0 +1,74 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_orders') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code, + {{ json_extract_scalar('_airbyte_data', ['date'], ['date']) }} as {{ adapter.quote('date') }}, + {{ json_extract_scalar('_airbyte_data', ['hour'], ['hour']) }} as {{ adapter.quote('hour') }}, + {{ json_extract_scalar('_airbyte_data', ['note'], ['note']) }} as note, + {{ json_extract_array('_airbyte_data', ['tags'], ['tags']) }} as tags, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price, + {{ json_extract_scalar('_airbyte_data', ['banned'], ['banned']) }} as banned, + {{ json_extract_scalar('_airbyte_data', ['reason'], ['reason']) }} as reason, + {{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }}, + {{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status, + {{ json_extract_scalar('_airbyte_data', ['teamId'], ['teamId']) }} as teamid, + {{ json_extract_scalar('_airbyte_data', ['payment'], ['payment']) }} as payment, + {{ json_extract_scalar('_airbyte_data', ['remarks'], ['remarks']) }} as remarks, + {{ json_extract_scalar('_airbyte_data', ['customer'], ['customer']) }} as customer, + {{ json_extract_scalar('_airbyte_data', ['delivery'], ['delivery']) }} as delivery, + {{ json_extract_scalar('_airbyte_data', ['isCalled'], ['isCalled']) }} as iscalled, + {{ json_extract_scalar('_airbyte_data', ['merchant'], ['merchant']) }} as merchant, + {{ json_extract_scalar('_airbyte_data', ['pickupAt'], ['pickupAt']) }} as pickupat, + {{ json_extract_scalar('_airbyte_data', ['supplier'], ['supplier']) }} as supplier, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['inventory'], ['inventory']) }} as inventory, + {{ json_extract_scalar('_airbyte_data', ['invoiceId'], ['invoiceId']) }} as invoiceid, + {{ json_extract_scalar('_airbyte_data', ['isDeleted'], ['isDeleted']) }} as isdeleted, + {{ json_extract_scalar('_airbyte_data', ['promotion'], ['promotion']) }} as promotion, + {{ json_extract_scalar('_airbyte_data', ['requestId'], ['requestId']) }} as requestid, + {{ json_extract_scalar('_airbyte_data', ['restockAt'], ['restockAt']) }} as restockat, + {{ json_extract_scalar('_airbyte_data', ['sendEmail'], ['sendEmail']) }} as sendemail, + {{ json_extract_scalar('_airbyte_data', ['totalItem'], ['totalItem']) }} as totalitem, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['userAgent'], ['userAgent']) }} as useragent, + {{ json_extract_scalar('_airbyte_data', ['wholesale'], ['wholesale']) }} as wholesale, + {{ json_extract_scalar('_airbyte_data', ['approvedAt'], ['approvedAt']) }} as approvedat, + {{ json_extract_scalar('_airbyte_data', ['cashbackAt'], ['cashbackAt']) }} as cashbackat, + {{ json_extract_scalar('_airbyte_data', ['isPreorder'], ['isPreorder']) }} as ispreorder, + {{ json_extract_scalar('_airbyte_data', ['isReviewed'], ['isReviewed']) }} as isreviewed, + {{ json_extract_scalar('_airbyte_data', ['rejectedAt'], ['rejectedAt']) }} as rejectedat, + {{ json_extract_scalar('_airbyte_data', ['deliveredAt'], ['deliveredAt']) }} as deliveredat, + {{ json_extract_scalar('_airbyte_data', ['deliveringAt'], ['deliveringAt']) }} as deliveringat, + {{ json_extract_scalar('_airbyte_data', ['deliveryCode'], ['deliveryCode']) }} as deliverycode, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_scalar('_airbyte_data', ['staffApprove'], ['staffApprove']) }} as staffapprove, + {{ json_extract_scalar('_airbyte_data', ['teamMemberId'], ['teamMemberId']) }} as teammemberid, + {{ json_extract_scalar('_airbyte_data', ['processStatus'], ['processStatus']) }} as processstatus, + {{ json_extract_scalar('_airbyte_data', ['hookTimeLastAt'], ['hookTimeLastAt']) }} as hooktimelastat, + {{ json_extract_scalar('_airbyte_data', ['isAssignCoupon'], ['isAssignCoupon']) }} as isassigncoupon, + {{ json_extract_scalar('_airbyte_data', ['isAutoApproved'], ['isAutoApproved']) }} as isautoapproved, + {{ json_extract_scalar('_airbyte_data', ['outboundRequest'], ['outboundRequest']) }} as outboundrequest, + {{ json_extract_scalar('_airbyte_data', ['trackingCodeURL'], ['trackingCodeURL']) }} as trackingcodeurl, + {{ json_extract_scalar('_airbyte_data', ['trackingCode'], ['trackingcode']) }} as trackingCode, + {{ json_extract_scalar('_airbyte_data', ['waitingCancelBy'], ['waitingCancelBy']) }} as waitingcancelby, + {{ json_extract_scalar('_airbyte_data', ['isChangeDelivery'], ['isChangeDelivery']) }} as ischangedelivery, + {{ json_extract_scalar('_airbyte_data', ['estimateCashbackAt'], ['estimateCashbackAt']) }} as estimatecashbackat, + {{ json_extract_scalar('_airbyte_data', ['fromNewActiveBuyer'], ['fromNewActiveBuyer']) }} as fromnewactivebuyer, + {{ json_extract_scalar('_airbyte_data', ['isWaitingCancelled'], ['isWaitingCancelled']) }} as iswaitingcancelled, + {{ json_extract_scalar('_airbyte_data', ['fromNewActiveSeller'], ['fromNewActiveSeller']) }} as fromnewactiveseller, + {{ json_extract_scalar('_airbyte_data', ['waitingCancelReason'], ['waitingCancelReason']) }} as waitingcancelreason, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_orders') }} as table_alias +-- orders +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/orders_ab2.sql b/models/generated/airbyte_ctes/unibag/orders_ab2.sql new file mode 100644 index 0000000..1435977 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/orders_ab2.sql @@ -0,0 +1,74 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('orders_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(code as {{ dbt_utils.type_string() }}) as code, + cast({{ adapter.quote('date') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('date') }}, + cast({{ adapter.quote('hour') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('hour') }}, + cast(note as {{ dbt_utils.type_string() }}) as note, + tags, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast(price as {{ dbt_utils.type_string() }}) as price, + {{ cast_to_boolean('banned') }} as banned, + cast(reason as {{ dbt_utils.type_string() }}) as reason, + cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }}, + cast(status as {{ dbt_utils.type_string() }}) as status, + cast(teamid as {{ dbt_utils.type_string() }}) as teamid, + cast(payment as {{ dbt_utils.type_string() }}) as payment, + cast(remarks as {{ dbt_utils.type_string() }}) as remarks, + cast(customer as {{ dbt_utils.type_string() }}) as customer, + cast(delivery as {{ dbt_utils.type_string() }}) as delivery, + {{ cast_to_boolean('iscalled') }} as iscalled, + cast(merchant as {{ dbt_utils.type_string() }}) as merchant, + cast(pickupat as {{ dbt_utils.type_string() }}) as pickupat, + cast(supplier as {{ dbt_utils.type_string() }}) as supplier, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(inventory as {{ dbt_utils.type_string() }}) as inventory, + cast(invoiceid as {{ dbt_utils.type_string() }}) as invoiceid, + {{ cast_to_boolean('isdeleted') }} as isdeleted, + cast(promotion as {{ dbt_utils.type_string() }}) as promotion, + cast(requestid as {{ dbt_utils.type_string() }}) as requestid, + cast(restockat as {{ dbt_utils.type_string() }}) as restockat, + cast(sendemail as {{ dbt_utils.type_string() }}) as sendemail, + cast(totalitem as {{ dbt_utils.type_float() }}) as totalitem, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(useragent as {{ dbt_utils.type_string() }}) as useragent, + {{ cast_to_boolean('wholesale') }} as wholesale, + cast(approvedat as {{ dbt_utils.type_string() }}) as approvedat, + cast(cashbackat as {{ dbt_utils.type_string() }}) as cashbackat, + {{ cast_to_boolean('ispreorder') }} as ispreorder, + {{ cast_to_boolean('isreviewed') }} as isreviewed, + cast(rejectedat as {{ dbt_utils.type_string() }}) as rejectedat, + cast(deliveredat as {{ dbt_utils.type_string() }}) as deliveredat, + cast(deliveringat as {{ dbt_utils.type_string() }}) as deliveringat, + cast(deliverycode as {{ dbt_utils.type_string() }}) as deliverycode, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + cast(staffapprove as {{ dbt_utils.type_string() }}) as staffapprove, + cast(teammemberid as {{ dbt_utils.type_string() }}) as teammemberid, + cast(processstatus as {{ dbt_utils.type_string() }}) as processstatus, + cast(hooktimelastat as {{ dbt_utils.type_string() }}) as hooktimelastat, + {{ cast_to_boolean('isassigncoupon') }} as isassigncoupon, + {{ cast_to_boolean('isautoapproved') }} as isautoapproved, + cast(outboundrequest as {{ dbt_utils.type_string() }}) as outboundrequest, + cast(trackingcodeurl as {{ dbt_utils.type_string() }}) as trackingcodeurl, + cast(trackingcode as {{ dbt_utils.type_string() }}) as trackingcode, + cast(waitingcancelby as {{ dbt_utils.type_string() }}) as waitingcancelby, + {{ cast_to_boolean('ischangedelivery') }} as ischangedelivery, + cast(estimatecashbackat as {{ dbt_utils.type_string() }}) as estimatecashbackat, + {{ cast_to_boolean('fromnewactivebuyer') }} as fromnewactivebuyer, + {{ cast_to_boolean('iswaitingcancelled') }} as iswaitingcancelled, + {{ cast_to_boolean('fromnewactiveseller') }} as fromnewactiveseller, + cast(waitingcancelreason as {{ dbt_utils.type_string() }}) as waitingcancelreason, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('orders_ab1') }} +-- orders +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/orders_ab3.sql b/models/generated/airbyte_ctes/unibag/orders_ab3.sql new file mode 100644 index 0000000..c222dbd --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/orders_ab3.sql @@ -0,0 +1,74 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('orders_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'code', + adapter.quote('date'), + adapter.quote('hour'), + 'note', + array_to_string('tags'), + adapter.quote('user'), + 'price', + boolean_to_string('banned'), + 'reason', + adapter.quote('source'), + 'status', + 'teamid', + 'payment', + 'remarks', + 'customer', + 'delivery', + boolean_to_string('iscalled'), + 'merchant', + 'pickupat', + 'supplier', + 'createdat', + 'inventory', + 'invoiceid', + boolean_to_string('isdeleted'), + 'promotion', + 'requestid', + 'restockat', + 'sendemail', + 'totalitem', + 'updatedat', + 'useragent', + boolean_to_string('wholesale'), + 'approvedat', + 'cashbackat', + boolean_to_string('ispreorder'), + boolean_to_string('isreviewed'), + 'rejectedat', + 'deliveredat', + 'deliveringat', + 'deliverycode', + 'searchstring', + 'staffapprove', + 'teammemberid', + 'processstatus', + 'hooktimelastat', + boolean_to_string('isassigncoupon'), + boolean_to_string('isautoapproved'), + 'outboundrequest', + 'trackingcodeurl', + 'trackingcode', + 'waitingcancelby', + boolean_to_string('ischangedelivery'), + 'estimatecashbackat', + boolean_to_string('fromnewactivebuyer'), + boolean_to_string('iswaitingcancelled'), + boolean_to_string('fromnewactiveseller'), + 'waitingcancelreason', + ]) }} as _airbyte_orders_hashid, + tmp.* +from {{ ref('orders_ab2') }} tmp +-- orders +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_categories_ab1.sql b/models/generated/airbyte_ctes/unibag/product_categories_ab1.sql new file mode 100644 index 0000000..3b71d62 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_categories_ab1.sql @@ -0,0 +1,27 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_product_categories') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['icon'], ['icon']) }} as icon, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['color'], ['color']) }} as color, + {{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }}, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_array('_airbyte_data', ['covers'], ['covers']) }} as covers, + {{ json_extract_scalar('_airbyte_data', ['featured'], ['featured']) }} as featured, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['totalProduct'], ['totalProduct']) }} as totalproduct, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_product_categories') }} as table_alias +-- product_categories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_categories_ab2.sql b/models/generated/airbyte_ctes/unibag/product_categories_ab2.sql new file mode 100644 index 0000000..ccdf80e --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_categories_ab2.sql @@ -0,0 +1,27 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('product_categories_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(icon as {{ dbt_utils.type_string() }}) as icon, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast(color as {{ dbt_utils.type_string() }}) as color, + cast({{ adapter.quote('order') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('order') }}, + {{ cast_to_boolean('active') }} as active, + covers, + {{ cast_to_boolean('featured') }} as featured, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(totalproduct as {{ dbt_utils.type_float() }}) as totalproduct, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('product_categories_ab1') }} +-- product_categories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_categories_ab3.sql b/models/generated/airbyte_ctes/unibag/product_categories_ab3.sql new file mode 100644 index 0000000..4efd8d0 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_categories_ab3.sql @@ -0,0 +1,27 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('product_categories_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'icon', + adapter.quote('name'), + 'color', + adapter.quote('order'), + boolean_to_string('active'), + array_to_string('covers'), + boolean_to_string('featured'), + 'createdat', + 'updatedat', + 'totalproduct', + ]) }} as _airbyte_product_categories_hashid, + tmp.* +from {{ ref('product_categories_ab2') }} tmp +-- product_categories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_sku_ab1.sql b/models/generated/airbyte_ctes/unibag/product_sku_ab1.sql new file mode 100644 index 0000000..9a8e52a --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_sku_ab1.sql @@ -0,0 +1,48 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_product_sku') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['sku'], ['sku']) }} as sku, + {{ json_extract_scalar('_airbyte_data', ['info'], ['info']) }} as info, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }}, + {{ json_extract_scalar('_airbyte_data', ['brand'], ['brand']) }} as brand, + {{ json_extract_scalar('_airbyte_data', ['cover'], ['cover']) }} as cover, + {{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['author'], ['author']) }} as author, + {{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }}, + {{ json_extract_scalar('_airbyte_data', ['display'], ['display']) }} as display, + {{ json_extract_scalar('_airbyte_data', ['picture'], ['picture']) }} as picture, + {{ json_extract_scalar('_airbyte_data', ['product'], ['product']) }} as product, + {{ json_extract_scalar('_airbyte_data', ['version'], ['version']) }} as {{ adapter.quote('version') }}, + {{ json_extract_scalar('_airbyte_data', ['groupSku'], ['groupSku']) }} as groupsku, + {{ json_extract_scalar('_airbyte_data', ['unitCode'], ['unitCode']) }} as unitcode, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['restockAt'], ['restockAt']) }} as restockat, + {{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['couponInfo'], ['couponInfo']) }} as couponinfo, + {{ json_extract_array('_airbyte_data', ['properties'], ['properties']) }} as properties, + {{ json_extract_scalar('_airbyte_data', ['canPreorder'], ['canPreorder']) }} as canpreorder, + {{ json_extract_scalar('_airbyte_data', ['supplierSku'], ['supplierSku']) }} as suppliersku, + {{ json_extract_scalar('_airbyte_data', ['isOutOfStock'], ['isOutOfStock']) }} as isoutofstock, + {{ json_extract_scalar('_airbyte_data', ['pricePercent'], ['pricePercent']) }} as pricepercent, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_scalar('_airbyte_data', ['quantity'], ['quantity']) }} as quantity, + {{ json_extract_scalar('_airbyte_data', ['displayInventory'], ['displayInventory']) }} as displayinventory, + {{ json_extract_scalar('_airbyte_data', ['showRemainingQuantity'], ['showRemainingQuantity']) }} as showremainingquantity, + {{ json_extract_scalar('_airbyte_data', ['quantity_aibyte_transform'], ['quantity_aibyte_transform']) }} as quantity_aibyte_transform, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_product_sku') }} as table_alias +-- product_sku +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_sku_ab2.sql b/models/generated/airbyte_ctes/unibag/product_sku_ab2.sql new file mode 100644 index 0000000..4a1fb08 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_sku_ab2.sql @@ -0,0 +1,48 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('product_sku_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(sku as {{ dbt_utils.type_string() }}) as sku, + cast(info as {{ dbt_utils.type_string() }}) as info, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }}, + cast(brand as {{ dbt_utils.type_string() }}) as brand, + cast(cover as {{ dbt_utils.type_string() }}) as cover, + cast(price as {{ dbt_utils.type_string() }}) as price, + {{ cast_to_boolean('active') }} as active, + cast(author as {{ dbt_utils.type_string() }}) as author, + cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }}, + {{ cast_to_boolean('display') }} as display, + cast(picture as {{ dbt_utils.type_string() }}) as picture, + cast(product as {{ dbt_utils.type_string() }}) as product, + cast({{ adapter.quote('version') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('version') }}, + cast(groupsku as {{ dbt_utils.type_string() }}) as groupsku, + cast(unitcode as {{ dbt_utils.type_string() }}) as unitcode, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(restockat as {{ dbt_utils.type_string() }}) as restockat, + cast(statistic as {{ dbt_utils.type_string() }}) as statistic, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(couponinfo as {{ dbt_utils.type_string() }}) as couponinfo, + properties, + {{ cast_to_boolean('canpreorder') }} as canpreorder, + cast(suppliersku as {{ dbt_utils.type_string() }}) as suppliersku, + {{ cast_to_boolean('isoutofstock') }} as isoutofstock, + cast(pricepercent as {{ dbt_utils.type_string() }}) as pricepercent, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + {{ cast_to_boolean('displayinventory') }} as displayinventory, + {{ cast_to_boolean('showremainingquantity') }} as showremainingquantity, + cast(quantity as {{ dbt_utils.type_string() }}) as quantity, + cast(quantity_aibyte_transform as {{ dbt_utils.type_string() }}) as quantity_aibyte_transform, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('product_sku_ab1') }} +-- product_sku +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_sku_ab3.sql b/models/generated/airbyte_ctes/unibag/product_sku_ab3.sql new file mode 100644 index 0000000..9323cba --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_sku_ab3.sql @@ -0,0 +1,48 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('product_sku_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'sku', + 'info', + adapter.quote('name'), + adapter.quote('type'), + 'brand', + 'cover', + 'price', + boolean_to_string('active'), + 'author', + adapter.quote('source'), + boolean_to_string('display'), + 'picture', + 'product', + adapter.quote('version'), + 'groupsku', + 'unitcode', + 'createdat', + 'restockat', + 'statistic', + 'updatedat', + 'couponinfo', + array_to_string('properties'), + boolean_to_string('canpreorder'), + 'suppliersku', + boolean_to_string('isoutofstock'), + 'pricepercent', + 'searchstring', + 'quantity', + boolean_to_string('displayinventory'), + boolean_to_string('showremainingquantity'), + 'quantity_aibyte_transform', + ]) }} as _airbyte_product_sku_hashid, + tmp.* +from {{ ref('product_sku_ab2') }} tmp +-- product_sku +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_sku_versions_ab1.sql b/models/generated/airbyte_ctes/unibag/product_sku_versions_ab1.sql new file mode 100644 index 0000000..5cbd21e --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_sku_versions_ab1.sql @@ -0,0 +1,30 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_product_sku_versions') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['sku'], ['sku']) }} as sku, + {{ json_extract_scalar('_airbyte_data', ['info'], ['info']) }} as info, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price, + {{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }}, + {{ json_extract_scalar('_airbyte_data', ['codeSku'], ['codeSku']) }} as codesku, + {{ json_extract_scalar('_airbyte_data', ['picture'], ['picture']) }} as picture, + {{ json_extract_scalar('_airbyte_data', ['product'], ['product']) }} as product, + {{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic, + {{ json_extract_scalar('_airbyte_data', ['version'], ['version']) }} as {{ adapter.quote('version') }}, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_array('_airbyte_data', ['properties'], ['properties']) }} as properties, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_product_sku_versions') }} as table_alias +-- product_sku_versions +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_sku_versions_ab2.sql b/models/generated/airbyte_ctes/unibag/product_sku_versions_ab2.sql new file mode 100644 index 0000000..f30d961 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_sku_versions_ab2.sql @@ -0,0 +1,30 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('product_sku_versions_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(sku as {{ dbt_utils.type_string() }}) as sku, + cast(info as {{ dbt_utils.type_string() }}) as info, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast(price as {{ dbt_utils.type_string() }}) as price, + cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }}, + cast(codesku as {{ dbt_utils.type_string() }}) as codesku, + cast(picture as {{ dbt_utils.type_string() }}) as picture, + cast(product as {{ dbt_utils.type_string() }}) as product, + cast({{ adapter.quote('version') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('version') }}, + cast(statistic as {{ dbt_utils.type_string() }}) as statistic, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + properties, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('product_sku_versions_ab1') }} +-- product_sku_versions +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_sku_versions_ab3.sql b/models/generated/airbyte_ctes/unibag/product_sku_versions_ab3.sql new file mode 100644 index 0000000..5582374 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_sku_versions_ab3.sql @@ -0,0 +1,30 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('product_sku_versions_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'sku', + 'info', + adapter.quote('name'), + 'price', + adapter.quote('source'), + 'codesku', + 'picture', + 'product', + 'statistic', + adapter.quote('version'), + 'createdat', + 'updatedat', + array_to_string('properties'), + ]) }} as _airbyte_product_sku_versions_hashid, + tmp.* +from {{ ref('product_sku_versions_ab2') }} tmp +-- product_sku_versions +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_sub_categories_ab1.sql b/models/generated/airbyte_ctes/unibag/product_sub_categories_ab1.sql new file mode 100644 index 0000000..68d02ac --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_sub_categories_ab1.sql @@ -0,0 +1,25 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_product_sub_categories') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }}, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['parent'], ['parent']) }} as parent, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_scalar('_airbyte_data', ['totalProduct'], ['totalProduct']) }} as totalproduct, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_product_sub_categories') }} as table_alias +-- product_sub_categories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_sub_categories_ab2.sql b/models/generated/airbyte_ctes/unibag/product_sub_categories_ab2.sql new file mode 100644 index 0000000..df6937b --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_sub_categories_ab2.sql @@ -0,0 +1,25 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('product_sub_categories_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast({{ adapter.quote('order') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('order') }}, + {{ cast_to_boolean('active') }} as active, + cast(parent as {{ dbt_utils.type_string() }}) as parent, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + cast(totalproduct as {{ dbt_utils.type_float() }}) as totalproduct, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('product_sub_categories_ab1') }} +-- product_sub_categories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/product_sub_categories_ab3.sql b/models/generated/airbyte_ctes/unibag/product_sub_categories_ab3.sql new file mode 100644 index 0000000..b001ca0 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/product_sub_categories_ab3.sql @@ -0,0 +1,25 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('product_sub_categories_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('name'), + adapter.quote('order'), + boolean_to_string('active'), + 'parent', + 'createdat', + 'updatedat', + 'searchstring', + 'totalproduct', + ]) }} as _airbyte_product_sub_categories_hashid, + tmp.* +from {{ ref('product_sub_categories_ab2') }} tmp +-- product_sub_categories +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/products_ab1.sql b/models/generated/airbyte_ctes/unibag/products_ab1.sql new file mode 100644 index 0000000..c09bfa8 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/products_ab1.sql @@ -0,0 +1,52 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_products') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['desc'], ['desc']) }} as {{ adapter.quote('desc') }}, + {{ json_extract_scalar('_airbyte_data', ['info'], ['info']) }} as info, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['temp'], ['temp']) }} as {{ adapter.quote('temp') }}, + {{ json_extract_scalar('_airbyte_data', ['brand'], ['brand']) }} as brand, + {{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }}, + {{ json_extract_scalar('_airbyte_data', ['price'], ['price']) }} as price, + {{ json_extract_scalar('_airbyte_data', ['score'], ['score']) }} as score, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['author'], ['author']) }} as author, + {{ json_extract_array('_airbyte_data', ['guides'], ['guides']) }} as guides, + {{ json_extract_array('_airbyte_data', ['photos'], ['photos']) }} as photos, + {{ json_extract_array('_airbyte_data', ['videos'], ['videos']) }} as videos, + {{ json_extract_scalar('_airbyte_data', ['quantity'], ['quantity']) }} as quantity, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_array('_airbyte_data', ['documents'], ['documents']) }} as documents, + {{ json_extract_scalar('_airbyte_data', ['shareDesc'], ['shareDesc']) }} as sharedesc, + {{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_array('_airbyte_data', ['categories'], ['categories']) }} as categories, + {{ json_extract_array('_airbyte_data', ['properties'], ['properties']) }} as properties, + {{ json_extract_scalar('_airbyte_data', ['reActiveAt'], ['reActiveAt']) }} as reactiveat, + {{ json_extract_array('_airbyte_data', ['inventories'], ['inventories']) }} as inventories, + {{ json_extract_scalar('_airbyte_data', ['isOutOfStock'], ['isOutOfStock']) }} as isoutofstock, + {{ json_extract_scalar('_airbyte_data', ['pricePercent'], ['pricePercent']) }} as pricepercent, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_array('_airbyte_data', ['subCategories'], ['subCategories']) }} as subcategories, + {{ json_extract_scalar('_airbyte_data', ['inactiveReason'], ['inactiveReason']) }} as inactivereason, + {{ json_extract_scalar('_airbyte_data', ['propertiesMain'], ['propertiesMain']) }} as propertiesmain, + {{ json_extract_scalar('_airbyte_data', ['shareStatistic'], ['shareStatistic']) }} as sharestatistic, + {{ json_extract_scalar('_airbyte_data', ['canIssueInvoice'], ['canIssueInvoice']) }} as canissueinvoice, + {{ json_extract_scalar('_airbyte_data', ['pendingInactive'], ['pendingInactive']) }} as pendinginactive, + {{ json_extract_scalar('_airbyte_data', ['reviewStatistic'], ['reviewStatistic']) }} as reviewstatistic, + {{ json_extract_scalar('_airbyte_data', ['pendingInactiveAt'], ['pendingInactiveAt']) }} as pendinginactiveat, + {{ json_extract_array('_airbyte_data', ['highlightProperties'], ['highlightProperties']) }} as highlightproperties, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_products') }} as table_alias +-- products +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/products_ab2.sql b/models/generated/airbyte_ctes/unibag/products_ab2.sql new file mode 100644 index 0000000..f0402a6 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/products_ab2.sql @@ -0,0 +1,52 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('products_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('desc') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('desc') }}, + cast(info as {{ dbt_utils.type_string() }}) as info, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast({{ adapter.quote('temp') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('temp') }}, + cast(brand as {{ dbt_utils.type_string() }}) as brand, + cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }}, + cast(price as {{ dbt_utils.type_string() }}) as price, + cast(score as {{ dbt_utils.type_string() }}) as score, + {{ cast_to_boolean('active') }} as active, + cast(author as {{ dbt_utils.type_string() }}) as author, + guides, + photos, + videos, + cast(quantity as {{ dbt_utils.type_float() }}) as quantity, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + documents, + cast(sharedesc as {{ dbt_utils.type_string() }}) as sharedesc, + cast(statistic as {{ dbt_utils.type_string() }}) as statistic, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + categories, + properties, + cast(reactiveat as {{ dbt_utils.type_string() }}) as reactiveat, + inventories, + {{ cast_to_boolean('isoutofstock') }} as isoutofstock, + cast(pricepercent as {{ dbt_utils.type_string() }}) as pricepercent, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + subcategories, + cast(inactivereason as {{ dbt_utils.type_string() }}) as inactivereason, + cast(propertiesmain as {{ dbt_utils.type_string() }}) as propertiesmain, + cast(sharestatistic as {{ dbt_utils.type_string() }}) as sharestatistic, + {{ cast_to_boolean('canissueinvoice') }} as canissueinvoice, + {{ cast_to_boolean('pendinginactive') }} as pendinginactive, + cast(reviewstatistic as {{ dbt_utils.type_string() }}) as reviewstatistic, + cast(pendinginactiveat as {{ dbt_utils.type_string() }}) as pendinginactiveat, + highlightproperties, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('products_ab1') }} +-- products +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/products_ab3.sql b/models/generated/airbyte_ctes/unibag/products_ab3.sql new file mode 100644 index 0000000..1f52628 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/products_ab3.sql @@ -0,0 +1,52 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('products_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('desc'), + 'info', + adapter.quote('name'), + adapter.quote('temp'), + 'brand', + adapter.quote('order'), + 'price', + 'score', + boolean_to_string('active'), + 'author', + array_to_string('guides'), + array_to_string('photos'), + array_to_string('videos'), + 'quantity', + 'createdat', + array_to_string('documents'), + 'sharedesc', + 'statistic', + 'updatedat', + array_to_string('categories'), + array_to_string('properties'), + 'reactiveat', + array_to_string('inventories'), + boolean_to_string('isoutofstock'), + 'pricepercent', + 'searchstring', + array_to_string('subcategories'), + 'inactivereason', + 'propertiesmain', + 'sharestatistic', + boolean_to_string('canissueinvoice'), + boolean_to_string('pendinginactive'), + 'reviewstatistic', + 'pendinginactiveat', + array_to_string('highlightproperties'), + ]) }} as _airbyte_products_hashid, + tmp.* +from {{ ref('products_ab2') }} tmp +-- products +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/promotion_orders_ab1.sql b/models/generated/airbyte_ctes/unibag/promotion_orders_ab1.sql new file mode 100644 index 0000000..54a3c64 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/promotion_orders_ab1.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_promotion_orders') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['order'], ['order']) }} as {{ adapter.quote('order') }}, + {{ json_extract_scalar('_airbyte_data', ['title'], ['title']) }} as title, + {{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status, + {{ json_extract_scalar('_airbyte_data', ['supplier'], ['supplier']) }} as supplier, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['promotion'], ['promotion']) }} as promotion, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['cashbackAt'], ['cashbackAt']) }} as cashbackat, + {{ json_extract_scalar('_airbyte_data', ['commission'], ['commission']) }} as commission, + {{ json_extract_scalar('_airbyte_data', ['isRejected'], ['isRejected']) }} as isrejected, + {{ json_extract_scalar('_airbyte_data', ['quantityPromotion'], ['quantityPromotion']) }} as quantitypromotion, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_promotion_orders') }} as table_alias +-- promotion_orders +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/promotion_orders_ab2.sql b/models/generated/airbyte_ctes/unibag/promotion_orders_ab2.sql new file mode 100644 index 0000000..7005f92 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/promotion_orders_ab2.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('promotion_orders_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast({{ adapter.quote('order') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('order') }}, + cast(title as {{ dbt_utils.type_string() }}) as title, + cast(status as {{ dbt_utils.type_string() }}) as status, + cast(supplier as {{ dbt_utils.type_string() }}) as supplier, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(promotion as {{ dbt_utils.type_string() }}) as promotion, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(cashbackat as {{ dbt_utils.type_string() }}) as cashbackat, + cast(commission as {{ dbt_utils.type_float() }}) as commission, + {{ cast_to_boolean('isrejected') }} as isrejected, + cast(quantitypromotion as {{ dbt_utils.type_float() }}) as quantitypromotion, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('promotion_orders_ab1') }} +-- promotion_orders +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/promotion_orders_ab3.sql b/models/generated/airbyte_ctes/unibag/promotion_orders_ab3.sql new file mode 100644 index 0000000..759fde9 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/promotion_orders_ab3.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('promotion_orders_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('user'), + adapter.quote('order'), + 'title', + 'status', + 'supplier', + 'createdat', + 'promotion', + 'updatedat', + 'cashbackat', + 'commission', + boolean_to_string('isrejected'), + 'quantitypromotion', + ]) }} as _airbyte_promotion_orders_hashid, + tmp.* +from {{ ref('promotion_orders_ab2') }} tmp +-- promotion_orders +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/promotions_ab1.sql b/models/generated/airbyte_ctes/unibag/promotions_ab1.sql new file mode 100644 index 0000000..14f319d --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/promotions_ab1.sql @@ -0,0 +1,34 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_promotions') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['rest'], ['rest']) }} as rest, + {{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }}, + {{ json_extract_scalar('_airbyte_data', ['endAt'], ['endAt']) }} as endat, + {{ json_extract_scalar('_airbyte_data', ['title'], ['title']) }} as title, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }}, + {{ json_extract_scalar('_airbyte_data', ['startAt'], ['startAt']) }} as startat, + {{ json_extract_scalar('_airbyte_data', ['applyFor'], ['applyFor']) }} as applyfor, + {{ json_extract_scalar('_airbyte_data', ['quantity'], ['quantity']) }} as quantity, + {{ json_extract_scalar('_airbyte_data', ['articleID'], ['articleID']) }} as articleid, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_scalar('_airbyte_data', ['sharePercent'], ['sharePercent']) }} as sharepercent, + {{ json_extract_scalar('_airbyte_data', ['conditionForUser'], ['conditionForUser']) }} as conditionforuser, + {{ json_extract_scalar('_airbyte_data', ['isUnlimitedQuantity'], ['isUnlimitedQuantity']) }} as isunlimitedquantity, + {{ json_extract_scalar('_airbyte_data', ['isApplyForOrderWholesale'], ['isApplyForOrderWholesale']) }} as isapplyfororderwholesale, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_promotions') }} as table_alias +-- promotions +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/promotions_ab2.sql b/models/generated/airbyte_ctes/unibag/promotions_ab2.sql new file mode 100644 index 0000000..866c880 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/promotions_ab2.sql @@ -0,0 +1,34 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('promotions_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(rest as {{ dbt_utils.type_float() }}) as rest, + cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }}, + cast(endat as {{ dbt_utils.type_string() }}) as endat, + cast(title as {{ dbt_utils.type_string() }}) as title, + {{ cast_to_boolean('active') }} as active, + cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }}, + cast(startat as {{ dbt_utils.type_string() }}) as startat, + cast(applyfor as {{ dbt_utils.type_string() }}) as applyfor, + cast(quantity as {{ dbt_utils.type_float() }}) as quantity, + cast(articleid as {{ dbt_utils.type_string() }}) as articleid, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + cast(sharepercent as {{ dbt_utils.type_string() }}) as sharepercent, + cast(conditionforuser as {{ dbt_utils.type_string() }}) as conditionforuser, + {{ cast_to_boolean('isunlimitedquantity') }} as isunlimitedquantity, + {{ cast_to_boolean('isapplyfororderwholesale') }} as isapplyfororderwholesale, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('promotions_ab1') }} +-- promotions +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/promotions_ab3.sql b/models/generated/airbyte_ctes/unibag/promotions_ab3.sql new file mode 100644 index 0000000..0a9ff20 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/promotions_ab3.sql @@ -0,0 +1,34 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('promotions_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'rest', + adapter.quote('type'), + 'endat', + 'title', + boolean_to_string('active'), + adapter.quote('options'), + 'startat', + 'applyfor', + 'quantity', + 'articleid', + 'createdat', + 'updatedat', + 'searchstring', + 'sharepercent', + 'conditionforuser', + boolean_to_string('isunlimitedquantity'), + boolean_to_string('isapplyfororderwholesale'), + ]) }} as _airbyte_promotions_hashid, + tmp.* +from {{ ref('promotions_ab2') }} tmp +-- promotions +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/referrals_ab1.sql b/models/generated/airbyte_ctes/unibag/referrals_ab1.sql new file mode 100644 index 0000000..e89545d --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/referrals_ab1.sql @@ -0,0 +1,21 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_referrals') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['invitee'], ['invitee']) }} as invitee, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['fromSystem'], ['fromSystem']) }} as fromsystem, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_referrals') }} as table_alias +-- referrals +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/referrals_ab2.sql b/models/generated/airbyte_ctes/unibag/referrals_ab2.sql new file mode 100644 index 0000000..88155db --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/referrals_ab2.sql @@ -0,0 +1,21 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('referrals_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast(invitee as {{ dbt_utils.type_string() }}) as invitee, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + {{ cast_to_boolean('fromsystem') }} as fromsystem, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('referrals_ab1') }} +-- referrals +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/referrals_ab3.sql b/models/generated/airbyte_ctes/unibag/referrals_ab3.sql new file mode 100644 index 0000000..cbb62b1 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/referrals_ab3.sql @@ -0,0 +1,21 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('referrals_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('user'), + 'invitee', + 'createdat', + boolean_to_string('fromsystem'), + ]) }} as _airbyte_referrals_hashid, + tmp.* +from {{ ref('referrals_ab2') }} tmp +-- referrals +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/suppliers_ab1.sql b/models/generated/airbyte_ctes/unibag/suppliers_ab1.sql new file mode 100644 index 0000000..eea9006 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/suppliers_ab1.sql @@ -0,0 +1,40 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_suppliers') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['tax'], ['tax']) }} as tax, + {{ json_extract_scalar('_airbyte_data', ['bank'], ['bank']) }} as bank, + {{ json_extract_scalar('_airbyte_data', ['logo'], ['logo']) }} as logo, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['checkSum'], ['checkSum']) }} as checksum, + {{ json_extract_scalar('_airbyte_data', ['checksum'], ['checksum']) }} as checksum_1, + {{ json_extract_scalar('_airbyte_data', ['location'], ['location']) }} as {{ adapter.quote('location') }}, + {{ json_extract_array('_airbyte_data', ['contracts'], ['contracts']) }} as contracts, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_array('_airbyte_data', ['documents'], ['documents']) }} as documents, + {{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_array('_airbyte_data', ['categories'], ['categories']) }} as categories, + {{ json_extract_array('_airbyte_data', ['inventories'], ['inventories']) }} as inventories, + {{ json_extract_scalar('_airbyte_data', ['identifyCode'], ['identifyCode']) }} as identifycode, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_scalar('_airbyte_data', ['contractNumber'], ['contractNumber']) }} as contractnumber, + {{ json_extract_scalar('_airbyte_data', ['reviewStatistic'], ['reviewStatistic']) }} as reviewstatistic, + {{ json_extract_scalar('_airbyte_data', ['contractSignedAt'], ['contractSignedAt']) }} as contractsignedat, + {{ json_extract_array('_airbyte_data', ['emailForInvoices'], ['emailForInvoices']) }} as emailforinvoices, + {{ json_extract_scalar('_airbyte_data', ['contractExpiredAt'], ['contractExpiredAt']) }} as contractexpiredat, + {{ json_extract_scalar('_airbyte_data', ['sendInvoiceRequestEveryDay'], ['sendInvoiceRequestEveryDay']) }} as sendinvoicerequesteveryday, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_suppliers') }} as table_alias +-- suppliers +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/suppliers_ab2.sql b/models/generated/airbyte_ctes/unibag/suppliers_ab2.sql new file mode 100644 index 0000000..59199cb --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/suppliers_ab2.sql @@ -0,0 +1,40 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('suppliers_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(tax as {{ dbt_utils.type_string() }}) as tax, + cast(bank as {{ dbt_utils.type_string() }}) as bank, + cast(logo as {{ dbt_utils.type_string() }}) as logo, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + {{ cast_to_boolean('active') }} as active, + cast(checksum as {{ dbt_utils.type_string() }}) as checksum, + cast(checksum_1 as {{ dbt_utils.type_string() }}) as checksum_1, + cast({{ adapter.quote('location') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('location') }}, + contracts, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + documents, + cast(statistic as {{ dbt_utils.type_string() }}) as statistic, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + categories, + inventories, + cast(identifycode as {{ dbt_utils.type_float() }}) as identifycode, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + cast(contractnumber as {{ dbt_utils.type_string() }}) as contractnumber, + cast(reviewstatistic as {{ dbt_utils.type_string() }}) as reviewstatistic, + cast(contractsignedat as {{ dbt_utils.type_string() }}) as contractsignedat, + emailforinvoices, + cast(contractexpiredat as {{ dbt_utils.type_string() }}) as contractexpiredat, + {{ cast_to_boolean('sendinvoicerequesteveryday') }} as sendinvoicerequesteveryday, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('suppliers_ab1') }} +-- suppliers +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/suppliers_ab3.sql b/models/generated/airbyte_ctes/unibag/suppliers_ab3.sql new file mode 100644 index 0000000..76f1c42 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/suppliers_ab3.sql @@ -0,0 +1,40 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('suppliers_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'tax', + 'bank', + 'logo', + adapter.quote('name'), + boolean_to_string('active'), + 'checksum', + 'checksum_1', + adapter.quote('location'), + array_to_string('contracts'), + 'createdat', + array_to_string('documents'), + 'statistic', + 'updatedat', + array_to_string('categories'), + array_to_string('inventories'), + 'identifycode', + 'searchstring', + 'contractnumber', + 'reviewstatistic', + 'contractsignedat', + array_to_string('emailforinvoices'), + 'contractexpiredat', + boolean_to_string('sendinvoicerequesteveryday'), + ]) }} as _airbyte_suppliers_hashid, + tmp.* +from {{ ref('suppliers_ab2') }} tmp +-- suppliers +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/team_activities_ab1.sql b/models/generated/airbyte_ctes/unibag/team_activities_ab1.sql new file mode 100644 index 0000000..9929ea2 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/team_activities_ab1.sql @@ -0,0 +1,23 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_team_activities') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['team'], ['team']) }} as team, + {{ json_extract_scalar('_airbyte_data', ['action'], ['action']) }} as {{ adapter.quote('action') }}, + {{ json_extract_scalar('_airbyte_data', ['options'], ['options']) }} as {{ adapter.quote('options') }}, + {{ json_extract_scalar('_airbyte_data', ['targetId'], ['targetId']) }} as targetid, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['createdBy'], ['createdBy']) }} as createdby, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_team_activities') }} as table_alias +-- team_activities +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/team_activities_ab2.sql b/models/generated/airbyte_ctes/unibag/team_activities_ab2.sql new file mode 100644 index 0000000..cf0a002 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/team_activities_ab2.sql @@ -0,0 +1,23 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('team_activities_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(team as {{ dbt_utils.type_string() }}) as team, + cast({{ adapter.quote('action') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('action') }}, + cast({{ adapter.quote('options') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('options') }}, + cast(targetid as {{ dbt_utils.type_string() }}) as targetid, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(createdby as {{ dbt_utils.type_string() }}) as createdby, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('team_activities_ab1') }} +-- team_activities +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/team_activities_ab3.sql b/models/generated/airbyte_ctes/unibag/team_activities_ab3.sql new file mode 100644 index 0000000..107bd5a --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/team_activities_ab3.sql @@ -0,0 +1,23 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('team_activities_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'team', + adapter.quote('action'), + adapter.quote('options'), + 'targetid', + 'createdat', + 'createdby', + ]) }} as _airbyte_team_activities_hashid, + tmp.* +from {{ ref('team_activities_ab2') }} tmp +-- team_activities +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/team_bonus_ab1.sql b/models/generated/airbyte_ctes/unibag/team_bonus_ab1.sql new file mode 100644 index 0000000..87ebed5 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/team_bonus_ab1.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_team_bonus') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['team'], ['team']) }} as team, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status, + {{ json_extract_scalar('_airbyte_data', ['percent'], ['percent']) }} as {{ adapter.quote('percent') }}, + {{ json_extract_scalar('_airbyte_data', ['targetId'], ['targetId']) }} as targetid, + {{ json_extract_scalar('_airbyte_data', ['teamName'], ['teamName']) }} as teamname, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['teamLevel'], ['teamLevel']) }} as teamlevel, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['commission'], ['commission']) }} as commission, + {{ json_extract_scalar('_airbyte_data', ['teamMember'], ['teamMember']) }} as teammember, + {{ json_extract_scalar('_airbyte_data', ['teamPromotion'], ['teamPromotion']) }} as teampromotion, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_team_bonus') }} as table_alias +-- team_bonus +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/team_bonus_ab2.sql b/models/generated/airbyte_ctes/unibag/team_bonus_ab2.sql new file mode 100644 index 0000000..3ff5a1e --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/team_bonus_ab2.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('team_bonus_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(team as {{ dbt_utils.type_string() }}) as team, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast(status as {{ dbt_utils.type_string() }}) as status, + cast({{ adapter.quote('percent') }} as {{ dbt_utils.type_float() }}) as {{ adapter.quote('percent') }}, + cast(targetid as {{ dbt_utils.type_string() }}) as targetid, + cast(teamname as {{ dbt_utils.type_string() }}) as teamname, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(teamlevel as {{ dbt_utils.type_float() }}) as teamlevel, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(commission as {{ dbt_utils.type_float() }}) as commission, + cast(teammember as {{ dbt_utils.type_string() }}) as teammember, + cast(teampromotion as {{ dbt_utils.type_string() }}) as teampromotion, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('team_bonus_ab1') }} +-- team_bonus +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/team_bonus_ab3.sql b/models/generated/airbyte_ctes/unibag/team_bonus_ab3.sql new file mode 100644 index 0000000..555a774 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/team_bonus_ab3.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('team_bonus_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'team', + adapter.quote('user'), + 'status', + adapter.quote('percent'), + 'targetid', + 'teamname', + 'createdat', + 'teamlevel', + 'updatedat', + 'commission', + 'teammember', + 'teampromotion', + ]) }} as _airbyte_team_bonus_hashid, + tmp.* +from {{ ref('team_bonus_ab2') }} tmp +-- team_bonus +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/team_members_ab1.sql b/models/generated/airbyte_ctes/unibag/team_members_ab1.sql new file mode 100644 index 0000000..55f902c --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/team_members_ab1.sql @@ -0,0 +1,31 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_team_members') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['role'], ['role']) }} as {{ adapter.quote('role') }}, + {{ json_extract_scalar('_airbyte_data', ['team'], ['team']) }} as team, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['isLeft'], ['isLeft']) }} as isleft, + {{ json_extract_scalar('_airbyte_data', ['leftAt'], ['leftAt']) }} as leftat, + {{ json_extract_scalar('_airbyte_data', ['joinedAt'], ['joinedAt']) }} as joinedat, + {{ json_extract_scalar('_airbyte_data', ['roleCode'], ['roleCode']) }} as rolecode, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['isRemovedBy'], ['isRemovedBy']) }} as isremovedby, + {{ json_extract_scalar('_airbyte_data', ['firstOrderAt'], ['firstOrderAt']) }} as firstorderat, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_scalar('_airbyte_data', ['isMemberHomegrown'], ['isMemberHomegrown']) }} as ismemberhomegrown, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_team_members') }} as table_alias +-- team_members +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/team_members_ab2.sql b/models/generated/airbyte_ctes/unibag/team_members_ab2.sql new file mode 100644 index 0000000..ca29b11 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/team_members_ab2.sql @@ -0,0 +1,31 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('team_members_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast({{ adapter.quote('role') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('role') }}, + cast(team as {{ dbt_utils.type_string() }}) as team, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + {{ cast_to_boolean('isleft') }} as isleft, + cast(leftat as {{ dbt_utils.type_string() }}) as leftat, + cast(joinedat as {{ dbt_utils.type_string() }}) as joinedat, + cast(rolecode as {{ dbt_utils.type_float() }}) as rolecode, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(statistic as {{ dbt_utils.type_string() }}) as statistic, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(isremovedby as {{ dbt_utils.type_string() }}) as isremovedby, + cast(firstorderat as {{ dbt_utils.type_string() }}) as firstorderat, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + {{ cast_to_boolean('ismemberhomegrown') }} as ismemberhomegrown, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('team_members_ab1') }} +-- team_members +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/team_members_ab3.sql b/models/generated/airbyte_ctes/unibag/team_members_ab3.sql new file mode 100644 index 0000000..cb2a11b --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/team_members_ab3.sql @@ -0,0 +1,31 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('team_members_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + adapter.quote('role'), + 'team', + adapter.quote('user'), + boolean_to_string('isleft'), + 'leftat', + 'joinedat', + 'rolecode', + 'createdat', + 'statistic', + 'updatedat', + 'isremovedby', + 'firstorderat', + 'searchstring', + boolean_to_string('ismemberhomegrown'), + ]) }} as _airbyte_team_members_hashid, + tmp.* +from {{ ref('team_members_ab2') }} tmp +-- team_members +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/teams_ab1.sql b/models/generated/airbyte_ctes/unibag/teams_ab1.sql new file mode 100644 index 0000000..1d59bba --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/teams_ab1.sql @@ -0,0 +1,34 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_teams') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code, + {{ json_extract_scalar('_airbyte_data', ['desc'], ['desc']) }} as {{ adapter.quote('desc') }}, + {{ json_extract_scalar('_airbyte_data', ['logo'], ['logo']) }} as logo, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['level'], ['level']) }} as {{ adapter.quote('level') }}, + {{ json_extract_scalar('_airbyte_data', ['active'], ['active']) }} as active, + {{ json_extract_scalar('_airbyte_data', ['isFull'], ['isFull']) }} as isfull, + {{ json_extract_scalar('_airbyte_data', ['cityCode'], ['cityCode']) }} as citycode, + {{ json_extract_scalar('_airbyte_data', ['adminUser'], ['adminUser']) }} as adminuser, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['inviteLink'], ['inviteLink']) }} as invitelink, + {{ json_extract_scalar('_airbyte_data', ['information'], ['information']) }} as information, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_scalar('_airbyte_data', ['inactiveReason'], ['inactiveReason']) }} as inactivereason, + {{ json_extract_scalar('_airbyte_data', ['changingNameCount'], ['changingNameCount']) }} as changingnamecount, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_teams') }} as table_alias +-- teams +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/teams_ab2.sql b/models/generated/airbyte_ctes/unibag/teams_ab2.sql new file mode 100644 index 0000000..bb0193c --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/teams_ab2.sql @@ -0,0 +1,34 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('teams_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(code as {{ dbt_utils.type_string() }}) as code, + cast({{ adapter.quote('desc') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('desc') }}, + cast(logo as {{ dbt_utils.type_string() }}) as logo, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast({{ adapter.quote('level') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('level') }}, + {{ cast_to_boolean('active') }} as active, + {{ cast_to_boolean('isfull') }} as isfull, + cast(citycode as {{ dbt_utils.type_float() }}) as citycode, + cast(adminuser as {{ dbt_utils.type_string() }}) as adminuser, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(statistic as {{ dbt_utils.type_string() }}) as statistic, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(invitelink as {{ dbt_utils.type_string() }}) as invitelink, + cast(information as {{ dbt_utils.type_string() }}) as information, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + cast(inactivereason as {{ dbt_utils.type_string() }}) as inactivereason, + cast(changingnamecount as {{ dbt_utils.type_float() }}) as changingnamecount, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('teams_ab1') }} +-- teams +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/teams_ab3.sql b/models/generated/airbyte_ctes/unibag/teams_ab3.sql new file mode 100644 index 0000000..36dc595 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/teams_ab3.sql @@ -0,0 +1,34 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('teams_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'code', + adapter.quote('desc'), + 'logo', + adapter.quote('name'), + adapter.quote('level'), + boolean_to_string('active'), + boolean_to_string('isfull'), + 'citycode', + 'adminuser', + 'createdat', + 'statistic', + 'updatedat', + 'invitelink', + 'information', + 'searchstring', + 'inactivereason', + 'changingnamecount', + ]) }} as _airbyte_teams_hashid, + tmp.* +from {{ ref('teams_ab2') }} tmp +-- teams +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/user_identifications_ab1.sql b/models/generated/airbyte_ctes/unibag/user_identifications_ab1.sql new file mode 100644 index 0000000..54c9bb1 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/user_identifications_ab1.sql @@ -0,0 +1,38 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_user_identifications') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['dob'], ['dob']) }} as dob, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['note'], ['note']) }} as note, + {{ json_extract_scalar('_airbyte_data', ['type'], ['type']) }} as {{ adapter.quote('type') }}, + {{ json_extract_scalar('_airbyte_data', ['user'], ['user']) }} as {{ adapter.quote('user') }}, + {{ json_extract_scalar('_airbyte_data', ['gender'], ['gender']) }} as gender, + {{ json_extract_scalar('_airbyte_data', ['nation'], ['nation']) }} as nation, + {{ json_extract_scalar('_airbyte_data', ['number'], ['number']) }} as {{ adapter.quote('number') }}, + {{ json_extract_scalar('_airbyte_data', ['status'], ['status']) }} as status, + {{ json_extract_scalar('_airbyte_data', ['address'], ['address']) }} as address, + {{ json_extract_scalar('_airbyte_data', ['dobDate'], ['dobDate']) }} as dobdate, + {{ json_extract_scalar('_airbyte_data', ['backSide'], ['backSide']) }} as backside, + {{ json_extract_scalar('_airbyte_data', ['birthday'], ['birthday']) }} as birthday, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['frontSide'], ['frontSide']) }} as frontside, + {{ json_extract_scalar('_airbyte_data', ['issueDate'], ['issueDate']) }} as issuedate, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['expiryDate'], ['expiryDate']) }} as expirydate, + {{ json_extract_scalar('_airbyte_data', ['issuePlace'], ['issuePlace']) }} as issueplace, + {{ json_extract_scalar('_airbyte_data', ['timeUpdate'], ['timeUpdate']) }} as timeupdate, + {{ json_extract_scalar('_airbyte_data', ['detectInformation'], ['detectInformation']) }} as detectinformation, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_user_identifications') }} as table_alias +-- user_identifications +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/user_identifications_ab2.sql b/models/generated/airbyte_ctes/unibag/user_identifications_ab2.sql new file mode 100644 index 0000000..1fcdceb --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/user_identifications_ab2.sql @@ -0,0 +1,38 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('user_identifications_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(dob as {{ dbt_utils.type_string() }}) as dob, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast(note as {{ dbt_utils.type_string() }}) as note, + cast({{ adapter.quote('type') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('type') }}, + cast({{ adapter.quote('user') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('user') }}, + cast(gender as {{ dbt_utils.type_string() }}) as gender, + cast(nation as {{ dbt_utils.type_string() }}) as nation, + cast({{ adapter.quote('number') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('number') }}, + cast(status as {{ dbt_utils.type_string() }}) as status, + cast(address as {{ dbt_utils.type_string() }}) as address, + cast(dobdate as {{ dbt_utils.type_string() }}) as dobdate, + cast(backside as {{ dbt_utils.type_string() }}) as backside, + cast(birthday as {{ dbt_utils.type_string() }}) as birthday, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(frontside as {{ dbt_utils.type_string() }}) as frontside, + cast(issuedate as {{ dbt_utils.type_string() }}) as issuedate, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(expirydate as {{ dbt_utils.type_string() }}) as expirydate, + cast(issueplace as {{ dbt_utils.type_string() }}) as issueplace, + cast(timeupdate as {{ dbt_utils.type_float() }}) as timeupdate, + cast(detectinformation as {{ dbt_utils.type_string() }}) as detectinformation, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('user_identifications_ab1') }} +-- user_identifications +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/user_identifications_ab3.sql b/models/generated/airbyte_ctes/unibag/user_identifications_ab3.sql new file mode 100644 index 0000000..e406266 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/user_identifications_ab3.sql @@ -0,0 +1,38 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('user_identifications_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'dob', + adapter.quote('name'), + 'note', + adapter.quote('type'), + adapter.quote('user'), + 'gender', + 'nation', + adapter.quote('number'), + 'status', + 'address', + 'dobdate', + 'backside', + 'birthday', + 'createdat', + 'frontside', + 'issuedate', + 'updatedat', + 'expirydate', + 'issueplace', + 'timeupdate', + 'detectinformation', + ]) }} as _airbyte_user_identifications_hashid, + tmp.* +from {{ ref('user_identifications_ab2') }} tmp +-- user_identifications +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/users_ab1.sql b/models/generated/airbyte_ctes/unibag/users_ab1.sql new file mode 100644 index 0000000..8327097 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/users_ab1.sql @@ -0,0 +1,44 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_users') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code, + {{ json_extract_scalar('_airbyte_data', ['info'], ['info']) }} as info, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['team'], ['team']) }} as team, + {{ json_extract_scalar('_airbyte_data', ['zalo'], ['zalo']) }} as zalo, + {{ json_extract_scalar('_airbyte_data', ['email'], ['email']) }} as email, + {{ json_extract_scalar('_airbyte_data', ['phone'], ['phone']) }} as phone, + {{ json_extract_scalar('_airbyte_data', ['avatar'], ['avatar']) }} as avatar, + {{ json_extract_scalar('_airbyte_data', ['banned'], ['banned']) }} as banned, + {{ json_extract_scalar('_airbyte_data', ['segment'], ['segment']) }} as segment, + {{ json_extract_scalar('_airbyte_data', ['facebook'], ['facebook']) }} as facebook, + {{ json_extract_scalar('_airbyte_data', ['hasOrder'], ['hasOrder']) }} as hasorder, + {{ json_extract_scalar('_airbyte_data', ['referral'], ['referral']) }} as referral, + {{ json_extract_array('_airbyte_data', ['segments'], ['segments']) }} as segments, + {{ json_extract_scalar('_airbyte_data', ['createdAt'], ['createdAt']) }} as createdat, + {{ json_extract_scalar('_airbyte_data', ['statistic'], ['statistic']) }} as statistic, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['membership'], ['membership']) }} as membership, + {{ json_extract_scalar('_airbyte_data', ['lastOrderAt'], ['lastOrderAt']) }} as lastorderat, + {{ json_extract_scalar('_airbyte_data', ['firstOrderAt'], ['firstOrderAt']) }} as firstorderat, + {{ json_extract_scalar('_airbyte_data', ['registerFrom'], ['registerFrom']) }} as registerfrom, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + {{ json_extract_scalar('_airbyte_data', ['adjustTracker'], ['adjustTracker']) }} as adjusttracker, + {{ json_extract_scalar('_airbyte_data', ['isUpdatedInfo'], ['isUpdatedInfo']) }} as isupdatedinfo, + {{ json_extract_scalar('_airbyte_data', ['identification'], ['identification']) }} as identification, + {{ json_extract_scalar('_airbyte_data', ['lastActivatedAt'], ['lastActivatedAt']) }} as lastactivatedat, + {{ json_extract_scalar('_airbyte_data', ['lastViewNotificationAt'], ['lastViewNotificationAt']) }} as lastviewnotificationat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_users') }} as table_alias +-- users +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/users_ab2.sql b/models/generated/airbyte_ctes/unibag/users_ab2.sql new file mode 100644 index 0000000..b3e92a0 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/users_ab2.sql @@ -0,0 +1,44 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('users_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(code as {{ dbt_utils.type_string() }}) as code, + cast(info as {{ dbt_utils.type_string() }}) as info, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast(team as {{ dbt_utils.type_string() }}) as team, + cast(zalo as {{ dbt_utils.type_string() }}) as zalo, + cast(email as {{ dbt_utils.type_string() }}) as email, + cast(phone as {{ dbt_utils.type_string() }}) as phone, + cast(avatar as {{ dbt_utils.type_string() }}) as avatar, + {{ cast_to_boolean('banned') }} as banned, + cast(segment as {{ dbt_utils.type_string() }}) as segment, + cast(facebook as {{ dbt_utils.type_string() }}) as facebook, + {{ cast_to_boolean('hasorder') }} as hasorder, + cast(referral as {{ dbt_utils.type_string() }}) as referral, + segments, + cast(createdat as {{ dbt_utils.type_string() }}) as createdat, + cast(statistic as {{ dbt_utils.type_string() }}) as statistic, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(membership as {{ dbt_utils.type_string() }}) as membership, + cast(lastorderat as {{ dbt_utils.type_string() }}) as lastorderat, + cast(firstorderat as {{ dbt_utils.type_string() }}) as firstorderat, + cast(registerfrom as {{ dbt_utils.type_string() }}) as registerfrom, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + cast(adjusttracker as {{ dbt_utils.type_string() }}) as adjusttracker, + {{ cast_to_boolean('isupdatedinfo') }} as isupdatedinfo, + cast(identification as {{ dbt_utils.type_string() }}) as identification, + cast(lastactivatedat as {{ dbt_utils.type_string() }}) as lastactivatedat, + cast(lastviewnotificationat as {{ dbt_utils.type_string() }}) as lastviewnotificationat, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('users_ab1') }} +-- users +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/users_ab3.sql b/models/generated/airbyte_ctes/unibag/users_ab3.sql new file mode 100644 index 0000000..1f54025 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/users_ab3.sql @@ -0,0 +1,44 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('users_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'code', + 'info', + adapter.quote('name'), + 'team', + 'zalo', + 'email', + 'phone', + 'avatar', + boolean_to_string('banned'), + 'segment', + 'facebook', + boolean_to_string('hasorder'), + 'referral', + array_to_string('segments'), + 'createdat', + 'statistic', + 'updatedat', + 'membership', + 'lastorderat', + 'firstorderat', + 'registerfrom', + 'searchstring', + 'adjusttracker', + boolean_to_string('isupdatedinfo'), + 'identification', + 'lastactivatedat', + 'lastviewnotificationat', + ]) }} as _airbyte_users_hashid, + tmp.* +from {{ ref('users_ab2') }} tmp +-- users +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/wards_ab1.sql b/models/generated/airbyte_ctes/unibag/wards_ab1.sql new file mode 100644 index 0000000..e595ee4 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/wards_ab1.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to parse JSON blob stored in a single column and extract into separated field columns as described by the JSON Schema +-- depends_on: {{ source('unibag', '_airbyte_raw_wards') }} +select + {{ json_extract_scalar('_airbyte_data', ['_id'], ['_id']) }} as _id, + {{ json_extract_scalar('_airbyte_data', ['city'], ['city']) }} as city, + {{ json_extract_scalar('_airbyte_data', ['code'], ['code']) }} as code, + {{ json_extract_scalar('_airbyte_data', ['name'], ['name']) }} as {{ adapter.quote('name') }}, + {{ json_extract_scalar('_airbyte_data', ['slug'], ['slug']) }} as slug, + {{ json_extract_scalar('_airbyte_data', ['tncId'], ['tncId']) }} as tncid, + {{ json_extract_scalar('_airbyte_data', ['cityId'], ['cityId']) }} as cityid, + {{ json_extract_scalar('_airbyte_data', ['source'], ['source']) }} as {{ adapter.quote('source') }}, + {{ json_extract_scalar('_airbyte_data', ['tncCode'], ['tncCode']) }} as tnccode, + {{ json_extract_scalar('_airbyte_data', ['district'], ['district']) }} as district, + {{ json_extract_scalar('_airbyte_data', ['gidoCode'], ['gidoCode']) }} as gidocode, + {{ json_extract_scalar('_airbyte_data', ['osirisId'], ['osirisId']) }} as osirisid, + {{ json_extract_scalar('_airbyte_data', ['updatedAt'], ['updatedAt']) }} as updatedat, + {{ json_extract_scalar('_airbyte_data', ['districtId'], ['districtId']) }} as districtid, + {{ json_extract_scalar('_airbyte_data', ['provinceId'], ['provinceId']) }} as provinceid, + {{ json_extract_scalar('_airbyte_data', ['searchString'], ['searchString']) }} as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ source('unibag', '_airbyte_raw_wards') }} as table_alias +-- wards +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/wards_ab2.sql b/models/generated/airbyte_ctes/unibag/wards_ab2.sql new file mode 100644 index 0000000..ba138c1 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/wards_ab2.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to cast each column to its adequate SQL type converted from the JSON schema type +-- depends_on: {{ ref('wards_ab1') }} +select + cast(_id as {{ dbt_utils.type_string() }}) as _id, + cast(city as {{ dbt_utils.type_string() }}) as city, + cast(code as {{ dbt_utils.type_float() }}) as code, + cast({{ adapter.quote('name') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('name') }}, + cast(slug as {{ dbt_utils.type_string() }}) as slug, + cast(tncid as {{ dbt_utils.type_float() }}) as tncid, + cast(cityid as {{ dbt_utils.type_float() }}) as cityid, + cast({{ adapter.quote('source') }} as {{ dbt_utils.type_string() }}) as {{ adapter.quote('source') }}, + cast(tnccode as {{ dbt_utils.type_string() }}) as tnccode, + cast(district as {{ dbt_utils.type_string() }}) as district, + cast(gidocode as {{ dbt_utils.type_float() }}) as gidocode, + cast(osirisid as {{ dbt_utils.type_float() }}) as osirisid, + cast(updatedat as {{ dbt_utils.type_string() }}) as updatedat, + cast(districtid as {{ dbt_utils.type_float() }}) as districtid, + cast(provinceid as {{ dbt_utils.type_float() }}) as provinceid, + cast(searchstring as {{ dbt_utils.type_string() }}) as searchstring, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at +from {{ ref('wards_ab1') }} +-- wards +where 1 = 1 + diff --git a/models/generated/airbyte_ctes/unibag/wards_ab3.sql b/models/generated/airbyte_ctes/unibag/wards_ab3.sql new file mode 100644 index 0000000..0c5b6a3 --- /dev/null +++ b/models/generated/airbyte_ctes/unibag/wards_ab3.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "_airbyte_unibag", + tags = [ "top-level-intermediate" ] +) }} +-- SQL model to build a hash column based on the values of this record +-- depends_on: {{ ref('wards_ab2') }} +select + {{ dbt_utils.surrogate_key([ + '_id', + 'city', + 'code', + adapter.quote('name'), + 'slug', + 'tncid', + 'cityid', + adapter.quote('source'), + 'tnccode', + 'district', + 'gidocode', + 'osirisid', + 'updatedat', + 'districtid', + 'provinceid', + 'searchstring', + ]) }} as _airbyte_wards_hashid, + tmp.* +from {{ ref('wards_ab2') }} tmp +-- wards +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/admin_tags.sql b/models/generated/airbyte_tables/unibag/admin_tags.sql new file mode 100644 index 0000000..ccede46 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/admin_tags.sql @@ -0,0 +1,23 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('admin_tags_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + {{ adapter.quote('type') }}, + color, + active, + createdat::timestamp AS created_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_admin_tags_hashid +from {{ ref('admin_tags_ab3') }} +-- admin_tags from {{ source('unibag', '_airbyte_raw_admin_tags') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/cash_flows.sql b/models/generated/airbyte_tables/unibag/cash_flows.sql new file mode 100644 index 0000000..4ced7f0 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/cash_flows.sql @@ -0,0 +1,25 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('cash_flows_ab3') }} +select + _id AS id, + {{ adapter.quote('value') }}, + {{ adapter.quote('action') }}, + newbalance AS new_balance, + oldbalance AS old_balance, + targetid AS target_id, + targettype AS target_type, + {{ adapter.quote('user') }} AS seller_id, + createdat::timestamp AS created_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_cash_flows_hashid +from {{ ref('cash_flows_ab3') }} +-- cash_flows from {{ source('unibag', '_airbyte_raw_cash_flows') }} +where 1 = 1 diff --git a/models/generated/airbyte_tables/unibag/cities.sql b/models/generated/airbyte_tables/unibag/cities.sql new file mode 100644 index 0000000..e3ae178 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/cities.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('cities_ab3') }} +select + _id AS id, + code, + {{ adapter.quote('name') }}, + slug, + region, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_cities_hashid +from {{ ref('cities_ab3') }} +-- cities from {{ source('unibag', '_airbyte_raw_cities') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/customers.sql b/models/generated/airbyte_tables/unibag/customers.sql new file mode 100644 index 0000000..266e813 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/customers.sql @@ -0,0 +1,28 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('customers_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + phone, + cast({{ adapter.quote('statistic') }}::json->>'expenseTotal' AS numeric) AS stats_expense_total, + cast({{ adapter.quote('statistic') }}::json->>'transactionTotal' AS numeric) AS stats_order_total, + cast({{ adapter.quote('statistic') }}::json->>'transactionPending' AS numeric) AS stats_order_pending, + cast({{ adapter.quote('statistic') }}::json->>'transactionSuccess' AS numeric) AS stats_order_success, + cast({{ adapter.quote('statistic') }}::json->>'transactionRejected' AS numeric) AS stats_order_rejected, + {{ adapter.quote('user') }} AS seller_id, + {{ adapter.quote('location') }}::jsonb, + createdat::timestamp AS created_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_customers_hashid +from {{ ref('customers_ab3') }} +-- customers from {{ source('unibag', '_airbyte_raw_customers') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/districts.sql b/models/generated/airbyte_tables/unibag/districts.sql new file mode 100644 index 0000000..8738b76 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/districts.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('districts_ab3') }} +select + _id AS id, + code, + {{ adapter.quote('name') }}, + slug, + cityid AS province_code, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_districts_hashid +from {{ ref('districts_ab3') }} +-- districts from {{ source('unibag', '_airbyte_raw_districts') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/event_rewards.sql b/models/generated/airbyte_tables/unibag/event_rewards.sql new file mode 100644 index 0000000..e4ab8df --- /dev/null +++ b/models/generated/airbyte_tables/unibag/event_rewards.sql @@ -0,0 +1,32 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('event_rewards_ab3') }} +select + _id AS id, + cash, + {{ adapter.quote('type') }}, + status, + {{ adapter.quote('options') }}::json->>'referral' AS option_referral, + {{ adapter.quote('options') }}::json->>'invitee' AS option_invitee, + {{ adapter.quote('options') }}::json->>'order' AS option_order, + cast({{ adapter.quote('options') }}::json->>'percent' AS numeric) AS option_percent, + cast({{ adapter.quote('options') }}::json->>'minOrderToClaim' AS integer) AS option_min_order_to_claim, + cast({{ adapter.quote('options') }}::json->>'minOrderValue' AS numeric) AS option_min_order_value, + {{ adapter.quote('options') }}::json->>'userEventQuest' AS option_event_quest, + {{ adapter.quote('user') }} AS seller_id, + {{ adapter.quote('event') }} AS event_id, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_event_rewards_hashid +from {{ ref('event_rewards_ab3') }} +-- event_rewards from {{ source('unibag', '_airbyte_raw_event_rewards') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/events.sql b/models/generated/airbyte_tables/unibag/events.sql new file mode 100644 index 0000000..a897958 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/events.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('events_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + {{ adapter.quote('type') }}, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_events_hashid +from {{ ref('events_ab3') }} +-- events from {{ source('unibag', '_airbyte_raw_events') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/inventories.sql b/models/generated/airbyte_tables/unibag/inventories.sql new file mode 100644 index 0000000..9730ebe --- /dev/null +++ b/models/generated/airbyte_tables/unibag/inventories.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('inventories_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + code, + active, + {{ adapter.quote('location') }}::json->>'address' AS location_address, + {{ adapter.quote('location') }}::json->>'province' AS location_province, + {{ adapter.quote('location') }}::json->>'district' AS location_district, + {{ adapter.quote('location') }}::json->>'ward' AS location_ward, + {{ adapter.quote('supplier') }}::json->>'_id' AS supplier_id, + {{ adapter.quote('supplier') }}::json->>'name' AS supplier_name, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_inventories_hashid +from {{ ref('inventories_ab3') }} +-- inventories from {{ source('unibag', '_airbyte_raw_inventories') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/membership.sql b/models/generated/airbyte_tables/unibag/membership.sql new file mode 100644 index 0000000..8a3ed91 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/membership.sql @@ -0,0 +1,26 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('membership_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + {{ adapter.quote('level') }}, + active, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + {{ adapter.quote('transaction') }} AS order, + bonuspercent AS bonus_percent, + transactionminvalue AS order_min_value, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_membership_hashid +from {{ ref('membership_ab3') }} +-- membership from {{ source('unibag', '_airbyte_raw_membership') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/membership_histories.sql b/models/generated/airbyte_tables/unibag/membership_histories.sql new file mode 100644 index 0000000..aecd34e --- /dev/null +++ b/models/generated/airbyte_tables/unibag/membership_histories.sql @@ -0,0 +1,25 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('membership_histories_ab3') }} +select + _id AS id, + cast({{ adapter.quote('old') }}::json->>'level' AS numeric) AS old_membership_level, + {{ adapter.quote('old') }}::json->>'name' AS old_membership_name, + cast({{ adapter.quote('new') }}::json->>'level' AS numeric) AS new_membership_level, + {{ adapter.quote('new') }}::json->>'name' AS new_membership_name, + {{ adapter.quote('type') }}, + {{ adapter.quote('user') }} AS seller_id, + createdat::timestamp AS created_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_membership_histories_hashid +from {{ ref('membership_histories_ab3') }} +-- membership_histories from {{ source('unibag', '_airbyte_raw_membership_histories') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/membership_orders.sql b/models/generated/airbyte_tables/unibag/membership_orders.sql new file mode 100644 index 0000000..a28eae4 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/membership_orders.sql @@ -0,0 +1,29 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('membership_orders_ab3') }} +select + _id, + {{ adapter.quote('user') }} AS seller_id, + targetid AS target_id, + membershipPromotion AS membership_promotion, + membershipname AS membership_name, + cast(membershiplevel AS integer) AS membership_level, + cast(commission AS numeric) AS commission, + status, + cast({{ adapter.quote('percent') }} AS numeric) AS percent, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + isrejected AS is_rejected, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_membership_orders_hashid +from {{ ref('membership_orders_ab3') }} +-- membership_orders from {{ source('unibag', '_airbyte_raw_membership_orders') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/order_deliveries.sql b/models/generated/airbyte_tables/unibag/order_deliveries.sql new file mode 100644 index 0000000..cf09b74 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/order_deliveries.sql @@ -0,0 +1,45 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('order_deliveries_ab3') }} +select + _id AS id, + title, + status, + cast(promotion::json->>'discount' AS numeric) AS discount_value, + cast({{ adapter.quote('delivery') }}::json->>'fee' AS numeric) AS fee, + {{ adapter.quote('delivery') }}::json->>'note' AS note, + {{ adapter.quote('delivery') }}::json->>'courierName' AS courier_name, + {{ adapter.quote('delivery') }}::json->>'serviceName' AS service_name, + {{ adapter.quote('delivery') }}::json->>'serviceCode' AS service_code, + {{ adapter.quote('delivery') }}::json->>'currency' AS currency, + cast({{ adapter.quote('delivery') }}::json->'feeShip'->>'currency' AS numeric) AS feeship_cod, + cast({{ adapter.quote('delivery') }}::json->'feeShip'->>'insurance' AS numeric) AS feeship_insurance, + cast({{ adapter.quote('delivery') }}::json->'feeShip'->>'shipping' AS numeric) AS feeship_shipping, + cast({{ adapter.quote('delivery') }}::json->'feeShip'->>'total' AS numeric) AS feeship_total, + cast({{ adapter.quote('delivery') }}::json->>'minDeliveryDay' AS numeric) AS min_delivery_day, + cast({{ adapter.quote('delivery') }}::json->>'maxDeliveryDay' AS numeric) AS max_delivery_day, + {{ adapter.quote('delivery') }}::json->>'estimateTimeDelivery' AS estimate_time_delivery, + service AS service_delivery, + cast({{ adapter.quote('location') }}::json->>'province' AS integer) AS location_province, + cast({{ adapter.quote('location') }}::json->>'district' AS integer) AS location_district, + cast({{ adapter.quote('location') }}::json->>'ward' AS integer) AS location_ward, + {{ adapter.quote('location') }}::json->>'address' AS location_address, + {{ adapter.quote('location') }}::json->>'fullAddress' AS location_full_address, + {{ adapter.quote('customer') }}::json->>'name' AS customer_name, + {{ adapter.quote('customer') }}::json->>'phone' AS customer_phone, + {{ adapter.quote('order') }} AS order_id, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_order_deliveries_hashid +from {{ ref('order_deliveries_ab3') }} +-- order_deliveries from {{ source('unibag', '_airbyte_raw_order_deliveries') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/order_histories.sql b/models/generated/airbyte_tables/unibag/order_histories.sql new file mode 100644 index 0000000..382492f --- /dev/null +++ b/models/generated/airbyte_tables/unibag/order_histories.sql @@ -0,0 +1,21 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('order_histories_ab3') }} +select + _id AS id, + status, + {{ adapter.quote('order') }} AS order_id, + createdat::timestamp AS created_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_order_histories_hashid +from {{ ref('order_histories_ab3') }} +-- order_histories from {{ source('unibag', '_airbyte_raw_order_histories') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/order_items.sql b/models/generated/airbyte_tables/unibag/order_items.sql new file mode 100644 index 0000000..5f44174 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/order_items.sql @@ -0,0 +1,37 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('order_items_ab3') }} +select + _id AS id, + status, + quantity, + cast({{ adapter.quote('price') }}::json->>'base' AS numeric) AS price_base, + cast({{ adapter.quote('price') }}::json->>'sell' AS numeric) AS price_sell, + cast({{ adapter.quote('price') }}::json->>'profit' AS numeric) AS price_profit, + cast({{ adapter.quote('price') }}::json->>'profitUni' AS numeric) AS price_profit_of_selly, + cast({{ adapter.quote('price') }}::json->>'wholesaleBonus' AS numeric) AS price_wholesale_bonus, + cast({{ adapter.quote('price') }}::json->>'sellyWholesaleBonus' AS numeric) AS price_selly_wholesale_bonus, + cast({{ adapter.quote('price') }}::json->>'minimum' AS numeric) AS price_min, + cast({{ adapter.quote('price') }}::json->>'maximum' AS numeric) AS price_max, + cast({{ adapter.quote('price') }}::json->>'market' AS numeric) AS price_market, + cast({{ adapter.quote('price') }}::json->>'supplierPrice' AS numeric) AS price_of_supplier, + cast({{ adapter.quote('price') }}::json->>'weight' AS numeric) AS weight, + {{ adapter.quote('sku') }}::json->>'_id' AS sku_id, + {{ adapter.quote('sku') }}::json->'version' AS sku_version, + {{ adapter.quote('sku') }}::json->'unitCode' AS sku_unit_code, + {{ adapter.quote('user') }} AS seller_id, + {{ adapter.quote('order') }} AS order_id, + {{ adapter.quote('product') }} AS product_id, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_order_items_hashid +from {{ ref('order_items_ab3') }} +-- order_items from {{ source('unibag', '_airbyte_raw_order_items') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/orders.sql b/models/generated/airbyte_tables/unibag/orders.sql new file mode 100644 index 0000000..daaf0a2 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/orders.sql @@ -0,0 +1,51 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('orders_ab3') }} +select + _id AS id, + code, + trackingcode AS tracking_code, + status, + banned, + string_to_array(REPLACE(REPLACE(REPLACE(tags::text, '[', ''), ']', ''), '"', ''), ',') AS tags, + isdeleted AS is_deleted, + cast({{ adapter.quote('promotion') }}::json->>'isApplied' AS boolean) AS promotion_is_applied, + cast({{ adapter.quote('promotion') }}::json->>'discount' AS numeric) AS promotion_discount_value, + cast({{ adapter.quote('promotion') }}::json->>'minOrderValue' AS numeric) AS promotion_min_order_value, + {{ adapter.quote('inventory') }}::json->>'_id' AS inventory_id, + {{ adapter.quote('inventory') }}::json->>'name' AS inventory_name, + {{ adapter.quote('payment') }}::json->>'method' AS payment_method, + {{ adapter.quote('payment') }}::json->>'status' AS payment_status, + cast({{ adapter.quote('price') }}::json->>'base' AS numeric) AS price_base, + cast({{ adapter.quote('price') }}::json->>'sell' AS numeric) AS price_sell, + cast({{ adapter.quote('price') }}::json->>'profit' AS numeric) AS price_profit, + cast({{ adapter.quote('price') }}::json->>'profitUni' AS numeric) AS price_profit_of_selly, + cast({{ adapter.quote('price') }}::json->>'minimum' AS numeric) AS price_min, + cast({{ adapter.quote('price') }}::json->>'maximum' AS numeric) AS price_max, + cast({{ adapter.quote('price') }}::json->>'total' AS numeric) AS price_total, + cast({{ adapter.quote('price') }}::json->>'weight' AS numeric) AS weight, + {{ adapter.quote('delivery') }}::json->>'_id' AS delivery_id, + cast({{ adapter.quote('delivery') }}::json->>'discountValue' AS numeric) AS delivery_discount_value, + approvedat::timestamp AS approved_at, + rejectedat::timestamp AS rejected_at, + pickupat::timestamp AS pickup_at, + deliveredat::timestamp AS delivered_at, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + {{ adapter.quote('user') }} AS seller_id, + customer AS customer_id, + delivery::json->>'status' AS delivery_status, + iswaitingcancelled AS is_waiting_cancelled, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_orders_hashid +from {{ ref('orders_ab3') }} +-- orders from {{ source('unibag', '_airbyte_raw_orders') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/product_categories.sql b/models/generated/airbyte_tables/unibag/product_categories.sql new file mode 100644 index 0000000..a779b7e --- /dev/null +++ b/models/generated/airbyte_tables/unibag/product_categories.sql @@ -0,0 +1,20 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('product_categories_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + active, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_product_categories_hashid +from {{ ref('product_categories_ab3') }} +-- product_categories from {{ source('unibag', '_airbyte_raw_product_categories') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/product_sku.sql b/models/generated/airbyte_tables/unibag/product_sku.sql new file mode 100644 index 0000000..b62ba82 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/product_sku.sql @@ -0,0 +1,43 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('product_sku_ab3') }} +select + _id AS id, + sku, + {{ adapter.quote('name') }}, + active, + -- quantity, + picture AS photo, + cast({{ adapter.quote('price') }}::json->>'base' AS numeric) AS price_base, + cast({{ adapter.quote('price') }}::json->>'market' AS numeric) AS price_market, + cast({{ adapter.quote('price') }}::json->>'minimum' AS numeric) AS price_min, + cast({{ adapter.quote('price') }}::json->>'maximum' AS numeric) AS price_max, + cast({{ adapter.quote('price') }}::json->>'supplier' AS numeric) AS price_of_supplier, + cast({{ adapter.quote('info') }}::json->'inventory'->>'id' AS integer) AS inventory_code, + {{ adapter.quote('info') }}::json->'inventory'->>'name' AS inventory_name, + {{ adapter.quote('info') }}::json->'supplier'->>'_id' AS supplier_id, + {{ adapter.quote('info') }}::json->'supplier'->>'name' AS supplier_name, + {{ adapter.quote('info') }}::json->>'dimension' AS info_dimension, + unitCode AS info_unit_code, + cast({{ adapter.quote('info') }}::json->>'weight' AS numeric) AS info_weight, + cast({{ adapter.quote('statistic') }}::json->>'saleTotal' AS numeric) AS stats_sale_total, + cast({{ adapter.quote('statistic') }}::json->>'salePending' AS numeric) AS stats_sale_pending, + cast({{ adapter.quote('statistic') }}::json->>'saleDelivered' AS numeric) AS stats_sale_delivered, + cast({{ adapter.quote('statistic') }}::json->>'saleCancelled' AS numeric) AS stats_sale_cancelled, + cast({{ adapter.quote('statistic') }}::json->>'saleCashback' AS numeric) AS stats_sale_cashback, + product AS product_id, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_product_sku_hashid +from {{ ref('product_sku_ab3') }} +-- product_sku from {{ source('unibag', '_airbyte_raw_product_sku') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/product_sku_versions.sql b/models/generated/airbyte_tables/unibag/product_sku_versions.sql new file mode 100644 index 0000000..dd19234 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/product_sku_versions.sql @@ -0,0 +1,41 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('product_sku_versions_ab3') }} +select + _id AS id, + sku AS sku_id, + {{ adapter.quote('name') }}, + cast({{ adapter.quote('price') }}::json->>'base' AS numeric) AS price_base, + cast({{ adapter.quote('price') }}::json->>'market' AS numeric) AS price_market, + cast({{ adapter.quote('price') }}::json->>'minimum' AS numeric) AS price_min, + cast({{ adapter.quote('price') }}::json->>'maximum' AS numeric) AS price_max, + cast({{ adapter.quote('price') }}::json->>'supplier' AS numeric) AS price_of_supplier, + {{ adapter.quote('info') }}::json->'inventory'->>'_id' AS inventory_id, + cast({{ adapter.quote('info') }}::json->'inventory'->>'id' AS integer) AS inventory_code, + {{ adapter.quote('info') }}::json->'inventory'->>'name' AS inventory_name, + {{ adapter.quote('info') }}::json->'supplier'->>'_id' AS supplier_id, + {{ adapter.quote('info') }}::json->'supplier'->>'name' AS supplier_name, + {{ adapter.quote('info') }}::json->>'dimension' AS info_dimension, + cast({{ adapter.quote('info') }}::json->>'weight' AS numeric) AS info_weight, + cast({{ adapter.quote('statistic') }}::json->>'saleTotal' AS numeric) AS stats_sale_total, + cast({{ adapter.quote('statistic') }}::json->>'salePending' AS numeric) AS stats_sale_pending, + cast({{ adapter.quote('statistic') }}::json->>'saleDelivered' AS numeric) AS stats_sale_delivered, + cast({{ adapter.quote('statistic') }}::json->>'saleCancelled' AS numeric) AS stats_sale_cancelled, + cast({{ adapter.quote('statistic') }}::json->>'saleCashback' AS numeric) AS stats_sale_cashback, + product AS product_id, + version, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_product_sku_versions_hashid +from {{ ref('product_sku_versions_ab3') }} +-- product_sku_versions from {{ source('unibag', '_airbyte_raw_product_sku_versions') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/product_sub_categories.sql b/models/generated/airbyte_tables/unibag/product_sub_categories.sql new file mode 100644 index 0000000..59b9799 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/product_sub_categories.sql @@ -0,0 +1,21 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('product_sub_categories_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + active, + parent AS parent_id, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_product_sub_categories_hashid +from {{ ref('product_sub_categories_ab3') }} +-- product_sub_categories from {{ source('unibag', '_airbyte_raw_product_sub_categories') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/products.sql b/models/generated/airbyte_tables/unibag/products.sql new file mode 100644 index 0000000..3d9cd7d --- /dev/null +++ b/models/generated/airbyte_tables/unibag/products.sql @@ -0,0 +1,28 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('products_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + active, + string_to_array(REPLACE(REPLACE(REPLACE(categories::text, '[', ''), ']', ''), '"', ''), ',') AS categories, + string_to_array(REPLACE(REPLACE(REPLACE(subcategories::text, '[', ''), ']', ''), '"', ''), ',') AS sub_categories, + cast({{ adapter.quote('price') }}::json->>'base' AS numeric) AS price_base, + cast({{ adapter.quote('price') }}::json->>'market' AS numeric) AS price_market, + cast({{ adapter.quote('price') }}::json->>'minimum' AS numeric) AS price_min, + cast({{ adapter.quote('price') }}::json->>'maximum' AS numeric) AS price_max, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_products_hashid +from {{ ref('products_ab3') }} +-- products from {{ source('unibag', '_airbyte_raw_products') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/promotion_orders.sql b/models/generated/airbyte_tables/unibag/promotion_orders.sql new file mode 100644 index 0000000..ad612e7 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/promotion_orders.sql @@ -0,0 +1,31 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('promotion_orders_ab3') }} +select + _id, + {{ adapter.quote('user') }} AS seller_id, + {{ adapter.quote('order') }} AS order_id, + promotion AS promotion_id, + commission, + status, + title, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + -- cast({{ adapter.quote('sharepercent') }}::json->>'supplier' AS numeric) AS share_percent_supplier, + -- cast({{ adapter.quote('sharepercent') }}::json->>'selly' AS numeric) AS share_percent_selly, + {{ adapter.quote('supplier') }}::json->>'_id' AS supplier_id, + {{ adapter.quote('supplier') }}::json->>'name' AS supplier_name, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_promotion_orders_hashid +from {{ ref('promotion_orders_ab3') }} +-- promotion_orders from {{ source('unibag', '_airbyte_raw_promotion_orders') }} +where 1 = 1 + + diff --git a/models/generated/airbyte_tables/unibag/promotions.sql b/models/generated/airbyte_tables/unibag/promotions.sql new file mode 100644 index 0000000..e699c01 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/promotions.sql @@ -0,0 +1,36 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('promotions_ab3') }} +select + _id, + title, + type, + endat::timestamp AS end_at, + startat::timestamp AS start_at, + isunlimitedquantity AS is_unlimited_quantity, + quantity, + rest, + {{ adapter.quote('applyfor') }}::json->>'type' AS apply_for_type, + cast({{ adapter.quote('options') }}::json->>'transactionMinValue' AS numeric) AS options_transaction_min_value, + cast({{ adapter.quote('options') }}::json->>'milestones' AS jsonb) AS options_milestones, + {{ adapter.quote('options') }}::json->'bonus'->>'type' AS options_bonus_type, + cast({{ adapter.quote('options') }}::json->'bonus'->>'value' AS numeric) AS options_bonus_value, + {{ adapter.quote('conditionforuser') }}::json->>'applyFor' AS condition_for_user_apply_for, + {{ adapter.quote('conditionforuser') }}::json->>'gender' AS condition_for_user_gender, + articleid AS article_id, + isapplyfororderwholesale AS is_apply_for_order_wholesale, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_promotions_hashid +from {{ ref('promotions_ab3') }} +-- promotions from {{ source('unibag', '_airbyte_raw_promotions') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/referrals.sql b/models/generated/airbyte_tables/unibag/referrals.sql new file mode 100644 index 0000000..3dd3593 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/referrals.sql @@ -0,0 +1,21 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('referrals_ab3') }} +select + _id AS id, + {{ adapter.quote('user') }} AS seller_id, + invitee AS invitee_id, + createdat::timestamp AS created_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_referrals_hashid +from {{ ref('referrals_ab3') }} +-- referrals from {{ source('unibag', '_airbyte_raw_referrals') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/suppliers.sql b/models/generated/airbyte_tables/unibag/suppliers.sql new file mode 100644 index 0000000..5d0980b --- /dev/null +++ b/models/generated/airbyte_tables/unibag/suppliers.sql @@ -0,0 +1,20 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('suppliers_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + identifycode AS identify_code, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_suppliers_hashid +from {{ ref('suppliers_ab3') }} +-- suppliers from {{ source('unibag', '_airbyte_raw_suppliers') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/team_activities.sql b/models/generated/airbyte_tables/unibag/team_activities.sql new file mode 100644 index 0000000..96ce4a0 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/team_activities.sql @@ -0,0 +1,22 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('team_activities_ab3') }} +select + _id AS id, + {{ adapter.quote('action') }}, + team AS team_id, + targetid AS team_member_id, + createdat::timestamp AS created_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_team_activities_hashid +from {{ ref('team_activities_ab3') }} +-- team_activities from {{ source('unibag', '_airbyte_raw_team_activities') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/team_bonus.sql b/models/generated/airbyte_tables/unibag/team_bonus.sql new file mode 100644 index 0000000..552198c --- /dev/null +++ b/models/generated/airbyte_tables/unibag/team_bonus.sql @@ -0,0 +1,30 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('team_bonus_ab3') }} +select + _id, + team AS team_id, + {{ adapter.quote('user') }} AS seller_id, + status, + cast({{ adapter.quote('percent') }} AS numeric) AS percent, + cast({{ adapter.quote('commission') }} AS numeric) AS commission, + teammember AS team_member, + teampromotion AS team_promotion, + targetid AS target_id, + teamname AS team_name, + cast(teamlevel AS integer) AS team_level, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_team_bonus_hashid +from {{ ref('team_bonus_ab3') }} +-- team_bonus from {{ source('unibag', '_airbyte_raw_team_bonus') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/team_members.sql b/models/generated/airbyte_tables/unibag/team_members.sql new file mode 100644 index 0000000..a0a6009 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/team_members.sql @@ -0,0 +1,26 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('team_members_ab3') }} +select + _id AS id, + {{ adapter.quote('role') }}, + team AS team_id, + {{ adapter.quote('user') }} AS seller_id, + isleft AS is_left, + leftat AS left_at, + joinedat::timestamp AS joined_at, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_team_members_hashid +from {{ ref('team_members_ab3') }} +-- team_members from {{ source('unibag', '_airbyte_raw_team_members') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/teams.sql b/models/generated/airbyte_tables/unibag/teams.sql new file mode 100644 index 0000000..43b1545 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/teams.sql @@ -0,0 +1,30 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('teams_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + active, + adminuser AS admin_id, + citycode AS province_code, + cast({{ adapter.quote('level') }}::json->>'level' AS numeric) AS current_level_value, + {{ adapter.quote('level') }}::json->>'name' AS current_level_name, + cast(level::json->>'expiredAt' AS timestamp) AS current_level_expired_at, + cast({{ adapter.quote('level') }}::json->>'bonusPercent' AS numeric) AS bonus_percent, + cast({{ adapter.quote('level') }}::json->>'maximumNumberMember' AS numeric) AS stats_max_member, + cast({{ adapter.quote('statistic') }}::json->>'memberTotal' AS numeric) AS stats_current_member, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_teams_hashid +from {{ ref('teams_ab3') }} +-- teams from {{ source('unibag', '_airbyte_raw_teams') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/user_identifications.sql b/models/generated/airbyte_tables/unibag/user_identifications.sql new file mode 100644 index 0000000..5af3c20 --- /dev/null +++ b/models/generated/airbyte_tables/unibag/user_identifications.sql @@ -0,0 +1,27 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'btree'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('user_identifications_ab3') }} +select + _id, + dob, + {{ adapter.quote('name') }}, + {{ adapter.quote('type') }}, + {{ adapter.quote('user') }} AS seller_id, + gender, + nation, + status, + address, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_user_identifications_hashid +from {{ ref('user_identifications_ab3') }} +-- user_identifications from {{ source('unibag', '_airbyte_raw_user_identifications') }} +where 1 = 1 diff --git a/models/generated/airbyte_tables/unibag/users.sql b/models/generated/airbyte_tables/unibag/users.sql new file mode 100644 index 0000000..92c51df --- /dev/null +++ b/models/generated/airbyte_tables/unibag/users.sql @@ -0,0 +1,36 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('users_ab3') }} +select + _id AS id, + {{ adapter.quote('name') }}, + banned, + {{ adapter.quote('phone') }}::json->>'full' AS phone_number, + {{ adapter.quote('phone') }}::json->>'verified' AS phone_verified, + cast(phone::json->>'verifiedAt' AS date) AS phone_verified_at, + {{ adapter.quote('info') }}::json->>'email' AS info_email, + cast({{ adapter.quote('info') }}::json->>'cityCode' AS integer) AS info_province_code, + {{ adapter.quote('info') }}::json->>'gender' AS info_gender, + {{ adapter.quote('referral') }}::json->>'code' AS referral_code, + cast({{ adapter.quote('identification') }}::json->>'completedAt' AS timestamp) AS identification_completed_at, + {{ adapter.quote('identification') }}::json->>'status' AS identification_status, + cast({{ adapter.quote('identification') }}::json->>'timeUpdate' AS integer) AS identification_times_update, + registerfrom AS register_from, + cast({{ adapter.quote('membership') }}::json->>'currentLevel' AS numeric) AS membership_current_level, + cast({{ adapter.quote('membership') }}::json->>'expireAt' AS timestamp) AS membership_expire_at, + createdat::timestamp AS created_at, + updatedat::timestamp AS updated_at, + lastactivatedat::timestamp AS last_activated_at, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_users_hashid +from {{ ref('users_ab3') }} +-- users from {{ source('unibag', '_airbyte_raw_users') }} +where 1 = 1 + diff --git a/models/generated/airbyte_tables/unibag/wards.sql b/models/generated/airbyte_tables/unibag/wards.sql new file mode 100644 index 0000000..62cf38e --- /dev/null +++ b/models/generated/airbyte_tables/unibag/wards.sql @@ -0,0 +1,23 @@ +{{ config( + indexes = [{'columns':['_airbyte_emitted_at'],'type':'hash'}], + unique_key = '_airbyte_ab_id', + schema = "unibag", + tags = [ "top-level" ] +) }} +-- Final base SQL model +-- depends_on: {{ ref('wards_ab3') }} +select + _id AS id, + code, + {{ adapter.quote('name') }}, + slug, + cityid AS province_code, + districtid AS district_code, + _airbyte_ab_id, + _airbyte_emitted_at, + {{ current_timestamp() }} as _airbyte_normalized_at, + _airbyte_wards_hashid +from {{ ref('wards_ab3') }} +-- wards from {{ source('unibag', '_airbyte_raw_wards') }} +where 1 = 1 + diff --git a/models/generated/sources.yml b/models/generated/sources.yml new file mode 100644 index 0000000..ad32b5f --- /dev/null +++ b/models/generated/sources.yml @@ -0,0 +1,39 @@ +version: 2 +sources: +- name: unibag + quoting: + database: true + schema: false + identifier: false + tables: + - name: _airbyte_raw_admin_tags + - name: _airbyte_raw_cash_flows + - name: _airbyte_raw_cities + - name: _airbyte_raw_customers + - name: _airbyte_raw_districts + - name: _airbyte_raw_event_rewards + - name: _airbyte_raw_events + - name: _airbyte_raw_inventories + - name: _airbyte_raw_membership + - name: _airbyte_raw_membership_histories + - name: _airbyte_raw_membership_orders + - name: _airbyte_raw_order_deliveries + - name: _airbyte_raw_order_histories + - name: _airbyte_raw_order_items + - name: _airbyte_raw_orders + - name: _airbyte_raw_product_categories + - name: _airbyte_raw_product_sku + - name: _airbyte_raw_product_sku_versions + - name: _airbyte_raw_product_sub_categories + - name: _airbyte_raw_products + - name: _airbyte_raw_promotion_orders + - name: _airbyte_raw_promotions + - name: _airbyte_raw_referrals + - name: _airbyte_raw_suppliers + - name: _airbyte_raw_team_activities + - name: _airbyte_raw_team_bonus + - name: _airbyte_raw_team_members + - name: _airbyte_raw_teams + - name: _airbyte_raw_user_identifications + - name: _airbyte_raw_users + - name: _airbyte_raw_wards diff --git a/packages.yml b/packages.yml new file mode 100755 index 0000000..4b74445 --- /dev/null +++ b/packages.yml @@ -0,0 +1,5 @@ +# add dependencies. these will get pulled during the `dbt deps` process. + +packages: + - git: "https://github.com/fishtown-analytics/dbt-utils.git" + revision: 0.7.4 diff --git a/profiles.yml b/profiles.yml new file mode 100644 index 0000000..892eaa5 --- /dev/null +++ b/profiles.yml @@ -0,0 +1,17 @@ +config: + partial_parse: true + printer_width: 120 + send_anonymous_usage_stats: false + use_colors: true +normalize: + outputs: + prod: + dbname: selly_etl + host: localhost + pass: '123' + port: 5555 + schema: public + threads: 8 + type: postgres + user: selly + target: prod