Skip to content

Commit

Permalink
Update variable declarations (#59)
Browse files Browse the repository at this point in the history
* Update variable declarations

* fix variable declaration

* fix variable declaration

* fix variable declaration

* Update + regen docs

* PR fixes

* PR fixes

* PR fixes

* PR fixes

* PR fixes
  • Loading branch information
fivetran-avinash authored Jan 15, 2025
1 parent bd22af7 commit 40846a9
Show file tree
Hide file tree
Showing 30 changed files with 70 additions and 31 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# dbt_netsuite_source v0.11.1
[PR #59](https://github.com/fivetran/dbt_netsuite_source/pull/59) includes the following updates:

## Macro Updates
- Introduced a local version of the `fill_pass_through_columns` macro that directly calls the variables within our staging models. This removes the existing string-to-variable conversion and leads to cleaner parsing.
- This new macro has no functional changes from the previous macro and will not require customers to make any changes on their end.
- This new macro is applied to all staging models with passthrough column functionality, and replaces the existing `fill_pass_through_columns` macro.
- `stg_netsuite` and `stg_netsuite2` models impacted include: `accounts`, `classes`, `consolidated_exchange_rates`, `customers`, `departments`, `items`, `locations`, `subsidiaries`, `transaction_lines`, `transactions`, and `vendors`.
- Similar changes are being made on a simultaneous release to the `persist_pass_through_columns` macro in the `dbt_netsuite` package. [See the release notes](https://github.com/fivetran/dbt_netsuite/releases/tag/v0.17.1) for more details.
- The process for adding passthrough columns remains unchanged. [Consult the README](https://github.com/fivetran/dbt_netsuite?tab=readme-ov-file#passing-through-additional-fields) for more details.

## Documentation Update
- Moved badges at top of the README below the H1 header to be consistent with popular README formats.

# dbt_netsuite_source v0.11.0
[PR #57](https://github.com/fivetran/dbt_netsuite_source/pull/57) includes the following update:

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<p align="center">
# Netsuite Source dbt Package ([Docs](https://fivetran.github.io/dbt_netsuite_source/))

<p align="left">
<a alt="License"
href="https://github.com/fivetran/dbt_netsuite_source/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" /></a>
Expand All @@ -13,7 +15,6 @@
<img src="https://img.shields.io/badge/Fivetran_Quickstart_Compatible%3F-yes-green.svg" /></a>
</p>

# Netsuite Source dbt Package ([Docs](https://fivetran.github.io/dbt_netsuite_source/))
## What does this dbt package do?
<!--section="netsuite_source_model"-->
- Materializes [Netsuite staging tables](https://fivetran.github.io/dbt_netsuite_source/#!/overview/netsuite_source/models/?g_v=1&g_e=seeds) which leverage data in the format described by [this ERD](https://fivetran.com/docs/applications/netsuite#schemainformation). These staging tables clean, test, and prepare your Netsuite data from [Fivetran's connector](https://fivetran.com/docs/applications/netsuite) for analysis by doing the following:
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
name: 'netsuite_source'
version: '0.11.0'
version: '0.11.1'

models:
netsuite_source:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'netsuite_source_integration_tests'

version: '0.11.0'
version: '0.11.1'

profile: 'integration_tests'
config-version: 2
Expand Down
23 changes: 23 additions & 0 deletions macros/fill_pass_through_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% macro fill_pass_through_columns(pass_through_variable) %}

{{ adapter.dispatch('fill_pass_through_columns', 'netsuite_source') (pass_through_variable) }}

{%- endmacro %}

{% macro default__fill_pass_through_columns(pass_through_variable) %}

{% if pass_through_variable %}
{% for field in pass_through_variable %}
{% if field is mapping %}
{% if field.transform_sql %}
, {{ field.transform_sql }} as {{ field.alias if field.alias else field.name }}
{% else %}
, {{ field.alias if field.alias else field.name }}
{% endif %}
{% else %}
, {{ field }}
{% endif %}
{% endfor %}
{% endif %}

{% endmacro %}
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__accounts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your accounts_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('accounts_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('accounts_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__classes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your classes_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('classes_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('classes_pass_through_columns', [])) }}

from fields
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your consolidated_exchange_rates_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('consolidated_exchange_rates_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('consolidated_exchange_rates_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your customers_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('customers_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('customers_pass_through_columns', [])) }}


from fields
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__departments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your departments_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('departments_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('departments_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__items.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your items_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('items_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('items_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__locations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your locations_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('locations_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('locations_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__subsidiaries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your subsidiaries_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('subsidiaries_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('subsidiaries_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__transaction_lines.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final as (
memo

--The below macro adds the fields defined within your transaction_lines_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('transaction_lines_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('transaction_lines_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your transactions_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('transactions_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('transactions_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite/stg_netsuite__vendors.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your vendors_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('vendors_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('vendors_pass_through_columns', [])) }}

from fields
)
Expand Down
3 changes: 2 additions & 1 deletion models/netsuite2/stg_netsuite2__accounts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your accounts_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('accounts_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('accounts_pass_through_columns', [])) }}


from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite2/stg_netsuite2__classes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your classes_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('classes_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('classes_pass_through_columns', [])) }}

from fields
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final as (
historicalrate as historical_rate

--The below macro adds the fields defined within your consolidated_exchange_rates_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('consolidated_exchange_rates_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('consolidated_exchange_rates_pass_through_columns', [])) }}

from fields
where not coalesce(_fivetran_deleted, false)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite2/stg_netsuite2__customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final as (
cast(firstorderdate as date) as date_first_order_at

--The below macro adds the fields defined within your customers_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('customers_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('customers_pass_through_columns', [])) }}

from fields
where not coalesce(_fivetran_deleted, false)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite2/stg_netsuite2__departments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final as (
_fivetran_deleted

--The below macro adds the fields defined within your departments_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('departments_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('departments_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite2/stg_netsuite2__entities.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final as (
vendor as vendor_id

--The below macro adds the fields defined within your entities_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('entities_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('entities_pass_through_columns', [])) }}

from fields
)
Expand Down
4 changes: 2 additions & 2 deletions models/netsuite2/stg_netsuite2__items.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ final as (
parent as parent_item_id

--The below macro adds the fields defined within your items_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('items_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('items_pass_through_columns', [])) }}

from fields
where not coalesce(_fivetran_deleted, false)
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite2/stg_netsuite2__locations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final as (
subsidiary as subsidiary_id

--The below macro adds the fields defined within your locations_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('locations_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('locations_pass_through_columns', [])) }}

from fields
where not coalesce(_fivetran_deleted, false)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite2/stg_netsuite2__subsidiaries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final as (
currency as currency_id

--The below macro adds the fields defined within your subsidiaries_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('subsidiaries_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('subsidiaries_pass_through_columns', [])) }}

from fields
where not coalesce(_fivetran_deleted, false)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite2/stg_netsuite2__transaction_lines.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final as (
netamount

--The below macro adds the fields defined within your transaction_lines_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('transaction_lines_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('transaction_lines_pass_through_columns', [])) }}

from fields
)
Expand Down
2 changes: 1 addition & 1 deletion models/netsuite2/stg_netsuite2__transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final as (
reversaldefer = 'T' as is_reversal_defer

--The below macro adds the fields defined within your transactions_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('transactions_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('transactions_pass_through_columns', [])) }}

from fields
where not coalesce(_fivetran_deleted, false)
Expand Down
4 changes: 2 additions & 2 deletions models/netsuite2/stg_netsuite2__vendors.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ final as (
category as vendor_category_id

--The below macro adds the fields defined within your vendors_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('vendors_pass_through_columns') }}
{{ netsuite_source.fill_pass_through_columns(var('vendors_pass_through_columns', [])) }}

from fields
where not coalesce(_fivetran_deleted, false)
)
Expand Down

0 comments on commit 40846a9

Please sign in to comment.