Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into dbeatty/unknown-data-type-code-8912
Browse files Browse the repository at this point in the history
# Conflicts:
#	hatch_build.py
#	pyproject.toml
  • Loading branch information
mikealfare committed Apr 19, 2024
2 parents 8d3e7cd + 333a1e5 commit 14cf61e
Show file tree
Hide file tree
Showing 40 changed files with 182 additions and 4,419 deletions.
9 changes: 9 additions & 0 deletions .changes/1.0.8-b3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## dbt-postgres 1.0.8-b3 - April 16, 2024

### Fixes

* Determine `psycopg2` based on `platform_system` (Linux or other), remove usage of `DBT_PSYCOPG2_NAME` environment variable

### Under the Hood

* Update dependabot configuration to cover GHA
6 changes: 0 additions & 6 deletions .changes/unreleased/Under the Hood-20240410-180644.yaml

This file was deleted.

28 changes: 9 additions & 19 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ on:
workflow_dispatch:
inputs:
dbt_adapters_branch:
description: "The branch of dbt-adapters to evaluate"
type: string
required: true
default: "main"
description: "The branch of dbt-adapters to evaluate"
type: string
default: "main"
workflow_call:
inputs:
dbt_adapters_branch:
description: "The branch of dbt-adapters to evaluate"
type: string
required: true
default: "main"

permissions: read-all
Expand All @@ -27,34 +25,26 @@ permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}
cancel-in-progress: true
env:
# set DBT_ADAPTERS_BRANCH to the input value if the event is a workflow_dispatch (workflow_call uses the same event_name),
# otherwise use 'main'
DBT_ADAPTERS_BRANCH: ${{ github.event_name == 'workflow_dispatch' && inputs.dbt_adapters_branch || 'main' }}

jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest


steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Update Adapters and Core branches
if: ${{ contains(github.event_name, 'workflow_') }}
shell: bash
run: |
./.github/scripts/update_dev_packages.sh \
$DBT_ADAPTERS_BRANCH \
"main"
run: ./.github/scripts/update_dev_packages.sh ${{ inputs.dbt_adapters_branch }} "main"

- name: Setup `hatch`
uses: dbt-labs/dbt-adapters/.github/actions/setup-hatch@main

- name: Run linters
run: hatch run lint:all

- name: Run typechecks
run: hatch run typecheck:all
- name: Run code quality
shell: bash
run: hatch run code-quality
37 changes: 27 additions & 10 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ on:
required: false
default: "main"


permissions: read-all

# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
integration:
name: Integration Tests
Expand Down Expand Up @@ -68,14 +71,12 @@ jobs:

- name: Update Adapters and Core branches
if: ${{ github.event_name == 'workflow_call' || github.event_name == 'workflow_dispatch'}}
shell: bash
run: |
./.github/scripts/update_dev_packages.sh \
${{ inputs.dbt_adapters_branch }} \
${{ inputs.core_branch }}
- name: Setup postgres
shell: bash
run: psql -f ./scripts/setup_test_database.sql
env:
PGHOST: localhost
Expand All @@ -99,10 +100,26 @@ jobs:
POSTGRES_TEST_DATABASE: dbt
POSTGRES_TEST_THREADS: 4

- name: Publish results
uses: dbt-labs/dbt-adapters/.github/actions/publish-results@main
if: always()
with:
source-file: "results.csv"
file-name: "integration_results"
python-version: ${{ matrix.python-version }}
psycopg2-check:
name: "Test psycopg2 build version"
runs-on: ${{ matrix.scenario.platform }}
strategy:
fail-fast: false
matrix:
scenario:
- {platform: ubuntu-latest, psycopg2-name: psycopg2}
- {platform: macos-latest, psycopg2-name: psycopg2-binary}
steps:
- name: "Check out repository"
uses: actions/checkout@v4

- name: "Test psycopg2 name"
run: |
python -m pip install .
PSYCOPG2_PIP_ENTRY=$(pip list | grep "psycopg2 " || pip list | grep psycopg2-binary)
echo $PSYCOPG2_PIP_ENTRY
PSYCOPG2_NAME="${PSYCOPG2_PIP_ENTRY%% *}"
echo $PSYCOPG2_NAME
if [[ "${PSYCOPG2_NAME}" != "${{ matrix.scenario.psycopg2-name }}" ]]; then
exit 1
fi
8 changes: 0 additions & 8 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,3 @@ jobs:
- name: Run unit tests
run: hatch run unit-tests:all
shell: bash

- name: Publish results
uses: dbt-labs/dbt-adapters/.github/actions/publish-results@main
if: always()
with:
source-file: "results.csv"
file-name: "unit_results"
python-version: ${{ matrix.python-version }}
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
default_language_version:
python: python3

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
args: [--unsafe]
- id: check-json
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict

- repo: https://github.com/dbt-labs/pre-commit-hooks
rev: v0.1.0a1
hooks:
- id: dbt-core-in-adapters-check

- repo: https://github.com/psf/black
rev: 24.4.0
hooks:
- id: black
args:
- --line-length=99
- --target-version=py38
- --target-version=py39
- --target-version=py310
- --target-version=py311

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
exclude: tests/
args:
- --max-line-length=99
- --select=E,F,W
- --ignore=E203,E501,E741,W503,W504
- --per-file-ignores=*/__init__.py:F401

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
args:
- --explicit-package-bases
- --ignore-missing-imports
- --pretty
- --show-error-codes
files: ^dbt/adapters/postgres
additional_dependencies:
- types-PyYAML
- types-protobuf
- types-pytz
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
### Security

* Pin `black>=24.3` in `pyproject.toml`

## dbt-postgres 1.0.8-b3 - April 16, 2024

### Fixes

* Determine `psycopg2` based on `platform_system` (Linux or other), remove usage of `DBT_PSYCOPG2_NAME` environment variable

### Under the Hood

* Update dependabot configuration to cover GHA
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Remember to commit and push the file that's created.

### Signing the CLA

> **_NOTE:_** All contributors to `dbt-postgres` must sign the
> **_NOTE:_** All contributors to `dbt-postgres` 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.
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/postgres/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.8.0b2"
version = "1.8.0b4"
30 changes: 17 additions & 13 deletions dbt/adapters/postgres/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@

@dataclass(frozen=True, eq=False, repr=False)
class PostgresRelation(BaseRelation):
renameable_relations: FrozenSet[RelationType] = field(default_factory=lambda: frozenset(
{
RelationType.View,
RelationType.Table,
RelationType.MaterializedView,
}
))
replaceable_relations: FrozenSet[RelationType] = field(default_factory=lambda: frozenset(
{
RelationType.View,
RelationType.Table,
}
))
renameable_relations: FrozenSet[RelationType] = field(
default_factory=lambda: frozenset(
{
RelationType.View,
RelationType.Table,
RelationType.MaterializedView,
}
)
)
replaceable_relations: FrozenSet[RelationType] = field(
default_factory=lambda: frozenset(
{
RelationType.View,
RelationType.Table,
}
)
)

def __post_init__(self):
# Check for length of Postgres table/view names.
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/postgres/relation_configs/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PostgresIndexMethod(StrEnum):

@classmethod
def default(cls) -> "PostgresIndexMethod":
return cls.btree
return cls("btree")


@dataclass(frozen=True, eq=True, unsafe_hash=True)
Expand Down
56 changes: 0 additions & 56 deletions hatch_build.py

This file was deleted.

Loading

0 comments on commit 14cf61e

Please sign in to comment.