Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# dbt-dremio v1.9.0

## Changes

- Updated dbt-dremio to match dbt-core v1.9 with the snapshots improvements

## Dependency

- Upgraded dbt-core to 1.9.0 and dbt-tests-adapter to 1.11.0

# dbt-dremio v1.8.4

## Changes
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/dremio/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version = "1.8.4"
version = "1.9.0"
49 changes: 30 additions & 19 deletions dbt/include/dremio/macros/adapters/snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,33 @@ limitations under the License.*/


{% macro dremio__snapshot_merge_sql(target, source, insert_cols) -%}
{%- set insert_cols_csv = insert_cols | join(', ') -%}

merge into {{ target }} as DBT_INTERNAL_DEST
using {{ source }} as DBT_INTERNAL_SOURCE
on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id

when matched
then update
set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to

when not matched
then insert ({{ insert_cols_csv }})
values
({% for column_name in insert_cols -%}
DBT_INTERNAL_SOURCE.{{ column_name }}
{%- if not loop.last %}, {%- endif %}
{%- endfor %})

{% endmacro %}
{%- set columns = config.get("snapshot_table_column_names") or get_snapshot_table_column_names() -%}
Comment thread
howareyouman marked this conversation as resolved.
{%- set insert_cols_csv = insert_cols | join(', ') -%}

merge into {{ target }} as DBT_INTERNAL_DEST
using (
select * from {{ source }}
where dbt_change_type in ('update', 'delete', 'insert')
) as DBT_INTERNAL_SOURCE
on (DBT_INTERNAL_SOURCE.{{ columns.dbt_scd_id }} = DBT_INTERNAL_DEST.{{ columns.dbt_scd_id }}
and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')
{%- if config.get("dbt_valid_to_current") %}
and (
DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} = {{ config.get('dbt_valid_to_current') }}
or DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null
)
{%- else %}
and DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null
{%- endif %})

when matched then update set {{ columns.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ columns.dbt_valid_to }}
Comment thread
99Lys marked this conversation as resolved.

when not matched then insert ({{ insert_cols_csv }})
values
(
{%- for column_name in insert_cols -%}
DBT_INTERNAL_SOURCE.{{ column_name }}{% if not loop.last %}, {% endif %}
{%- endfor %}
)

{% endmacro %}
8 changes: 4 additions & 4 deletions dbt/include/dremio/macros/builtins/builtins.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ limitations under the License.*/
and model.config.format is defined
else none -%}
{%- set format_clause = format_clause_from_node(model.config) if format is not none else none -%}
{%- set relation2 = api.Relation.create(database=relation.database, schema=relation.schema, identifier=relation.identifier, format=format, format_clause=format_clause) -%}
{{ return (relation2) }}
{%- set relation2 = api.Relation.create(database=relation.database, schema=relation.schema, identifier=relation.identifier, format=format, format_clause=format_clause, limit=relation.limit) -%}
Comment thread
99Lys marked this conversation as resolved.
{{ return (relation2) }}
{%- else -%}
{{ return (relation) }}
{%- endif -%}
Expand All @@ -40,8 +40,8 @@ limitations under the License.*/
and source.external.format is defined
else none -%}
{%- set format_clause = format_clause_from_node(source.external) if format is not none else none -%}
{%- set relation2 = api.Relation.create(database=relation.database, schema=relation.schema, identifier=relation.identifier, format=format, format_clause=format_clause) -%}
{{ return (relation2) }}
{%- set relation2 = api.Relation.create(database=relation.database, schema=relation.schema, identifier=relation.identifier, format=format, format_clause=format_clause, limit=relation.limit) -%}
{{ return (relation2) }}
{%- else -%}
{{ return (relation) }}
{%- endif -%}
Expand Down
4 changes: 2 additions & 2 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Babel==2.12.1
betterproto==1.2.5
certifi==2023.7.22
charset-normalizer==3.1.0
dbt-core==1.8.8
dbt-tests-adapter==1.8.0
dbt-core==1.9.0
dbt-tests-adapter==1.11.0
python-dotenv==1.0.1
exceptiongroup==1.1.1
future==0.18.3
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

package_name = "dbt-dremio"

package_version = "1.8.4"
package_version = "1.9.0"

description = """The Dremio adapter plugin for dbt"""

Expand All @@ -37,8 +37,9 @@
packages=find_namespace_packages(include=["dbt", "dbt.*"]),
include_package_data=True,
install_requires=[
"dbt-core>=1.8",
"dbt-adapters>=1.0.0, <2.0.0",
"dbt-core>=1.9",
"dbt-common>=1.11,<2.0",
"dbt-adapters>=1.10.1, <2.0",
"requests>=2.31.0",
],
classifiers=[
Expand Down
12 changes: 0 additions & 12 deletions tests/functional/adapter/empty/test_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,3 @@ def models(self):
"model.sql": _models.model_sql,
"sources.yml": schema_sources_yml,
}

def test_run_with_empty(self, project):
Comment thread
99Lys marked this conversation as resolved.
# create source from seed
run_dbt(["seed"])

# run without empty - 3 expected rows in output - 1 from each input
# run_dbt(["run"])
# self.assert_row_count(project, "model", 3)

# run with empty - 0 expected rows in output
run_dbt(["build", "--empty"])
self.assert_row_count(project, "model", 0)
Loading