Skip to content

Commit

Permalink
Merge branch 'main' into upgrade_protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Nov 12, 2024
2 parents d2436cb + a72379e commit e397daa
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 113 deletions.
1 change: 1 addition & 0 deletions .changes/1.10.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## dbt-adapters 1.10.4 - November 11, 2024
12 changes: 12 additions & 0 deletions .changes/1.11.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## dbt-adapters 1.11.0 - November 11, 2024

### Features

- Use a behavior flag to gate microbatch functionality (instead of an environment variable) ([#327](https://github.com/dbt-labs/dbt-adapters/issues/327))

### Under the Hood

- Add `query_id` to SQLQueryStatus ([#342](https://github.com/dbt-labs/dbt-adapters/issues/342))

### Contributors
- [@cmcarthur](https://github.com/cmcarthur) ([#342](https://github.com/dbt-labs/dbt-adapters/issues/342))
2 changes: 1 addition & 1 deletion .github/actions/publish-pypi/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ runs:
shell: bash

- name: Publish artifacts to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@release/v1.11
with:
repository-url: ${{ inputs.repository-url }}
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,24 @@ 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.10.3 - October 29, 2024
## dbt-adapters 1.11.0 - November 11, 2024

### Features

- Use a behavior flag to gate microbatch functionality (instead of an environment variable) ([#327](https://github.com/dbt-labs/dbt-adapters/issues/327))

### Under the Hood

- Add `query_id` to SQLQueryStatus ([#342](https://github.com/dbt-labs/dbt-adapters/issues/342))

### Contributors
- [@cmcarthur](https://github.com/cmcarthur) ([#342](https://github.com/dbt-labs/dbt-adapters/issues/342))

## dbt-adapters 1.10.4 - November 11, 2024



## dbt-adapters 1.10.3 - October 29, 2024

## dbt-adapters 1.10.2 - October 01, 2024

Expand Down
2 changes: 1 addition & 1 deletion dbt-tests-adapter/dbt/tests/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.10.3"
version = "1.10.4"
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
from pprint import pformat
from unittest import mock

import pytest

Expand Down Expand Up @@ -63,7 +61,6 @@ def assert_row_count(self, project, relation_name: str, expected_row_count: int)

assert len(result) == expected_row_count, f"{relation_name}:{pformat(result)}"

@mock.patch.dict(os.environ, {"DBT_EXPERIMENTAL_MICROBATCH": "True"})
def test_run_with_event_time(self, project, insert_two_rows_sql):
# initial run -- backfills all data
with patch_microbatch_end_time("2020-01-03 13:57:00"):
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.8.0"
version = "1.11.0"
22 changes: 19 additions & 3 deletions dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
Union,
TYPE_CHECKING,
)
import os
import pytz
from dbt_common.behavior_flags import Behavior, BehaviorFlag
from dbt_common.clients.jinja import CallableMacroGenerator
Expand Down Expand Up @@ -316,7 +315,13 @@ def _behavior_flags(self) -> List[BehaviorFlag]:
"""
This method should be overwritten by adapter maintainers to provide platform-specific flags
"""
return []
return [
{
"name": "require_batched_execution_for_custom_microbatch_strategy",
"default": False,
"docs_url": "https://docs.getdbt.com/docs/build/incremental-microbatch",
}
]

###
# Methods that pass through to the connection manager
Expand Down Expand Up @@ -1574,13 +1579,24 @@ def valid_incremental_strategies(self):

def builtin_incremental_strategies(self):
builtin_strategies = ["append", "delete+insert", "merge", "insert_overwrite"]
if os.environ.get("DBT_EXPERIMENTAL_MICROBATCH"):
if self.behavior.require_batched_execution_for_custom_microbatch_strategy.no_warn:
builtin_strategies.append("microbatch")

return builtin_strategies

@available.parse_none
def get_incremental_strategy_macro(self, model_context, strategy: str):
"""Gets the macro for the given incremental strategy.
Additionally some validations are done:
1. Assert that if the given strategy is a "builtin" strategy, then it must
also be defined as a "valid" strategy for the associated adapter
2. Assert that the incremental strategy exists in the model context
Notably, something be defined by the adapter as "valid" without it being
a "builtin", and nothing will break (and that is desirable).
"""

# Construct macro_name from strategy name
if strategy is None:
strategy = "default"
Expand Down
1 change: 1 addition & 0 deletions dbt/adapters/contracts/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AdapterResponse(dbtClassMixin):
_message: str
code: Optional[str] = None
rows_affected: Optional[int] = None
query_id: Optional[str] = None

def __str__(self):
return self._message
Expand Down
1 change: 1 addition & 0 deletions dbt/adapters/events/adapter_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ message SQLQueryStatus {
AdapterNodeInfo node_info = 1;
string status = 2;
float elapsed = 3;
string query_id = 4;
}

message SQLQueryStatusMsg {
Expand Down
205 changes: 103 additions & 102 deletions dbt/adapters/events/adapter_types_pb2.py

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion dbt/adapters/sql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ def add_query(
cursor = connection.handle.cursor()
cursor.execute(sql, bindings)

result = self.get_response(cursor)

fire_event(
SQLQueryStatus(
status=str(self.get_response(cursor)),
status=str(result),
elapsed=time.perf_counter() - pre,
node_info=get_node_info(),
query_id=result.query_id,
)
)

Expand Down

0 comments on commit e397daa

Please sign in to comment.