Skip to content

Commit

Permalink
Merge branch 'main' into paw/record
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-rogers-dbt authored May 2, 2024
2 parents ffe6c15 + c47c8b5 commit 9d85431
Show file tree
Hide file tree
Showing 23 changed files with 155 additions and 112 deletions.
12 changes: 0 additions & 12 deletions .changes/1.1.0-rc1.md

This file was deleted.

29 changes: 29 additions & 0 deletions .changes/1.1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## dbt-adapter 1.1.0 - May 01, 2024

### Features

* Debug log when `type_code` fails to convert to a `data_type`
* Introduce TableLastModifiedMetadataBatch and implement BaseAdapter.calculate_freshness_from_metadata_batch
* Support for sql fixtures in unit testing
* Cross-database `cast` macro
* Allow adapters to opt out of aliasing the subquery generated by render_limited
* subquery alias generated by render_limited now includes the relation name to mitigate duplicate aliasing

### Fixes

* Fix adapter-specific cast handling for constraint enforcement

### Docs

* Use `dbt-adapters` throughout the contributing guide

### Under the Hood

* Add the option to set the log level of the AdapterRegistered event
* Update dependabot config to cover GHA
* Validate that dbt-core and dbt-adapters remain de-coupled
* remove dbt_version from query comment test fixture

### Dependencies

* add support for py3.12
6 changes: 0 additions & 6 deletions .changes/1.1.0/Features-20240323-160251.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/1.1.0/Features-20240325-180611.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/1.1.0/Features-20240409-084844.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/1.1.0/Under the Hood-20240329-093307.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/1.1.0/Under the Hood-20240410-184109.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .changes/1.8.0-rc1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## dbt-adapter 1.8.0-rc1 - May 01, 2024
6 changes: 0 additions & 6 deletions .changes/unreleased/Dependencies-20240424-140142.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/unreleased/Features-20240412-192040.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/unreleased/Features-20240418-155123.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/unreleased/Features-20240418-155531.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240501-091604.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Cross-database `date` macro
time: 2024-05-01T09:16:04.909686-06:00
custom:
Author: dbeatty10
Issue: https://github.com/dbt-labs/dbt-core/issues/8831
6 changes: 0 additions & 6 deletions .changes/unreleased/Fixes-20240411-185203.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/unreleased/Under the Hood-20240417-192843.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/unreleased/Under the Hood-20240423-094843.yaml

This file was deleted.

21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,37 @@ 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.1.0-rc1 - April 17, 2024
## dbt-adapter 1.8.0-rc1 - May 01, 2024

## dbt-adapter 1.1.0 - May 01, 2024

### Features

* Debug log when `type_code` fails to convert to a `data_type`
* Introduce TableLastModifiedMetadataBatch and implement BaseAdapter.calculate_freshness_from_metadata_batch
* Support for sql fixtures in unit testing
* Cross-database `cast` macro
* Allow adapters to opt out of aliasing the subquery generated by render_limited
* subquery alias generated by render_limited now includes the relation name to mitigate duplicate aliasing

### Fixes

* Fix adapter-specific cast handling for constraint enforcement

### Docs

* Use `dbt-adapters` throughout the contributing guide

### Under the Hood

* Add the option to set the log level of the AdapterRegistered event
* Update dependabot config to cover GHA
* Validate that dbt-core and dbt-adapters remain de-coupled
* remove dbt_version from query comment test fixture

### Dependencies

* add support for py3.12

## dbt-adapter 1.0.0 - April 01, 2024

Expand Down
48 changes: 24 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to `dbt-adapter`
# Contributing to `dbt-adapters`

- [About this document](#about-this-document)
- [Getting the code](#getting-the-code)
Expand All @@ -10,8 +10,8 @@

## About this document

This document is a guide for anyone interested in contributing to `dbt-adapter`.
It outlines how to install `dbt-adapter` for development,
This document is a guide for anyone interested in contributing to `dbt-adapters`.
It outlines how to install `dbt-adapters` for development,
run tests locally, update documentation, and submit pull requests.
This guide assumes users are developing on a Linux or MacOS system.
The following utilities are needed or will be installed in this guide:
Expand All @@ -31,35 +31,35 @@ Almost all information there is applicable here.

## Getting the code

`git` is required to download, modify, and sync the `dbt-adapter` code.
`git` is required to download, modify, and sync the `dbt-adapters` code.
There are several ways to install Git. For MacOS:

- Install [Xcode](https://developer.apple.com/support/xcode/)
- Install [Xcode Command Line Tools](https://mac.install.guide/commandlinetools/index.html)

### External contributors

Contributors external to the `dbt-labs` GitHub organization can contribute to `dbt-adapter`
by forking the `dbt-adapter` repository. For more on forking, check out the
Contributors external to the `dbt-labs` GitHub organization can contribute to `dbt-adapters`
by forking the `dbt-adapters` repository. For more on forking, check out the
[GitHub docs on forking](https://help.github.com/en/articles/fork-a-repo). To contribute:

1. Fork the `dbt-labs/dbt-adapter` repository (e.g. `{forked-org}/dbt-adapter`)
2. Clone `{forked-org}/dbt-adapter` locally
1. Fork the `dbt-labs/dbt-adapters` repository (e.g. `{forked-org}/dbt-adapters`)
2. Clone `{forked-org}/dbt-adapters` locally
3. Check out a new branch locally
4. Make changes in the new branch
5. Push the new branch to `{forked-org}/dbt-adapter`
6. Open a pull request in `dbt-labs/dbt-adapter` to merge `{forked-org}/dbt-adapter/{new-branch}` into `main`
5. Push the new branch to `{forked-org}/dbt-adapters`
6. Open a pull request in `dbt-labs/dbt-adapters` to merge `{forked-org}/dbt-adapters/{new-branch}` into `main`

### dbt Labs contributors

Contributors in the `dbt Labs` GitHub organization have push access to the `dbt-adapter` repo.
Rather than forking `dbt-labs/dbt-adapter`, use `dbt-labs/dbt-adapter` directly. To contribute:
Contributors in the `dbt Labs` GitHub organization have push access to the `dbt-adapters` repo.
Rather than forking `dbt-labs/dbt-adapters`, use `dbt-labs/dbt-adapters` directly. To contribute:

1. Clone `dbt-labs/dbt-adapter` locally
1. Clone `dbt-labs/dbt-adapters` locally
2. Check out a new branch locally
3. Make changes in the new branch
4. Push the new branch to `dbt-labs/dbt-adapter`
5. Open a pull request in `dbt-labs/dbt-adapter` to merge `{new-branch}` into `main`
4. Push the new branch to `dbt-labs/dbt-adapters`
5. Open a pull request in `dbt-labs/dbt-adapters` to merge `{new-branch}` into `main`


## Developing
Expand All @@ -72,19 +72,19 @@ Rather than forking `dbt-labs/dbt-adapter`, use `dbt-labs/dbt-adapter` directly.
```
2. Configure and activate a virtual environment using `virtualenv` as described in
[Setting up an environment](https://github.com/dbt-labs/dbt-core/blob/HEAD/CONTRIBUTING.md#setting-up-an-environment)
3. Install `dbt-adapter` and development dependencies in the virtual environment
3. Install `dbt-adapters` and development dependencies in the virtual environment
```shell
pip install -e .[dev]
```

When `dbt-adapter` is installed this way, any changes made to the `dbt-adapter` source code
When `dbt-adapters` is installed this way, any changes made to the `dbt-adapters` source code
will be reflected in the virtual environment immediately.


## Testing

`dbt-adapter` contains [unit](https://github.com/dbt-labs/dbt-adapter/tree/main/tests/unit)
and [functional](https://github.com/dbt-labs/dbt-adapter/tree/main/tests/functional) tests.
`dbt-adapters` contains [unit](https://github.com/dbt-labs/dbt-adapters/tree/main/tests/unit)
and [functional](https://github.com/dbt-labs/dbt-adapters/tree/main/tests/functional) tests.

### Unit tests

Expand Down Expand Up @@ -134,7 +134,7 @@ python -m pytest tests/functional/$test_dir_and_filename.py::$test_class_name::$

### User documentation

Many changes will require an update to `dbt-adapter` user documentation.
Many changes will require an update to `dbt-adapters` user documentation.
All contributors, whether internal or external, are encouraged to open an issue or PR
in the docs repo when submitting user-facing changes. Here are some relevant links:

Expand All @@ -145,7 +145,7 @@ in the docs repo when submitting user-facing changes. Here are some relevant lin

### CHANGELOG entry

`dbt-adapter` uses [changie](https://changie.dev) to generate `CHANGELOG` entries.
`dbt-adapters` uses [changie](https://changie.dev) to generate `CHANGELOG` entries.
Follow the steps to [install `changie`](https://changie.dev/guide/installation/).

Once changie is installed and the PR is created, run:
Expand All @@ -172,11 +172,11 @@ Even without a CLA, anyone is welcome to open issues and comment on existing iss

### Opening a pull request

A `dbt-adapter` maintainer will be assigned to review each PR based on priority and capacity.
A `dbt-adapters` maintainer will be assigned to review each PR based on priority and capacity.
They may suggest code revisions for style and clarity or they may request additional tests.
These are good things! dbt Labs believes that contributing high-quality code is a collaborative effort.
The same process is followed whether the contributor is external or another `dbt-adapter` maintainer.
The same process is followed whether the contributor is external or another `dbt-adapters` maintainer.
Once all tests are passing and the PR has been approved by the appropriate code owners,
a `dbt-adapter` maintainer will merge the changes into `main`.
a `dbt-adapters` maintainer will merge the changes into `main`.

And that's it! Happy developing :tada:
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.8.0b1"
version = "1.8.0rc1"
45 changes: 45 additions & 0 deletions dbt-tests-adapter/dbt/tests/adapter/utils/fixture_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# date

models__test_date_sql = """
with generated_dates as (
{{
dbt.date_spine(
"day",
date(2023, 9, 7),
date(2023, 9, 10),
)
}}
),
expected_dates as (
select cast('2023-09-07' as date) as expected
union all
select cast('2023-09-08' as date) as expected
union all
select cast('2023-09-09' as date) as expected
),
joined as (
select
generated_dates.date_day,
expected_dates.expected
from generated_dates
full outer join expected_dates on generated_dates.date_day = expected_dates.expected
)
select * from joined
"""

models__test_date_yml = """
version: 2
models:
- name: test_date
data_tests:
- assert_equal:
actual: date_day
expected: expected
"""
18 changes: 18 additions & 0 deletions dbt-tests-adapter/dbt/tests/adapter/utils/test_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest

from dbt.tests.adapter.utils import base_utils, fixture_date


class BaseDate(base_utils.BaseUtils):
@pytest.fixture(scope="class")
def models(self):
return {
"test_date.yml": fixture_date.models__test_date_yml,
"test_date.sql": self.interpolate_macro_namespace(
fixture_date.models__test_date_sql, "date"
),
}


class TestDate(BaseDate):
pass
2 changes: 1 addition & 1 deletion dbt/adapters/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.1.0rc1"
version = "1.1.0"
10 changes: 10 additions & 0 deletions dbt/include/global_project/macros/utils/date.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% macro date(year, month, day) %}
{{ return(adapter.dispatch('date', 'dbt') (year, month, day)) }}
{% endmacro %}


{% macro default__date(year, month, day) -%}
{%- set dt = modules.datetime.date(year, month, day) -%}
{%- set iso_8601_formatted_date = dt.strftime('%Y-%m-%d') -%}
to_date('{{ iso_8601_formatted_date }}', 'YYYY-MM-DD')
{%- endmacro %}

0 comments on commit 9d85431

Please sign in to comment.