From 8ff69435a753f0a94dd1274d0e8dad199805cd13 Mon Sep 17 00:00:00 2001
From: Doug Beatty <44704949+dbeatty10@users.noreply.github.com>
Date: Fri, 7 Jun 2024 13:50:44 -0600
Subject: [PATCH 01/17] Update `dbt-adapter` to `dbt-adapters` (#235)
---
.changes/1.0.0.md | 2 +-
.changes/1.1.0.md | 2 +-
.changes/1.1.1.md | 2 +-
.changes/1.2.1.md | 2 +-
.changes/1.8.0.md | 2 +-
.changie.yaml | 2 +-
.github/ISSUE_TEMPLATE/bug-report.yml | 6 +++---
.github/ISSUE_TEMPLATE/config.yml | 4 ++--
.github/ISSUE_TEMPLATE/feature-request.yml | 10 +++++-----
.github/ISSUE_TEMPLATE/regression-report.yml | 10 +++++-----
.github/pull_request_template.md | 2 +-
.github/workflows/release.yml | 2 +-
CHANGELOG.md | 10 +++++-----
CONTRIBUTING.md | 2 +-
14 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/.changes/1.0.0.md b/.changes/1.0.0.md
index b6cc44a9..d381d635 100644
--- a/.changes/1.0.0.md
+++ b/.changes/1.0.0.md
@@ -1,4 +1,4 @@
-## dbt-adapter 1.0.0 - April 01, 2024
+## dbt-adapters 1.0.0 - April 01, 2024
### Fixes
diff --git a/.changes/1.1.0.md b/.changes/1.1.0.md
index c43ef9aa..9e7db78e 100644
--- a/.changes/1.1.0.md
+++ b/.changes/1.1.0.md
@@ -1,4 +1,4 @@
-## dbt-adapter 1.1.0 - May 01, 2024
+## dbt-adapters 1.1.0 - May 01, 2024
### Features
diff --git a/.changes/1.1.1.md b/.changes/1.1.1.md
index 0a28c3ad..a1c38c88 100644
--- a/.changes/1.1.1.md
+++ b/.changes/1.1.1.md
@@ -1,4 +1,4 @@
-## dbt-adapter 1.1.1 - May 07, 2024
+## dbt-adapters 1.1.1 - May 07, 2024
### Features
diff --git a/.changes/1.2.1.md b/.changes/1.2.1.md
index f838b769..2aac5674 100644
--- a/.changes/1.2.1.md
+++ b/.changes/1.2.1.md
@@ -1,4 +1,4 @@
-## dbt-adapter 1.2.1 - May 21, 2024
+## dbt-adapters 1.2.1 - May 21, 2024
### Features
diff --git a/.changes/1.8.0.md b/.changes/1.8.0.md
index bbe54825..e781a985 100644
--- a/.changes/1.8.0.md
+++ b/.changes/1.8.0.md
@@ -1,4 +1,4 @@
-## dbt-adapter 1.8.0 - May 09, 2024
+## dbt-adapters 1.8.0 - May 09, 2024
### Features
diff --git a/.changie.yaml b/.changie.yaml
index 9f78b81e..afbafb22 100644
--- a/.changie.yaml
+++ b/.changie.yaml
@@ -4,7 +4,7 @@ headerPath: header.tpl.md
changelogPath: CHANGELOG.md
versionExt: md
envPrefix: CHANGIE_
-versionFormat: '## dbt-adapter {{.Version}} - {{.Time.Format "January 02, 2006"}}'
+versionFormat: '## dbt-adapters {{.Version}} - {{.Time.Format "January 02, 2006"}}'
kindFormat: '### {{.Kind}}'
changeFormat: '* {{.Body}}'
kinds:
diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml
index 3bd90bf7..27cb521e 100644
--- a/.github/ISSUE_TEMPLATE/bug-report.yml
+++ b/.github/ISSUE_TEMPLATE/bug-report.yml
@@ -1,5 +1,5 @@
name: 🐞 Bug
-description: Report a bug or an issue you've found with dbt-adapter
+description: Report a bug or an issue you've found with dbt-adapters
title: "[Bug]
"
labels: ["bug", "triage"]
body:
@@ -62,11 +62,11 @@ body:
examples:
- **OS**: Ubuntu 20.04
- **Python**: 3.11.6 (`python3 --version`)
- - **dbt-adapter**: 1.0.0
+ - **dbt-adapters**: 1.0.0
value: |
- OS:
- Python:
- - dbt-adapter:
+ - dbt-adapters:
render: markdown
validations:
required: false
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index 2e23e0fd..a89889af 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -7,5 +7,5 @@ contact_links:
url: mailto:support@getdbt.com
about: Are you using dbt Cloud? Contact our support team for help!
- name: Participate in Discussions
- url: https://github.com/dbt-labs/dbt-adapter/discussions
- about: Do you have a Big Idea for dbt-adapter? Read open discussions, or start a new one
+ url: https://github.com/dbt-labs/dbt-adapters/discussions
+ about: Do you have a Big Idea for dbt-adapters? Read open discussions, or start a new one
diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml
index 25b28aae..22960c2d 100644
--- a/.github/ISSUE_TEMPLATE/feature-request.yml
+++ b/.github/ISSUE_TEMPLATE/feature-request.yml
@@ -1,5 +1,5 @@
name: ✨ Feature
-description: Propose a straightforward extension of dbt-adapter functionality
+description: Propose a straightforward extension of dbt-adapters functionality
title: "[Feature] "
labels: ["enhancement", "triage"]
body:
@@ -14,15 +14,15 @@ body:
We want to make sure that features are distinct and discoverable,
so that other members of the community can find them and offer their thoughts.
- Issues are the right place to request straightforward extensions of existing dbt-adapter functionality.
- For "big ideas" about future capabilities of dbt-adapter, we ask that you open a
- [discussion](https://github.com/dbt-labs/dbt-adapter/discussions/new?category=ideas) in the "Ideas" category instead.
+ Issues are the right place to request straightforward extensions of existing dbt-adapters functionality.
+ For "big ideas" about future capabilities of dbt-adapters, we ask that you open a
+ [discussion](https://github.com/dbt-labs/dbt-adapters/discussions/new?category=ideas) in the "Ideas" category instead.
options:
- label: I have read the [expectations for open source contributors](https://docs.getdbt.com/docs/contributing/oss-expectations)
required: true
- label: I have searched the existing issues, and I could not find an existing issue for this feature
required: true
- - label: I am requesting a straightforward extension of existing dbt-adapter functionality, rather than a Big Idea better suited to a discussion
+ - label: I am requesting a straightforward extension of existing dbt-adapters functionality, rather than a Big Idea better suited to a discussion
required: true
- type: textarea
attributes:
diff --git a/.github/ISSUE_TEMPLATE/regression-report.yml b/.github/ISSUE_TEMPLATE/regression-report.yml
index 01775507..6831ede2 100644
--- a/.github/ISSUE_TEMPLATE/regression-report.yml
+++ b/.github/ISSUE_TEMPLATE/regression-report.yml
@@ -1,5 +1,5 @@
name: ☣️ Regression
-description: Report a regression you've observed in a newer version of dbt-adapter
+description: Report a regression you've observed in a newer version of dbt-adapters
title: "[Regression] "
labels: ["regression", "triage"]
body:
@@ -57,13 +57,13 @@ body:
examples:
- **OS**: Ubuntu 20.04
- **Python**: 3.11.6 (`python3 --version`)
- - **dbt-adapter (working version)**: 1.1.0
- - **dbt-adapter (regression version)**: 1.2.0
+ - **dbt-adapters (working version)**: 1.1.0
+ - **dbt-adapters (regression version)**: 1.2.0
value: |
- OS:
- Python:
- - dbt-adapter (working version):
- - dbt-adapter (regression version):
+ - dbt-adapters (working version):
+ - dbt-adapters (regression version):
render: markdown
validations:
required: true
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 4fc2fcf8..3879b653 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -29,7 +29,7 @@ resolves #
### Checklist
-- [ ] I have read [the contributing guide](https://github.com/dbt-labs/dbt-adapter/blob/main/CONTRIBUTING.md) and understand what's expected of me
+- [ ] I have read [the contributing guide](https://github.com/dbt-labs/dbt-adapters/blob/main/CONTRIBUTING.md) and understand what's expected of me
- [ ] I have run this code in development, and it appears to resolve the stated issue
- [ ] This PR includes tests, or tests are not required/relevant for this PR
- [ ] This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1135adb8..828350dd 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -151,7 +151,7 @@ jobs:
github-release:
name: "GitHub Release"
- # ToDo: update GH release to handle adding dbt-tests-adapter and dbt-adapter assets to the same release
+ # ToDo: update GH release to handle adding dbt-tests-adapter and dbt-adapters assets to the same release
if: ${{ !failure() && !cancelled() && inputs.package == 'dbt-adapters' }}
needs: [release-inputs, build-and-test, bump-version-generate-changelog]
uses: dbt-labs/dbt-adapters/.github/workflows/github-release.yml@main
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aaa477cf..43c3937e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
-## dbt-adapter 1.8.0 - May 09, 2024
+## dbt-adapters 1.8.0 - May 09, 2024
### Features
@@ -15,7 +15,7 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
* Update Clone test to reflect core change removing `deferred` attribute from nodes
-## dbt-adapter 1.2.1 - May 21, 2024
+## dbt-adapters 1.2.1 - May 21, 2024
### Features
@@ -26,13 +26,13 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
* Add query recording for adapters which use SQLConnectionManager
* Improve memory efficiency of process_results()
-## dbt-adapter 1.1.1 - May 07, 2024
+## dbt-adapters 1.1.1 - May 07, 2024
### Features
* Enable serialization contexts
-## dbt-adapter 1.1.0 - May 01, 2024
+## dbt-adapters 1.1.0 - May 01, 2024
### Features
@@ -62,7 +62,7 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
* add support for py3.12
-## dbt-adapter 1.0.0 - April 01, 2024
+## dbt-adapters 1.0.0 - April 01, 2024
### Fixes
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c87ea23d..28f13f6c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -163,7 +163,7 @@ Remember to commit and push the file that's created.
### Signing the CLA
-> **_NOTE:_** All contributors to `dbt-adapter` must sign the
+> **_NOTE:_** All contributors to `dbt-adapters` must sign the
> [Contributor License Agreement](https://docs.getdbt.com/docs/contributor-license-agreements)(CLA).
Maintainers will be unable to merge contributions until the contributor signs the CLA.
From 6687ccc7cdf7b16ab5dbaab57d8aae5f9905b21a Mon Sep 17 00:00:00 2001
From: Kshitij Aranke
Date: Tue, 18 Jun 2024 21:27:35 +0100
Subject: [PATCH 02/17] Add `get_catalog_for_single_relation` macro and
capability (#231)
---
.../unreleased/Features-20240528-013623.yaml | 6 ++
.../test_get_catalog_for_single_relation.py | 87 +++++++++++++++++++
dbt/adapters/base/impl.py | 15 +++-
dbt/adapters/capability.py | 7 +-
dbt/adapters/sql/impl.py | 9 +-
.../macros/adapters/metadata.sql | 9 ++
pyproject.toml | 5 +-
7 files changed, 132 insertions(+), 6 deletions(-)
create mode 100644 .changes/unreleased/Features-20240528-013623.yaml
create mode 100644 dbt-tests-adapter/dbt/tests/adapter/basic/test_get_catalog_for_single_relation.py
diff --git a/.changes/unreleased/Features-20240528-013623.yaml b/.changes/unreleased/Features-20240528-013623.yaml
new file mode 100644
index 00000000..2c01e972
--- /dev/null
+++ b/.changes/unreleased/Features-20240528-013623.yaml
@@ -0,0 +1,6 @@
+kind: Features
+body: Add get_catalog_for_single_relation macro and capability to enable adapters to optimize catalog generation
+time: 2024-05-28T01:36:23.588295+01:00
+custom:
+ Author: aranke
+ Issue: "231"
diff --git a/dbt-tests-adapter/dbt/tests/adapter/basic/test_get_catalog_for_single_relation.py b/dbt-tests-adapter/dbt/tests/adapter/basic/test_get_catalog_for_single_relation.py
new file mode 100644
index 00000000..78055cc5
--- /dev/null
+++ b/dbt-tests-adapter/dbt/tests/adapter/basic/test_get_catalog_for_single_relation.py
@@ -0,0 +1,87 @@
+import pytest
+
+from dbt.tests.util import run_dbt, get_connection
+
+models__my_table_model_sql = """
+select * from {{ ref('my_seed') }}
+"""
+
+
+models__my_view_model_sql = """
+{{
+ config(
+ materialized='view',
+ )
+}}
+
+select * from {{ ref('my_seed') }}
+"""
+
+seed__my_seed_csv = """id,first_name,email,ip_address,updated_at
+1,Larry,lking0@miitbeian.gov.cn,69.135.206.194,2008-09-12 19:08:31
+"""
+
+
+class BaseGetCatalogForSingleRelation:
+ @pytest.fixture(scope="class")
+ def project_config_update(self):
+ return {"name": "get_catalog_for_single_relation"}
+
+ @pytest.fixture(scope="class")
+ def seeds(self):
+ return {
+ "my_seed.csv": seed__my_seed_csv,
+ }
+
+ @pytest.fixture(scope="class")
+ def models(self):
+ return {
+ "my_view_model.sql": models__my_view_model_sql,
+ "my_table_model.sql": models__my_table_model_sql,
+ }
+
+ @pytest.fixture(scope="class")
+ def expected_catalog_my_seed(self, project):
+ raise NotImplementedError(
+ "To use this test, please implement `get_catalog_for_single_relation`, inherited from `SQLAdapter`."
+ )
+
+ @pytest.fixture(scope="class")
+ def expected_catalog_my_model(self, project):
+ raise NotImplementedError(
+ "To use this test, please implement `get_catalog_for_single_relation`, inherited from `SQLAdapter`."
+ )
+
+ def get_relation_for_identifier(self, project, identifier):
+ return project.adapter.get_relation(
+ database=project.database,
+ schema=project.test_schema,
+ identifier=identifier,
+ )
+
+ def test_get_catalog_for_single_relation(
+ self, project, expected_catalog_my_seed, expected_catalog_my_view_model
+ ):
+ results = run_dbt(["seed"])
+ assert len(results) == 1
+
+ my_seed_relation = self.get_relation_for_identifier(project, "my_seed")
+
+ with get_connection(project.adapter):
+ actual_catalog_my_seed = project.adapter.get_catalog_for_single_relation(
+ my_seed_relation
+ )
+
+ assert actual_catalog_my_seed == expected_catalog_my_seed
+
+ results = run_dbt(["run"])
+ assert len(results) == 2
+
+ my_view_model_relation = self.get_relation_for_identifier(project, "my_view_model")
+
+ with get_connection(project.adapter):
+ actual_catalog_my_view_model = project.adapter.get_catalog_for_single_relation(
+ my_view_model_relation
+ )
+
+ assert actual_catalog_my_view_model == expected_catalog_my_view_model
diff --git a/dbt/adapters/base/impl.py b/dbt/adapters/base/impl.py
index f58f8aba..1fdbce48 100644
--- a/dbt/adapters/base/impl.py
+++ b/dbt/adapters/base/impl.py
@@ -1,10 +1,10 @@
import abc
+import time
from concurrent.futures import as_completed, Future
from contextlib import contextmanager
from datetime import datetime
from enum import Enum
from multiprocessing.context import SpawnContext
-import time
from typing import (
Any,
Callable,
@@ -23,12 +23,15 @@
TYPE_CHECKING,
)
+import pytz
from dbt_common.clients.jinja import CallableMacroGenerator
from dbt_common.contracts.constraints import (
ColumnLevelConstraint,
ConstraintType,
ModelLevelConstraint,
)
+from dbt_common.contracts.metadata import CatalogTable
+from dbt_common.events.functions import fire_event, warn_or_error
from dbt_common.exceptions import (
DbtInternalError,
DbtRuntimeError,
@@ -38,14 +41,12 @@
NotImplementedError,
UnexpectedNullError,
)
-from dbt_common.events.functions import fire_event, warn_or_error
from dbt_common.utils import (
AttrDict,
cast_to_str,
executor,
filter_null_values,
)
-import pytz
from dbt.adapters.base.column import Column as BaseColumn
from dbt.adapters.base.connections import (
@@ -222,6 +223,7 @@ class BaseAdapter(metaclass=AdapterMeta):
- truncate_relation
- rename_relation
- get_columns_in_relation
+ - get_catalog_for_single_relation
- get_column_schema_from_query
- expand_column_types
- list_relations_without_caching
@@ -627,6 +629,13 @@ def get_columns_in_relation(self, relation: BaseRelation) -> List[BaseColumn]:
"""Get a list of the columns in the given Relation."""
raise NotImplementedError("`get_columns_in_relation` is not implemented for this adapter!")
+ @abc.abstractmethod
+ def get_catalog_for_single_relation(self, relation: BaseRelation) -> Optional[CatalogTable]:
+ """Get catalog information including table-level and column-level metadata for a single relation."""
+ raise NotImplementedError(
+ "`get_catalog_for_single_relation` is not implemented for this adapter!"
+ )
+
@available.deprecated("get_columns_in_relation", lambda *a, **k: [])
def get_columns_in_table(self, schema: str, identifier: str) -> List[BaseColumn]:
"""DEPRECATED: Get a list of the columns in the given table."""
diff --git a/dbt/adapters/capability.py b/dbt/adapters/capability.py
index 305604c7..2bd49112 100644
--- a/dbt/adapters/capability.py
+++ b/dbt/adapters/capability.py
@@ -14,7 +14,12 @@ class Capability(str, Enum):
"""Indicates support for determining the time of the last table modification by querying database metadata."""
TableLastModifiedMetadataBatch = "TableLastModifiedMetadataBatch"
- """Indicates support for performantly determining the time of the last table modification by querying database metadata in batch."""
+ """Indicates support for performantly determining the time of the last table modification by querying database
+ metadata in batch."""
+
+ GetCatalogForSingleRelation = "GetCatalogForSingleRelation"
+ """Indicates support for getting catalog information including table-level and column-level metadata for a single
+ relation."""
class Support(str, Enum):
diff --git a/dbt/adapters/sql/impl.py b/dbt/adapters/sql/impl.py
index 8c6e0e8e..91ca3ebb 100644
--- a/dbt/adapters/sql/impl.py
+++ b/dbt/adapters/sql/impl.py
@@ -1,5 +1,6 @@
from typing import Any, List, Optional, Tuple, Type, TYPE_CHECKING
+from dbt_common.contracts.metadata import CatalogTable
from dbt_common.events.functions import fire_event
from dbt.adapters.base import BaseAdapter, BaseRelation, available
@@ -9,9 +10,9 @@
from dbt.adapters.exceptions import RelationTypeNullError
from dbt.adapters.sql.connections import SQLConnectionManager
-
LIST_RELATIONS_MACRO_NAME = "list_relations_without_caching"
GET_COLUMNS_IN_RELATION_MACRO_NAME = "get_columns_in_relation"
+GET_CATALOG_FOR_SINGLE_RELATION_NAME = "get_catalog_for_single_relation"
LIST_SCHEMAS_MACRO_NAME = "list_schemas"
CHECK_SCHEMA_EXISTS_MACRO_NAME = "check_schema_exists"
CREATE_SCHEMA_MACRO_NAME = "create_schema"
@@ -41,6 +42,7 @@ class SQLAdapter(BaseAdapter):
- get_catalog
- list_relations_without_caching
- get_columns_in_relation
+ - get_catalog_for_single_relation
"""
ConnectionManager: Type[SQLConnectionManager]
@@ -158,6 +160,11 @@ def get_columns_in_relation(self, relation):
GET_COLUMNS_IN_RELATION_MACRO_NAME, kwargs={"relation": relation}
)
+ def get_catalog_for_single_relation(self, relation: BaseRelation) -> Optional[CatalogTable]:
+ return self.execute_macro(
+ GET_CATALOG_FOR_SINGLE_RELATION_NAME, kwargs={"relation": relation}
+ )
+
def create_schema(self, relation: BaseRelation) -> None:
relation = relation.without_identifier()
fire_event(SchemaCreation(relation=_make_ref_key_dict(relation)))
diff --git a/dbt/include/global_project/macros/adapters/metadata.sql b/dbt/include/global_project/macros/adapters/metadata.sql
index c8e8a414..0aa7aabb 100644
--- a/dbt/include/global_project/macros/adapters/metadata.sql
+++ b/dbt/include/global_project/macros/adapters/metadata.sql
@@ -77,6 +77,15 @@
'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}
{% endmacro %}
+{% macro get_catalog_for_single_relation(relation) %}
+ {{ return(adapter.dispatch('get_catalog_for_single_relation', 'dbt')(relation)) }}
+{% endmacro %}
+
+{% macro default__get_catalog_for_single_relation(relation) %}
+ {{ exceptions.raise_not_implemented(
+ 'get_catalog_for_single_relation macro not implemented for adapter '+adapter.type()) }}
+{% endmacro %}
+
{% macro get_relations() %}
{{ return(adapter.dispatch('get_relations', 'dbt')()) }}
{% endmacro %}
diff --git a/pyproject.toml b/pyproject.toml
index a4b011a8..e50aa63a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -24,7 +24,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]
dependencies = [
- "dbt-common<2.0",
+ "dbt-common>=1.3,<2.0",
"pytz>=2015.7",
# installed via dbt-common but used directly
"agate>=1.0,<2.0",
@@ -43,6 +43,9 @@ Changelog = "https://github.com/dbt-labs/dbt-adapters/blob/main/CHANGELOG.md"
requires = ["hatchling"]
build-backend = "hatchling.build"
+[tool.hatch.metadata]
+allow-direct-references = true
+
[tool.hatch.version]
path = "dbt/adapters/__about__.py"
From 9f504d3fc7a822ebeab7da1000ad78b9a7efc8b3 Mon Sep 17 00:00:00 2001
From: Github Build Bot
Date: Tue, 18 Jun 2024 22:01:45 +0000
Subject: [PATCH 03/17] Bumping version to 1.3.0 and generate changelog
---
.changes/1.3.0.md | 5 +++++
.changes/unreleased/Features-20240528-013623.yaml | 6 ------
CHANGELOG.md | 6 ++++++
dbt/adapters/__about__.py | 2 +-
4 files changed, 12 insertions(+), 7 deletions(-)
create mode 100644 .changes/1.3.0.md
delete mode 100644 .changes/unreleased/Features-20240528-013623.yaml
diff --git a/.changes/1.3.0.md b/.changes/1.3.0.md
new file mode 100644
index 00000000..dae1f819
--- /dev/null
+++ b/.changes/1.3.0.md
@@ -0,0 +1,5 @@
+## dbt-adapters 1.3.0 - June 18, 2024
+
+### Features
+
+* Add get_catalog_for_single_relation macro and capability to enable adapters to optimize catalog generation
diff --git a/.changes/unreleased/Features-20240528-013623.yaml b/.changes/unreleased/Features-20240528-013623.yaml
deleted file mode 100644
index 2c01e972..00000000
--- a/.changes/unreleased/Features-20240528-013623.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: Features
-body: Add get_catalog_for_single_relation macro and capability to enable adapters to optimize catalog generation
-time: 2024-05-28T01:36:23.588295+01:00
-custom:
- Author: aranke
- Issue: "231"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 43c3937e..5f7560f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,12 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
* Update Clone test to reflect core change removing `deferred` attribute from nodes
+## dbt-adapters 1.3.0 - June 18, 2024
+
+### Features
+
+* Add get_catalog_for_single_relation macro and capability to enable adapters to optimize catalog generation
+
## dbt-adapters 1.2.1 - May 21, 2024
### Features
diff --git a/dbt/adapters/__about__.py b/dbt/adapters/__about__.py
index eb1d9a0f..d28b3ddc 100644
--- a/dbt/adapters/__about__.py
+++ b/dbt/adapters/__about__.py
@@ -1 +1 @@
-version = "1.2.1"
+version = "1.3.0"
From 3460543a155eeb4ccb749fe185d65c8f579dbd04 Mon Sep 17 00:00:00 2001
From: Github Build Bot
Date: Tue, 18 Jun 2024 22:58:01 +0000
Subject: [PATCH 04/17] Bumping version to 1.9.0 and generate changelog
---
.changes/1.9.0.md | 1 +
CHANGELOG.md | 2 ++
dbt-tests-adapter/dbt/tests/__about__.py | 2 +-
3 files changed, 4 insertions(+), 1 deletion(-)
create mode 100644 .changes/1.9.0.md
diff --git a/.changes/1.9.0.md b/.changes/1.9.0.md
new file mode 100644
index 00000000..2f016563
--- /dev/null
+++ b/.changes/1.9.0.md
@@ -0,0 +1 @@
+## dbt-adapters 1.9.0 - June 18, 2024
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f7560f7..016c13ee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
+## dbt-adapters 1.9.0 - June 18, 2024
+
## dbt-adapters 1.8.0 - May 09, 2024
### Features
diff --git a/dbt-tests-adapter/dbt/tests/__about__.py b/dbt-tests-adapter/dbt/tests/__about__.py
index 6aaa73b8..7aba6409 100644
--- a/dbt-tests-adapter/dbt/tests/__about__.py
+++ b/dbt-tests-adapter/dbt/tests/__about__.py
@@ -1 +1 @@
-version = "1.8.0"
+version = "1.9.0"
From 46e470cbbe8cefc98b00a2f0cd7223c43c2be4d1 Mon Sep 17 00:00:00 2001
From: Kshitij Aranke
Date: Wed, 19 Jun 2024 16:50:08 +0100
Subject: [PATCH 05/17] Make `get_catalog_for_single_relation` a concrete
method in `BaseAdapter` (#240)
---
dbt/adapters/base/impl.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/dbt/adapters/base/impl.py b/dbt/adapters/base/impl.py
index 1fdbce48..3b36022f 100644
--- a/dbt/adapters/base/impl.py
+++ b/dbt/adapters/base/impl.py
@@ -629,7 +629,6 @@ def get_columns_in_relation(self, relation: BaseRelation) -> List[BaseColumn]:
"""Get a list of the columns in the given Relation."""
raise NotImplementedError("`get_columns_in_relation` is not implemented for this adapter!")
- @abc.abstractmethod
def get_catalog_for_single_relation(self, relation: BaseRelation) -> Optional[CatalogTable]:
"""Get catalog information including table-level and column-level metadata for a single relation."""
raise NotImplementedError(
From ecf3e1d52bc31a4814f25fd67bc186bbb4ed132b Mon Sep 17 00:00:00 2001
From: Kshitij Aranke
Date: Thu, 20 Jun 2024 17:41:48 +0100
Subject: [PATCH 06/17] Remove get_catalog_for_single_relation from sql/impl.py
(#241)
---
dbt/adapters/sql/impl.py | 7 -------
1 file changed, 7 deletions(-)
diff --git a/dbt/adapters/sql/impl.py b/dbt/adapters/sql/impl.py
index 91ca3ebb..8a8473f2 100644
--- a/dbt/adapters/sql/impl.py
+++ b/dbt/adapters/sql/impl.py
@@ -1,6 +1,5 @@
from typing import Any, List, Optional, Tuple, Type, TYPE_CHECKING
-from dbt_common.contracts.metadata import CatalogTable
from dbt_common.events.functions import fire_event
from dbt.adapters.base import BaseAdapter, BaseRelation, available
@@ -12,7 +11,6 @@
LIST_RELATIONS_MACRO_NAME = "list_relations_without_caching"
GET_COLUMNS_IN_RELATION_MACRO_NAME = "get_columns_in_relation"
-GET_CATALOG_FOR_SINGLE_RELATION_NAME = "get_catalog_for_single_relation"
LIST_SCHEMAS_MACRO_NAME = "list_schemas"
CHECK_SCHEMA_EXISTS_MACRO_NAME = "check_schema_exists"
CREATE_SCHEMA_MACRO_NAME = "create_schema"
@@ -160,11 +158,6 @@ def get_columns_in_relation(self, relation):
GET_COLUMNS_IN_RELATION_MACRO_NAME, kwargs={"relation": relation}
)
- def get_catalog_for_single_relation(self, relation: BaseRelation) -> Optional[CatalogTable]:
- return self.execute_macro(
- GET_CATALOG_FOR_SINGLE_RELATION_NAME, kwargs={"relation": relation}
- )
-
def create_schema(self, relation: BaseRelation) -> None:
relation = relation.without_identifier()
fire_event(SchemaCreation(relation=_make_ref_key_dict(relation)))
From 10f197a09ebca9404e79710b49ec04ac71d23b99 Mon Sep 17 00:00:00 2001
From: Github Build Bot
Date: Thu, 20 Jun 2024 19:17:15 +0000
Subject: [PATCH 07/17] Bumping version to 1.3.1 and generate changelog
---
.changes/1.3.1.md | 1 +
CHANGELOG.md | 2 ++
dbt/adapters/__about__.py | 2 +-
3 files changed, 4 insertions(+), 1 deletion(-)
create mode 100644 .changes/1.3.1.md
diff --git a/.changes/1.3.1.md b/.changes/1.3.1.md
new file mode 100644
index 00000000..b8ec7374
--- /dev/null
+++ b/.changes/1.3.1.md
@@ -0,0 +1 @@
+## dbt-adapters 1.3.1 - June 20, 2024
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 016c13ee..b06ec9f2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,8 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
* Update Clone test to reflect core change removing `deferred` attribute from nodes
+## dbt-adapters 1.3.1 - June 20, 2024
+
## dbt-adapters 1.3.0 - June 18, 2024
### Features
diff --git a/dbt/adapters/__about__.py b/dbt/adapters/__about__.py
index d28b3ddc..35ec9a37 100644
--- a/dbt/adapters/__about__.py
+++ b/dbt/adapters/__about__.py
@@ -1 +1 @@
-version = "1.3.0"
+version = "1.3.1"
From f4880e57ae59215d6f4beedcaee290b5ffe22ae3 Mon Sep 17 00:00:00 2001
From: Github Build Bot
Date: Thu, 20 Jun 2024 19:27:26 +0000
Subject: [PATCH 08/17] Bumping version to 1.9.1 and generate changelog
---
.changes/1.9.1.md | 1 +
CHANGELOG.md | 2 ++
dbt-tests-adapter/dbt/tests/__about__.py | 2 +-
3 files changed, 4 insertions(+), 1 deletion(-)
create mode 100644 .changes/1.9.1.md
diff --git a/.changes/1.9.1.md b/.changes/1.9.1.md
new file mode 100644
index 00000000..900e6b75
--- /dev/null
+++ b/.changes/1.9.1.md
@@ -0,0 +1 @@
+## dbt-adapters 1.9.1 - June 20, 2024
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b06ec9f2..9114bcd1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
+## dbt-adapters 1.9.1 - June 20, 2024
+
## dbt-adapters 1.9.0 - June 18, 2024
## dbt-adapters 1.8.0 - May 09, 2024
diff --git a/dbt-tests-adapter/dbt/tests/__about__.py b/dbt-tests-adapter/dbt/tests/__about__.py
index 7aba6409..70227976 100644
--- a/dbt-tests-adapter/dbt/tests/__about__.py
+++ b/dbt-tests-adapter/dbt/tests/__about__.py
@@ -1 +1 @@
-version = "1.9.0"
+version = "1.9.1"
From 267cf5e31a132be6bf994c95ccce1d628043be64 Mon Sep 17 00:00:00 2001
From: Matthew McKnight <91097623+McKnight-42@users.noreply.github.com>
Date: Thu, 20 Jun 2024 14:44:33 -0500
Subject: [PATCH 09/17] update user docs-issue workflow (#238)
Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com>
---
.github/workflows/docs-issue.yml | 41 ++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 .github/workflows/docs-issue.yml
diff --git a/.github/workflows/docs-issue.yml b/.github/workflows/docs-issue.yml
new file mode 100644
index 00000000..f49cf517
--- /dev/null
+++ b/.github/workflows/docs-issue.yml
@@ -0,0 +1,41 @@
+# **what?**
+# Open an issue in docs.getdbt.com when an issue is labeled `user docs` and closed as completed
+
+# **why?**
+# To reduce barriers for keeping docs up to date
+
+# **when?**
+# When an issue is labeled `user docs` and is closed as completed. Can be labeled before or after the issue is closed.
+
+
+name: Open issues in docs.getdbt.com repo when an issue is labeled
+run-name: "Open an issue in docs.getdbt.com for issue #${{ github.event.issue.number }}"
+
+on:
+ issues:
+ types: [labeled, closed]
+
+defaults:
+ run:
+ shell: bash
+
+permissions:
+ issues: write # comments on issues
+
+jobs:
+ open_issues:
+ # we only want to run this when the issue is closed as completed and the label `user docs` has been assigned.
+ # If this logic does not exist in this workflow, it runs the
+ # risk of duplicaton of issues being created due to merge and label both triggering this workflow to run and neither having
+ # generating the comment before the other runs. This lives here instead of the shared workflow because this is where we
+ # decide if it should run or not.
+ if: |
+ (github.event.issue.state == 'closed' && github.event.issue.state_reason == 'completed') && (
+ (github.event.action == 'closed' && contains(github.event.issue.labels.*.name, 'user docs')) ||
+ (github.event.action == 'labeled' && github.event.label.name == 'user docs'))
+ uses: dbt-labs/actions/.github/workflows/open-issue-in-repo.yml@main
+ with:
+ issue_repository: "dbt-labs/docs.getdbt.com"
+ issue_title: "Docs Changes Needed from ${{ github.event.repository.name }} Issue #${{ github.event.issue.number }}"
+ issue_body: "At a minimum, update body to include a link to the page on docs.getdbt.com requiring updates and what part(s) of the page you would like to see updated."
+ secrets: inherit
From e964302121f70bacc8f827683c329e06696216cf Mon Sep 17 00:00:00 2001
From: Peter Webb
Date: Fri, 21 Jun 2024 15:21:15 -0400
Subject: [PATCH 10/17] Fix Query Timer Resolution (#246)
---
.changes/unreleased/Under the Hood-20240621-150837.yaml | 6 ++++++
dbt/adapters/events/types.py | 2 +-
dbt/adapters/sql/connections.py | 5 +++--
3 files changed, 10 insertions(+), 3 deletions(-)
create mode 100644 .changes/unreleased/Under the Hood-20240621-150837.yaml
diff --git a/.changes/unreleased/Under the Hood-20240621-150837.yaml b/.changes/unreleased/Under the Hood-20240621-150837.yaml
new file mode 100644
index 00000000..fab070c7
--- /dev/null
+++ b/.changes/unreleased/Under the Hood-20240621-150837.yaml
@@ -0,0 +1,6 @@
+kind: Under the Hood
+body: Fix query timer resolution
+time: 2024-06-21T15:08:37.43527-04:00
+custom:
+ Author: peterallenwebb
+ Issue: "246"
diff --git a/dbt/adapters/events/types.py b/dbt/adapters/events/types.py
index 7d98269d..47c48da6 100644
--- a/dbt/adapters/events/types.py
+++ b/dbt/adapters/events/types.py
@@ -190,7 +190,7 @@ def code(self) -> str:
return "E017"
def message(self) -> str:
- return f"SQL status: {self.status} in {self.elapsed} seconds"
+ return f"SQL status: {self.status} in {self.elapsed:.3f} seconds"
class SQLCommit(DebugLevel):
diff --git a/dbt/adapters/sql/connections.py b/dbt/adapters/sql/connections.py
index d8699fd3..13111a6e 100644
--- a/dbt/adapters/sql/connections.py
+++ b/dbt/adapters/sql/connections.py
@@ -88,7 +88,8 @@ def add_query(
node_info=get_node_info(),
)
)
- pre = time.time()
+
+ pre = time.perf_counter()
cursor = connection.handle.cursor()
cursor.execute(sql, bindings)
@@ -96,7 +97,7 @@ def add_query(
fire_event(
SQLQueryStatus(
status=str(self.get_response(cursor)),
- elapsed=round((time.time() - pre)),
+ elapsed=time.perf_counter() - pre,
node_info=get_node_info(),
)
)
From 0739850873de0af14bc5506accb597256f0cdad1 Mon Sep 17 00:00:00 2001
From: Kshitij Aranke
Date: Wed, 26 Jun 2024 23:47:14 +0100
Subject: [PATCH 11/17] Add optional `should_release_connection` parameter to
`connection_named` method (#247)
---
.changes/unreleased/Under the Hood-20240624-161108.yaml | 6 ++++++
dbt/adapters/base/impl.py | 8 ++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
create mode 100644 .changes/unreleased/Under the Hood-20240624-161108.yaml
diff --git a/.changes/unreleased/Under the Hood-20240624-161108.yaml b/.changes/unreleased/Under the Hood-20240624-161108.yaml
new file mode 100644
index 00000000..9042547f
--- /dev/null
+++ b/.changes/unreleased/Under the Hood-20240624-161108.yaml
@@ -0,0 +1,6 @@
+kind: Under the Hood
+body: Add optional release_connection parameter to connection_named method
+time: 2024-06-24T16:11:08.773419+01:00
+custom:
+ Author: aranke
+ Issue: "247"
diff --git a/dbt/adapters/base/impl.py b/dbt/adapters/base/impl.py
index 3b36022f..ec590137 100644
--- a/dbt/adapters/base/impl.py
+++ b/dbt/adapters/base/impl.py
@@ -319,14 +319,18 @@ def nice_connection_name(self) -> str:
return conn.name
@contextmanager
- def connection_named(self, name: str, query_header_context: Any = None) -> Iterator[None]:
+ def connection_named(
+ self, name: str, query_header_context: Any = None, should_release_connection=True
+ ) -> Iterator[None]:
try:
if self.connections.query_header is not None:
self.connections.query_header.set(name, query_header_context)
self.acquire_connection(name)
yield
finally:
- self.release_connection()
+ if should_release_connection:
+ self.release_connection()
+
if self.connections.query_header is not None:
self.connections.query_header.reset()
From d6f736956ef0948cb3fa61d2f5a00d4aa9a6a2aa Mon Sep 17 00:00:00 2001
From: Github Build Bot
Date: Tue, 2 Jul 2024 15:45:03 +0000
Subject: [PATCH 12/17] Bumping version to 1.3.2 and generate changelog
---
.changes/1.3.2.md | 6 ++++++
.changes/unreleased/Under the Hood-20240621-150837.yaml | 6 ------
.changes/unreleased/Under the Hood-20240624-161108.yaml | 6 ------
CHANGELOG.md | 7 +++++++
dbt/adapters/__about__.py | 2 +-
5 files changed, 14 insertions(+), 13 deletions(-)
create mode 100644 .changes/1.3.2.md
delete mode 100644 .changes/unreleased/Under the Hood-20240621-150837.yaml
delete mode 100644 .changes/unreleased/Under the Hood-20240624-161108.yaml
diff --git a/.changes/1.3.2.md b/.changes/1.3.2.md
new file mode 100644
index 00000000..bdc7f593
--- /dev/null
+++ b/.changes/1.3.2.md
@@ -0,0 +1,6 @@
+## dbt-adapters 1.3.2 - July 02, 2024
+
+### Under the Hood
+
+* Fix query timer resolution
+* Add optional release_connection parameter to connection_named method
diff --git a/.changes/unreleased/Under the Hood-20240621-150837.yaml b/.changes/unreleased/Under the Hood-20240621-150837.yaml
deleted file mode 100644
index fab070c7..00000000
--- a/.changes/unreleased/Under the Hood-20240621-150837.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: Under the Hood
-body: Fix query timer resolution
-time: 2024-06-21T15:08:37.43527-04:00
-custom:
- Author: peterallenwebb
- Issue: "246"
diff --git a/.changes/unreleased/Under the Hood-20240624-161108.yaml b/.changes/unreleased/Under the Hood-20240624-161108.yaml
deleted file mode 100644
index 9042547f..00000000
--- a/.changes/unreleased/Under the Hood-20240624-161108.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: Under the Hood
-body: Add optional release_connection parameter to connection_named method
-time: 2024-06-24T16:11:08.773419+01:00
-custom:
- Author: aranke
- Issue: "247"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9114bcd1..ce8d7837 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,13 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
* Update Clone test to reflect core change removing `deferred` attribute from nodes
+## dbt-adapters 1.3.2 - July 02, 2024
+
+### Under the Hood
+
+* Fix query timer resolution
+* Add optional release_connection parameter to connection_named method
+
## dbt-adapters 1.3.1 - June 20, 2024
## dbt-adapters 1.3.0 - June 18, 2024
diff --git a/dbt/adapters/__about__.py b/dbt/adapters/__about__.py
index 35ec9a37..2238c8f6 100644
--- a/dbt/adapters/__about__.py
+++ b/dbt/adapters/__about__.py
@@ -1 +1 @@
-version = "1.3.1"
+version = "1.3.2"
From d2842a73d11b2e49d72d87429314e96eae0574fe Mon Sep 17 00:00:00 2001
From: Mila Page <67295367+VersusFacit@users.noreply.github.com>
Date: Wed, 3 Jul 2024 17:42:58 +0000
Subject: [PATCH 13/17] [Adap-207] remove subshell around get show sql with
limit predicate (#249)
Co-authored-by: Mila Page
Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com>
---
.../Under the Hood-20240624-231955.yaml | 7 ++++
.gitignore | 3 ++
.../tests/adapter/dbt_show/test_dbt_show.py | 17 ++++++++++
.../global_project/macros/adapters/show.sql | 34 +++++++++++--------
4 files changed, 46 insertions(+), 15 deletions(-)
create mode 100644 .changes/unreleased/Under the Hood-20240624-231955.yaml
diff --git a/.changes/unreleased/Under the Hood-20240624-231955.yaml b/.changes/unreleased/Under the Hood-20240624-231955.yaml
new file mode 100644
index 00000000..e3eaccb7
--- /dev/null
+++ b/.changes/unreleased/Under the Hood-20240624-231955.yaml
@@ -0,0 +1,7 @@
+kind: Under the Hood
+body: --limit flag no longer subshells the query. This resolves the dbt Cloud experience
+ issue where limit prevents ordering elements..
+time: 2024-06-24T23:19:55.611142-07:00
+custom:
+ Author: versusfacit
+ Issue: "207"
diff --git a/.gitignore b/.gitignore
index a14d6d0d..807d3d41 100644
--- a/.gitignore
+++ b/.gitignore
@@ -154,3 +154,6 @@ cython_debug/
# PyCharm
.idea/
+
+# Vim
+*.swp
diff --git a/dbt-tests-adapter/dbt/tests/adapter/dbt_show/test_dbt_show.py b/dbt-tests-adapter/dbt/tests/adapter/dbt_show/test_dbt_show.py
index c00491aa..3f3d36c5 100644
--- a/dbt-tests-adapter/dbt/tests/adapter/dbt_show/test_dbt_show.py
+++ b/dbt-tests-adapter/dbt/tests/adapter/dbt_show/test_dbt_show.py
@@ -1,5 +1,6 @@
import pytest
+from dbt_common.exceptions import DbtRuntimeError
from dbt.tests.adapter.dbt_show import fixtures
from dbt.tests.util import run_dbt
@@ -47,9 +48,25 @@ def test_sql_header(self, project):
run_dbt(["show", "--select", "sql_header", "--vars", "timezone: Asia/Kolkata"])
+class BaseShowDoesNotHandleDoubleLimit:
+ """see issue: https://github.com/dbt-labs/dbt-adapters/issues/207"""
+
+ DATABASE_ERROR_MESSAGE = 'syntax error at or near "limit"'
+
+ def test_double_limit_throws_syntax_error(self, project):
+ with pytest.raises(DbtRuntimeError) as e:
+ run_dbt(["show", "--limit", "1", "--inline", "select 1 limit 1"])
+
+ assert self.DATABASE_ERROR_MESSAGE in str(e)
+
+
class TestPostgresShowSqlHeader(BaseShowSqlHeader):
pass
class TestPostgresShowLimit(BaseShowLimit):
pass
+
+
+class TestShowDoesNotHandleDoubleLimit(BaseShowDoesNotHandleDoubleLimit):
+ pass
diff --git a/dbt/include/global_project/macros/adapters/show.sql b/dbt/include/global_project/macros/adapters/show.sql
index 33a93f3d..3a5faa98 100644
--- a/dbt/include/global_project/macros/adapters/show.sql
+++ b/dbt/include/global_project/macros/adapters/show.sql
@@ -1,22 +1,26 @@
+{#
+ We expect a syntax error if dbt show is invoked both with a --limit flag to show
+ and with a limit predicate embedded in its inline query. No special handling is
+ provided out-of-box.
+#}
{% macro get_show_sql(compiled_code, sql_header, limit) -%}
- {%- if sql_header -%}
+ {%- if sql_header is not none -%}
{{ sql_header }}
- {%- endif -%}
- {%- if limit is not none -%}
+ {%- endif %}
{{ get_limit_subquery_sql(compiled_code, limit) }}
- {%- else -%}
- {{ compiled_code }}
- {%- endif -%}
{% endmacro %}
-{% macro get_limit_subquery_sql(sql, limit) %}
- {{ adapter.dispatch('get_limit_subquery_sql', 'dbt')(sql, limit) }}
-{% endmacro %}
+{#
+ Not necessarily a true subquery anymore. Now, merely a query subordinate
+ to the calling macro.
+#}
+{%- macro get_limit_subquery_sql(sql, limit) -%}
+ {{ adapter.dispatch('get_limit_sql', 'dbt')(sql, limit) }}
+{%- endmacro -%}
-{% macro default__get_limit_subquery_sql(sql, limit) %}
- select *
- from (
- {{ sql }}
- ) as model_limit_subq
- limit {{ limit }}
+{% macro default__get_limit_sql(sql, limit) %}
+ {{ compiled_code }}
+ {% if limit is not none %}
+ limit {{ limit }}
+ {%- endif -%}
{% endmacro %}
From 99e81943d39baf74e9cbd9c797227a071949a66e Mon Sep 17 00:00:00 2001
From: Mike Alfare <13974384+mikealfare@users.noreply.github.com>
Date: Wed, 3 Jul 2024 15:59:45 -0400
Subject: [PATCH 14/17] [Bug] Fix scenarios where `--empty` flag pushes limit 0
into metadata queries (#257)
---
.../unreleased/Fixes-20240702-161935.yaml | 6 +
.gitignore | 7 ++
.../dbt/tests/adapter/empty/_models.py | 111 ++++++++++++++++++
.../dbt/tests/adapter/empty/test_empty.py | 99 ++++++++--------
.../macros/adapters/apply_grants.sql | 8 +-
.../macros/adapters/columns.sql | 10 +-
.../macros/adapters/relation.sql | 2 +-
.../materializations/models/clone/clone.sql | 4 +-
.../models/clone/create_or_replace_clone.sql | 2 +-
.../models/materialized_view.sql | 4 +-
.../macros/materializations/seeds/helpers.sql | 2 +-
.../macros/materializations/seeds/seed.sql | 2 +-
.../materializations/snapshots/helpers.sql | 2 +-
.../snapshots/snapshot_merge.sql | 2 +-
.../global_project/macros/relations/drop.sql | 2 +-
.../relations/materialized_view/drop.sql | 2 +-
.../macros/relations/rename.sql | 2 +-
.../macros/relations/table/drop.sql | 2 +-
.../macros/relations/view/create.sql | 2 +-
.../macros/relations/view/drop.sql | 2 +-
.../macros/relations/view/replace.sql | 2 +-
21 files changed, 202 insertions(+), 73 deletions(-)
create mode 100644 .changes/unreleased/Fixes-20240702-161935.yaml
create mode 100644 dbt-tests-adapter/dbt/tests/adapter/empty/_models.py
diff --git a/.changes/unreleased/Fixes-20240702-161935.yaml b/.changes/unreleased/Fixes-20240702-161935.yaml
new file mode 100644
index 00000000..0b0f21ee
--- /dev/null
+++ b/.changes/unreleased/Fixes-20240702-161935.yaml
@@ -0,0 +1,6 @@
+kind: Fixes
+body: Fix scenario where using the `--empty` flag causes metadata queries to contain limit clauses
+time: 2024-07-02T16:19:35.457997-04:00
+custom:
+ Author: mikealfare
+ Issue: "213"
diff --git a/.gitignore b/.gitignore
index 807d3d41..31258db2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -155,5 +155,12 @@ cython_debug/
# PyCharm
.idea/
+# MacOS
+.DS_Store
+
+# vscode
+.vscode/
+.venv/
+
# Vim
*.swp
diff --git a/dbt-tests-adapter/dbt/tests/adapter/empty/_models.py b/dbt-tests-adapter/dbt/tests/adapter/empty/_models.py
new file mode 100644
index 00000000..f5e684f7
--- /dev/null
+++ b/dbt-tests-adapter/dbt/tests/adapter/empty/_models.py
@@ -0,0 +1,111 @@
+model_input_sql = """
+select 1 as id
+"""
+
+ephemeral_model_input_sql = """
+{{ config(materialized='ephemeral') }}
+select 2 as id
+"""
+
+raw_source_csv = """id
+3
+"""
+
+
+model_sql = """
+select *
+from {{ ref('model_input') }}
+union all
+select *
+from {{ ref('ephemeral_model_input') }}
+union all
+select *
+from {{ source('seed_sources', 'raw_source') }}
+"""
+
+
+model_inline_sql = """
+select * from {{ source('seed_sources', 'raw_source') }} as raw_source
+"""
+
+schema_sources_yml = """
+sources:
+ - name: seed_sources
+ schema: "{{ target.schema }}"
+ tables:
+ - name: raw_source
+"""
+
+
+SEED = """
+my_id,my_value
+1,a
+2,b
+3,c
+""".strip()
+
+
+SCHEMA = """
+version: 2
+
+seeds:
+ - name: my_seed
+ description: "This is my_seed"
+ columns:
+ - name: id
+ description: "This is my_seed.my_id"
+"""
+
+CONTROL = """
+select * from {{ ref("my_seed") }}
+"""
+
+
+GET_COLUMNS_IN_RELATION = """
+{{ config(materialized="table") }}
+{% set columns = adapter.get_columns_in_relation(ref("my_seed")) %}
+select * from {{ ref("my_seed") }}
+"""
+
+
+ALTER_COLUMN_TYPE = """
+{{ config(materialized="table") }}
+{{ alter_column_type(ref("my_seed"), "MY_VALUE", "varchar") }}
+select * from {{ ref("my_seed") }}
+"""
+
+
+ALTER_RELATION_COMMENT = """
+{{ config(
+ materialized="table",
+ persist_docs={"relations": True},
+) }}
+select * from {{ ref("my_seed") }}
+"""
+
+
+ALTER_COLUMN_COMMENT = """
+{{ config(
+ materialized="table",
+ persist_docs={"columns": True},
+) }}
+select * from {{ ref("my_seed") }}
+"""
+
+
+ALTER_RELATION_ADD_REMOVE_COLUMNS = """
+{{ config(materialized="table") }}
+{% set my_seed = adapter.Relation.create(this.database, this.schema, "my_seed", "table") %}
+{% set my_column = api.Column("my_column", "varchar") %}
+{% do alter_relation_add_remove_columns(my_seed, [my_column], none) %}
+{% do alter_relation_add_remove_columns(my_seed, none, [my_column]) %}
+select * from {{ ref("my_seed") }}
+"""
+
+
+TRUNCATE_RELATION = """
+{{ config(materialized="table") }}
+{% set my_seed = adapter.Relation.create(this.database, this.schema, "my_seed", "table") %}
+{{ truncate_relation(my_seed) }}
+select * from {{ ref("my_seed") }}
+"""
diff --git a/dbt-tests-adapter/dbt/tests/adapter/empty/test_empty.py b/dbt-tests-adapter/dbt/tests/adapter/empty/test_empty.py
index 2249d98d..a0a44edc 100644
--- a/dbt-tests-adapter/dbt/tests/adapter/empty/test_empty.py
+++ b/dbt-tests-adapter/dbt/tests/adapter/empty/test_empty.py
@@ -1,57 +1,23 @@
-import pytest
-
from dbt.tests.util import relation_from_name, run_dbt
+import pytest
-
-model_input_sql = """
-select 1 as id
-"""
-
-ephemeral_model_input_sql = """
-{{ config(materialized='ephemeral') }}
-select 2 as id
-"""
-
-raw_source_csv = """id
-3
-"""
-
-
-model_sql = """
-select *
-from {{ ref('model_input') }}
-union all
-select *
-from {{ ref('ephemeral_model_input') }}
-union all
-select *
-from {{ source('seed_sources', 'raw_source') }}
-"""
-
-
-schema_sources_yml = """
-sources:
- - name: seed_sources
- schema: "{{ target.schema }}"
- tables:
- - name: raw_source
-"""
+from tests.functional.adapter.empty import _models
class BaseTestEmpty:
@pytest.fixture(scope="class")
def seeds(self):
return {
- "raw_source.csv": raw_source_csv,
+ "raw_source.csv": _models.raw_source_csv,
}
@pytest.fixture(scope="class")
def models(self):
return {
- "model_input.sql": model_input_sql,
- "ephemeral_model_input.sql": ephemeral_model_input_sql,
- "model.sql": model_sql,
- "sources.yml": schema_sources_yml,
+ "model_input.sql": _models.model_input_sql,
+ "ephemeral_model_input.sql": _models.ephemeral_model_input_sql,
+ "model.sql": _models.model_sql,
+ "sources.yml": _models.schema_sources_yml,
}
def assert_row_count(self, project, relation_name: str, expected_row_count: int):
@@ -75,13 +41,9 @@ def test_run_with_empty(self, project):
class BaseTestEmptyInlineSourceRef(BaseTestEmpty):
@pytest.fixture(scope="class")
def models(self):
- model_sql = """
- select * from {{ source('seed_sources', 'raw_source') }} as raw_source
- """
-
return {
- "model.sql": model_sql,
- "sources.yml": schema_sources_yml,
+ "model.sql": _models.model_inline_sql,
+ "sources.yml": _models.schema_sources_yml,
}
def test_run_with_empty(self, project):
@@ -92,4 +54,47 @@ def test_run_with_empty(self, project):
class TestEmpty(BaseTestEmpty):
+ """
+ Though we don't create these classes anymore, we need to keep this one in case an adapter wanted to import the test as-is to automatically run it.
+ We should consider adding a deprecation warning that suggests moving this into the concrete adapter and importing `BaseTestEmpty` instead.
+ """
+
pass
+
+
+class MetadataWithEmptyFlag:
+ @pytest.fixture(scope="class")
+ def seeds(self):
+ return {"my_seed.csv": _models.SEED}
+
+ @pytest.fixture(scope="class")
+ def models(self):
+ return {
+ "schema.yml": _models.SCHEMA,
+ "control.sql": _models.CONTROL,
+ "get_columns_in_relation.sql": _models.GET_COLUMNS_IN_RELATION,
+ "alter_column_type.sql": _models.ALTER_COLUMN_TYPE,
+ "alter_relation_comment.sql": _models.ALTER_RELATION_COMMENT,
+ "alter_column_comment.sql": _models.ALTER_COLUMN_COMMENT,
+ "alter_relation_add_remove_columns.sql": _models.ALTER_RELATION_ADD_REMOVE_COLUMNS,
+ "truncate_relation.sql": _models.TRUNCATE_RELATION,
+ }
+
+ @pytest.fixture(scope="class", autouse=True)
+ def setup(self, project):
+ run_dbt(["seed"])
+
+ @pytest.mark.parametrize(
+ "model",
+ [
+ "control",
+ "get_columns_in_relation",
+ "alter_column_type",
+ "alter_relation_comment",
+ "alter_column_comment",
+ "alter_relation_add_remove_columns",
+ "truncate_relation",
+ ],
+ )
+ def test_run(self, project, model):
+ run_dbt(["run", "--empty", "--select", model])
diff --git a/dbt/include/global_project/macros/adapters/apply_grants.sql b/dbt/include/global_project/macros/adapters/apply_grants.sql
index 10906e7f..c75eef89 100644
--- a/dbt/include/global_project/macros/adapters/apply_grants.sql
+++ b/dbt/include/global_project/macros/adapters/apply_grants.sql
@@ -61,7 +61,7 @@
{% endmacro %}
{% macro default__get_show_grant_sql(relation) %}
- show grants on {{ relation }}
+ show grants on {{ relation.render() }}
{% endmacro %}
@@ -70,7 +70,7 @@
{% endmacro %}
{%- macro default__get_grant_sql(relation, privilege, grantees) -%}
- grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}
+ grant {{ privilege }} on {{ relation.render() }} to {{ grantees | join(', ') }}
{%- endmacro -%}
@@ -79,7 +79,7 @@
{% endmacro %}
{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}
- revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}
+ revoke {{ privilege }} on {{ relation.render() }} from {{ grantees | join(', ') }}
{%- endmacro -%}
@@ -147,7 +147,7 @@
{% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}
{% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}
{% if not (needs_granting or needs_revoking) %}
- {{ log('On ' ~ relation ~': All grants are in place, no revocation or granting needed.')}}
+ {{ log('On ' ~ relation.render() ~': All grants are in place, no revocation or granting needed.')}}
{% endif %}
{% else %}
{#-- We don't think there's any chance of previous grants having carried over. --#}
diff --git a/dbt/include/global_project/macros/adapters/columns.sql b/dbt/include/global_project/macros/adapters/columns.sql
index 663a827b..96e6f3f2 100644
--- a/dbt/include/global_project/macros/adapters/columns.sql
+++ b/dbt/include/global_project/macros/adapters/columns.sql
@@ -96,10 +96,10 @@
{%- set tmp_column = column_name + "__dbt_alter" -%}
{% call statement('alter_column_type') %}
- alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};
- update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};
- alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;
- alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}
+ alter table {{ relation.render() }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};
+ update {{ relation.render() }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};
+ alter table {{ relation.render() }} drop column {{ adapter.quote(column_name) }} cascade;
+ alter table {{ relation.render() }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}
{% endcall %}
{% endmacro %}
@@ -120,7 +120,7 @@
{% set sql -%}
- alter {{ relation.type }} {{ relation }}
+ alter {{ relation.type }} {{ relation.render() }}
{% for column in add_columns %}
add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}
diff --git a/dbt/include/global_project/macros/adapters/relation.sql b/dbt/include/global_project/macros/adapters/relation.sql
index 1c2bd880..b9af4969 100644
--- a/dbt/include/global_project/macros/adapters/relation.sql
+++ b/dbt/include/global_project/macros/adapters/relation.sql
@@ -38,7 +38,7 @@
{% macro default__truncate_relation(relation) -%}
{% call statement('truncate_relation') -%}
- truncate table {{ relation }}
+ truncate table {{ relation.render() }}
{%- endcall %}
{% endmacro %}
diff --git a/dbt/include/global_project/macros/materializations/models/clone/clone.sql b/dbt/include/global_project/macros/materializations/models/clone/clone.sql
index 01c8c393..56d80082 100644
--- a/dbt/include/global_project/macros/materializations/models/clone/clone.sql
+++ b/dbt/include/global_project/macros/materializations/models/clone/clone.sql
@@ -27,14 +27,14 @@
{%- set target_relation = this.incorporate(type='table') -%}
{% if existing_relation is not none and not existing_relation.is_table %}
- {{ log("Dropping relation " ~ existing_relation ~ " because it is of type " ~ existing_relation.type) }}
+ {{ log("Dropping relation " ~ existing_relation.render() ~ " because it is of type " ~ existing_relation.type) }}
{{ drop_relation_if_exists(existing_relation) }}
{% endif %}
-- as a general rule, data platforms that can clone tables can also do atomic 'create or replace'
{% call statement('main') %}
{% if target_relation and defer_relation and target_relation == defer_relation %}
- {{ log("Target relation and defer relation are the same, skipping clone for relation: " ~ target_relation) }}
+ {{ log("Target relation and defer relation are the same, skipping clone for relation: " ~ target_relation.render()) }}
{% else %}
{{ create_or_replace_clone(target_relation, defer_relation) }}
{% endif %}
diff --git a/dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql b/dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql
index 204e9e87..cdb2559c 100644
--- a/dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql
+++ b/dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql
@@ -3,5 +3,5 @@
{% endmacro %}
{% macro default__create_or_replace_clone(this_relation, defer_relation) %}
- create or replace table {{ this_relation }} clone {{ defer_relation }}
+ create or replace table {{ this_relation.render() }} clone {{ defer_relation.render() }}
{% endmacro %}
diff --git a/dbt/include/global_project/macros/materializations/models/materialized_view.sql b/dbt/include/global_project/macros/materializations/models/materialized_view.sql
index 6dc30bf9..a39f8aa2 100644
--- a/dbt/include/global_project/macros/materializations/models/materialized_view.sql
+++ b/dbt/include/global_project/macros/materializations/models/materialized_view.sql
@@ -71,9 +71,9 @@
{% set build_sql = get_alter_materialized_view_as_sql(target_relation, configuration_changes, sql, existing_relation, backup_relation, intermediate_relation) %}
{% elif on_configuration_change == 'continue' %}
{% set build_sql = '' %}
- {{ exceptions.warn("Configuration changes were identified and `on_configuration_change` was set to `continue` for `" ~ target_relation ~ "`") }}
+ {{ exceptions.warn("Configuration changes were identified and `on_configuration_change` was set to `continue` for `" ~ target_relation.render() ~ "`") }}
{% elif on_configuration_change == 'fail' %}
- {{ exceptions.raise_fail_fast_error("Configuration changes were identified and `on_configuration_change` was set to `fail` for `" ~ target_relation ~ "`") }}
+ {{ exceptions.raise_fail_fast_error("Configuration changes were identified and `on_configuration_change` was set to `fail` for `" ~ target_relation.render() ~ "`") }}
{% else %}
-- this only happens if the user provides a value other than `apply`, 'skip', 'fail'
diff --git a/dbt/include/global_project/macros/materializations/seeds/helpers.sql b/dbt/include/global_project/macros/materializations/seeds/helpers.sql
index 44dbf370..d87c258b 100644
--- a/dbt/include/global_project/macros/materializations/seeds/helpers.sql
+++ b/dbt/include/global_project/macros/materializations/seeds/helpers.sql
@@ -37,7 +37,7 @@
{% set sql = create_csv_table(model, agate_table) %}
{% else %}
{{ adapter.truncate_relation(old_relation) }}
- {% set sql = "truncate table " ~ old_relation %}
+ {% set sql = "truncate table " ~ old_relation.render() %}
{% endif %}
{{ return(sql) }}
diff --git a/dbt/include/global_project/macros/materializations/seeds/seed.sql b/dbt/include/global_project/macros/materializations/seeds/seed.sql
index 3b66252d..4ee4fb80 100644
--- a/dbt/include/global_project/macros/materializations/seeds/seed.sql
+++ b/dbt/include/global_project/macros/materializations/seeds/seed.sql
@@ -22,7 +22,7 @@
-- build model
{% set create_table_sql = "" %}
{% if exists_as_view %}
- {{ exceptions.raise_compiler_error("Cannot seed to '{}', it is a view".format(old_relation)) }}
+ {{ exceptions.raise_compiler_error("Cannot seed to '{}', it is a view".format(old_relation.render())) }}
{% elif exists_as_table %}
{% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}
{% else %}
diff --git a/dbt/include/global_project/macros/materializations/snapshots/helpers.sql b/dbt/include/global_project/macros/materializations/snapshots/helpers.sql
index 7fd4bfd5..bb71974c 100644
--- a/dbt/include/global_project/macros/materializations/snapshots/helpers.sql
+++ b/dbt/include/global_project/macros/materializations/snapshots/helpers.sql
@@ -8,7 +8,7 @@
{% macro default__create_columns(relation, columns) %}
{% for column in columns %}
{% call statement() %}
- alter table {{ relation }} add column "{{ column.name }}" {{ column.data_type }};
+ alter table {{ relation.render() }} add column "{{ column.name }}" {{ column.data_type }};
{% endcall %}
{% endfor %}
{% endmacro %}
diff --git a/dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql b/dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql
index 6bc50fd3..56798811 100644
--- a/dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql
+++ b/dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql
@@ -7,7 +7,7 @@
{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}
{%- set insert_cols_csv = insert_cols | join(', ') -%}
- merge into {{ target }} as DBT_INTERNAL_DEST
+ merge into {{ target.render() }} as DBT_INTERNAL_DEST
using {{ source }} as DBT_INTERNAL_SOURCE
on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id
diff --git a/dbt/include/global_project/macros/relations/drop.sql b/dbt/include/global_project/macros/relations/drop.sql
index 58abd14d..e66511da 100644
--- a/dbt/include/global_project/macros/relations/drop.sql
+++ b/dbt/include/global_project/macros/relations/drop.sql
@@ -16,7 +16,7 @@
{{ drop_materialized_view(relation) }}
{%- else -%}
- drop {{ relation.type }} if exists {{ relation }} cascade
+ drop {{ relation.type }} if exists {{ relation.render() }} cascade
{%- endif -%}
diff --git a/dbt/include/global_project/macros/relations/materialized_view/drop.sql b/dbt/include/global_project/macros/relations/materialized_view/drop.sql
index b218d0f3..8235b1c6 100644
--- a/dbt/include/global_project/macros/relations/materialized_view/drop.sql
+++ b/dbt/include/global_project/macros/relations/materialized_view/drop.sql
@@ -10,5 +10,5 @@ actually executes the drop, and `get_drop_sql`, which returns the template.
{% macro default__drop_materialized_view(relation) -%}
- drop materialized view if exists {{ relation }} cascade
+ drop materialized view if exists {{ relation.render() }} cascade
{%- endmacro %}
diff --git a/dbt/include/global_project/macros/relations/rename.sql b/dbt/include/global_project/macros/relations/rename.sql
index d7f3a72e..4b913df3 100644
--- a/dbt/include/global_project/macros/relations/rename.sql
+++ b/dbt/include/global_project/macros/relations/rename.sql
@@ -30,6 +30,6 @@
{% macro default__rename_relation(from_relation, to_relation) -%}
{% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}
{% call statement('rename_relation') -%}
- alter table {{ from_relation }} rename to {{ target_name }}
+ alter table {{ from_relation.render() }} rename to {{ target_name }}
{%- endcall %}
{% endmacro %}
diff --git a/dbt/include/global_project/macros/relations/table/drop.sql b/dbt/include/global_project/macros/relations/table/drop.sql
index d7d5941c..038ded9e 100644
--- a/dbt/include/global_project/macros/relations/table/drop.sql
+++ b/dbt/include/global_project/macros/relations/table/drop.sql
@@ -10,5 +10,5 @@ actually executes the drop, and `get_drop_sql`, which returns the template.
{% macro default__drop_table(relation) -%}
- drop table if exists {{ relation }} cascade
+ drop table if exists {{ relation.render() }} cascade
{%- endmacro %}
diff --git a/dbt/include/global_project/macros/relations/view/create.sql b/dbt/include/global_project/macros/relations/view/create.sql
index 41cd196c..ee83befa 100644
--- a/dbt/include/global_project/macros/relations/view/create.sql
+++ b/dbt/include/global_project/macros/relations/view/create.sql
@@ -16,7 +16,7 @@
{%- set sql_header = config.get('sql_header', none) -%}
{{ sql_header if sql_header is not none }}
- create view {{ relation }}
+ create view {{ relation.render() }}
{% set contract_config = config.get('contract') %}
{% if contract_config.enforced %}
{{ get_assert_columns_equivalent(sql) }}
diff --git a/dbt/include/global_project/macros/relations/view/drop.sql b/dbt/include/global_project/macros/relations/view/drop.sql
index 7e1924fa..84c91a36 100644
--- a/dbt/include/global_project/macros/relations/view/drop.sql
+++ b/dbt/include/global_project/macros/relations/view/drop.sql
@@ -10,5 +10,5 @@ actually executes the drop, and `get_drop_sql`, which returns the template.
{% macro default__drop_view(relation) -%}
- drop view if exists {{ relation }} cascade
+ drop view if exists {{ relation.render() }} cascade
{%- endmacro %}
diff --git a/dbt/include/global_project/macros/relations/view/replace.sql b/dbt/include/global_project/macros/relations/view/replace.sql
index 1da06134..a0f0dc76 100644
--- a/dbt/include/global_project/macros/relations/view/replace.sql
+++ b/dbt/include/global_project/macros/relations/view/replace.sql
@@ -61,6 +61,6 @@
{% endmacro %}
{% macro default__handle_existing_table(full_refresh, old_relation) %}
- {{ log("Dropping relation " ~ old_relation ~ " because it is of type " ~ old_relation.type) }}
+ {{ log("Dropping relation " ~ old_relation.render() ~ " because it is of type " ~ old_relation.type) }}
{{ adapter.drop_relation(old_relation) }}
{% endmacro %}
From 7e9731cd819d521ffd638f0e1b96a96e58504eb5 Mon Sep 17 00:00:00 2001
From: Mike Alfare <13974384+mikealfare@users.noreply.github.com>
Date: Wed, 3 Jul 2024 17:25:11 -0400
Subject: [PATCH 15/17] Fix import statement for `--empty` tests (#258)
---
dbt-tests-adapter/dbt/tests/adapter/empty/test_empty.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dbt-tests-adapter/dbt/tests/adapter/empty/test_empty.py b/dbt-tests-adapter/dbt/tests/adapter/empty/test_empty.py
index a0a44edc..de15bd5b 100644
--- a/dbt-tests-adapter/dbt/tests/adapter/empty/test_empty.py
+++ b/dbt-tests-adapter/dbt/tests/adapter/empty/test_empty.py
@@ -1,7 +1,7 @@
from dbt.tests.util import relation_from_name, run_dbt
import pytest
-from tests.functional.adapter.empty import _models
+from dbt.tests.adapter.empty import _models
class BaseTestEmpty:
From 78b2b4c5867e13d07f5c5d9bb4ffcd6081aedd22 Mon Sep 17 00:00:00 2001
From: Github Build Bot
Date: Tue, 9 Jul 2024 20:07:46 +0000
Subject: [PATCH 16/17] Bumping version to 1.3.3 and generate changelog
---
.changes/1.3.3.md | 9 +++++++++
.changes/unreleased/Fixes-20240702-161935.yaml | 6 ------
.../unreleased/Under the Hood-20240624-231955.yaml | 7 -------
CHANGELOG.md | 10 ++++++++++
dbt/adapters/__about__.py | 2 +-
5 files changed, 20 insertions(+), 14 deletions(-)
create mode 100644 .changes/1.3.3.md
delete mode 100644 .changes/unreleased/Fixes-20240702-161935.yaml
delete mode 100644 .changes/unreleased/Under the Hood-20240624-231955.yaml
diff --git a/.changes/1.3.3.md b/.changes/1.3.3.md
new file mode 100644
index 00000000..22ab18e3
--- /dev/null
+++ b/.changes/1.3.3.md
@@ -0,0 +1,9 @@
+## dbt-adapters 1.3.3 - July 09, 2024
+
+### Fixes
+
+* Fix scenario where using the `--empty` flag causes metadata queries to contain limit clauses
+
+### Under the Hood
+
+* --limit flag no longer subshells the query. This resolves the dbt Cloud experience issue where limit prevents ordering elements..
diff --git a/.changes/unreleased/Fixes-20240702-161935.yaml b/.changes/unreleased/Fixes-20240702-161935.yaml
deleted file mode 100644
index 0b0f21ee..00000000
--- a/.changes/unreleased/Fixes-20240702-161935.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: Fixes
-body: Fix scenario where using the `--empty` flag causes metadata queries to contain limit clauses
-time: 2024-07-02T16:19:35.457997-04:00
-custom:
- Author: mikealfare
- Issue: "213"
diff --git a/.changes/unreleased/Under the Hood-20240624-231955.yaml b/.changes/unreleased/Under the Hood-20240624-231955.yaml
deleted file mode 100644
index e3eaccb7..00000000
--- a/.changes/unreleased/Under the Hood-20240624-231955.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-kind: Under the Hood
-body: --limit flag no longer subshells the query. This resolves the dbt Cloud experience
- issue where limit prevents ordering elements..
-time: 2024-06-24T23:19:55.611142-07:00
-custom:
- Author: versusfacit
- Issue: "207"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ce8d7837..8834049e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,16 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
* Update Clone test to reflect core change removing `deferred` attribute from nodes
+## dbt-adapters 1.3.3 - July 09, 2024
+
+### Fixes
+
+* Fix scenario where using the `--empty` flag causes metadata queries to contain limit clauses
+
+### Under the Hood
+
+* --limit flag no longer subshells the query. This resolves the dbt Cloud experience issue where limit prevents ordering elements..
+
## dbt-adapters 1.3.2 - July 02, 2024
### Under the Hood
diff --git a/dbt/adapters/__about__.py b/dbt/adapters/__about__.py
index 2238c8f6..cfa2db68 100644
--- a/dbt/adapters/__about__.py
+++ b/dbt/adapters/__about__.py
@@ -1 +1 @@
-version = "1.3.2"
+version = "1.3.3"
From 594ad067ea1e85f4cef4fb2b2b420695c6ba936f Mon Sep 17 00:00:00 2001
From: Github Build Bot
Date: Tue, 9 Jul 2024 20:22:10 +0000
Subject: [PATCH 17/17] Bumping version to 1.9.2 and generate changelog
---
.changes/1.9.2.md | 1 +
CHANGELOG.md | 2 ++
dbt-tests-adapter/dbt/tests/__about__.py | 2 +-
3 files changed, 4 insertions(+), 1 deletion(-)
create mode 100644 .changes/1.9.2.md
diff --git a/.changes/1.9.2.md b/.changes/1.9.2.md
new file mode 100644
index 00000000..26505f20
--- /dev/null
+++ b/.changes/1.9.2.md
@@ -0,0 +1 @@
+## dbt-adapters 1.9.2 - July 09, 2024
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8834049e..1a2f1833 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
+## dbt-adapters 1.9.2 - July 09, 2024
+
## dbt-adapters 1.9.1 - June 20, 2024
## dbt-adapters 1.9.0 - June 18, 2024
diff --git a/dbt-tests-adapter/dbt/tests/__about__.py b/dbt-tests-adapter/dbt/tests/__about__.py
index 70227976..1b022739 100644
--- a/dbt-tests-adapter/dbt/tests/__about__.py
+++ b/dbt-tests-adapter/dbt/tests/__about__.py
@@ -1 +1 @@
-version = "1.9.1"
+version = "1.9.2"