diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad30e94..42c246aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # dbt-dremio MAIN - [#223](https://github.com/dremio/dbt-dremio/issues/224) Implement merge strategy for incremental materializations +- [#229](https://github.com/dremio/dbt-dremio/issues/229) Add max operator to get_relation_last_modified macro # dbt-dremio v1.7.0 diff --git a/dbt/include/dremio/macros/adapters/metadata.sql b/dbt/include/dremio/macros/adapters/metadata.sql index ec8a79b6..b6a316e3 100644 --- a/dbt/include/dremio/macros/adapters/metadata.sql +++ b/dbt/include/dremio/macros/adapters/metadata.sql @@ -312,7 +312,7 @@ limitations under the License.*/ {%- if relation.type != 'view' -%} {%- call statement('last_modified', fetch_result=True) -%} - select committed_at as last_modified, + select max(committed_at) as last_modified, {{ current_timestamp() }} as snapshotted_at from TABLE( table_snapshot('{{relation}}') ) {%- endcall -%} diff --git a/tests/functional/adapter/relation/test_get_relation_last_modified.py b/tests/functional/adapter/relation/test_get_relation_last_modified.py index d82b0bf9..281b975b 100644 --- a/tests/functional/adapter/relation/test_get_relation_last_modified.py +++ b/tests/functional/adapter/relation/test_get_relation_last_modified.py @@ -1,6 +1,6 @@ import pytest from dbt.tests.util import run_dbt -from tests.utils.util import BUCKET +from tests.utils.util import BUCKET, relation_from_name freshness_via_metadata_schema_yml = """version: 2 @@ -83,7 +83,10 @@ def test_get_last_relation_modified(self, project): # run command result = run_dbt(["seed"]) - + relation = relation_from_name(project.adapter, "test_source") + result = project.run_sql( + f"INSERT INTO {relation} VALUES (10, 'name')", fetch="one" + ) results = run_dbt(["source", "freshness"]) assert len(results) == 1 result = results[0]