Skip to content

Commit

Permalink
updated to 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed Feb 3, 2025
1 parent 4847ee2 commit b00652a
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 29 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
3.11
3.12
- name: Install python dependencies
run: |
Expand All @@ -70,7 +70,7 @@ jobs:
- name: Run Tests
run: |
tox -e py38,py39,py310,py311
tox -e py39,py310,py311,py312
- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure
Expand All @@ -80,17 +80,17 @@ jobs:
fail-fast: false
matrix:
image:
- containers.intersystems.com/intersystems/iris-community:latest-em
- containers.intersystems.com/intersystems/iris-community:latest-cd
- containers.intersystems.com/intersystems/iris-community:latest-preview
python:
- name: py38
version: "3.8"
- name: py39
version: "3.9"
- name: py310
version: "3.10"
- name: py311
version: "3.11"
- name: py312
version: "3.12"
runs-on: ubuntu-latest

steps:
Expand Down
5 changes: 1 addition & 4 deletions .python-version
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
3.8
3.9
3.10
3.11
3.12
4 changes: 3 additions & 1 deletion dbt/adapters/iris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@


Plugin = AdapterPlugin(
adapter=IRISAdapter, credentials=IRISCredentials, include_path=iris.PACKAGE_PATH # type: ignore
adapter=IRISAdapter, # type: ignore
credentials=IRISCredentials,
include_path=iris.PACKAGE_PATH,
)
2 changes: 1 addition & 1 deletion dbt/adapters/iris/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.8.19"
version = "1.9.2"
5 changes: 3 additions & 2 deletions dbt/adapters/iris/connections.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from typing import Optional, Tuple, Any
from typing import Optional, Tuple, Any, Type
from contextlib import contextmanager
from dataclasses import dataclass
from dbt.exceptions import DbtRuntimeError
Expand Down Expand Up @@ -142,7 +142,8 @@ def add_query(
auto_begin: bool = True,
bindings: Optional[Any] = None,
abridge_sql_log: bool = False,
many=False,
retryable_exceptions: Tuple[Type[Exception], ...] = tuple(),
retry_limit: int = 1,
) -> Tuple[Connection, Any]:
connection = self.get_thread_connection()
if auto_begin and connection.transaction_open is False:
Expand Down
6 changes: 2 additions & 4 deletions dbt/adapters/iris/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ def list_relations_without_caching(self, schema_relation: IRISRelation) -> List[
results = self.execute_macro(LIST_RELATIONS_MACRO_NAME, kwargs=kwargs)
except DbtRuntimeError as e:
errmsg = getattr(e, "msg", "")
if f"IRIS schema '{schema_relation}' not found" in errmsg:
return []
else:
if f"IRIS schema '{schema_relation}' not found" not in errmsg:
description = "Error while retrieving information about"
logger.debug(f"{description} {schema_relation}: {e.msg}")
return []
return []

relations = []
_database = schema_relation.database
Expand Down
11 changes: 5 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# install latest changes in dbt-core
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/dbt-common.git
git+https://github.com/dbt-labs/dbt-adapters.git
git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter
dbt-common @ git+https://github.com/dbt-labs/dbt-common.git
dbt-tests-adapter @ git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter
dbt-core @ git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-adapters

black>=24.3
bumpversion~=0.6.0
Expand All @@ -14,8 +14,6 @@ freezegun~=1.3
ipdb~=0.13.13
mypy==1.7.1 # patch updates have historically introduced breaking changes
pip-tools~=7.3
pre-commit~=3.5
pre-commit-hooks~=4.5
pytest~=7.4
pytest-csv~=3.0
pytest-dotenv~=0.5.2
Expand All @@ -30,3 +28,4 @@ twine~=4.0
wheel~=0.42

testcontainers-iris
pre-commit
2 changes: 1 addition & 1 deletion requirements-iris.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/intersystems-community/intersystems-irispython/releases/download/3.7.9/intersystems_iris-3.7.9-py3-none-any.whl
https://github.com/intersystems-community/intersystems-irispython/releases/download/3.8.0/intersystems_iris-3.8.0-py3-none-any.whl
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ def _dbt_iris_version() -> str:
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
python_requires=">3.7,<3.12",
python_requires=">3.7",
)
117 changes: 117 additions & 0 deletions tests/functional/basic/test_adapter_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import pytest

from dbt.tests.util import run_dbt, check_relations_equal
from dbt.tests.fixtures.project import write_project_files


tests__get_columns_in_relation_sql = """
{% set columns = adapter.get_columns_in_relation(ref('model')) %}
{% set limit_query = 0 %}
{% if (columns | length) == 0 %}
{% set limit_query = 1 %}
{% endif %}
select 1 as id limit {{ limit_query }}
"""

models__upstream_sql = """
select 1 as id
"""

models__expected_sql = """
-- make sure this runs after 'model'
-- {{ ref('model') }}
select 2 as id
"""

models__model_sql = """
{% set upstream = ref('upstream') %}
{% if execute %}
{# don't ever do any of this #}
{%- do adapter.drop_schema(upstream) -%}
{% set existing = adapter.get_relation(upstream.database, upstream.schema, upstream.identifier) %}
{% if existing is not none %}
{% do exceptions.raise_compiler_error('expected ' ~ ' to not exist, but it did') %}
{% endif %}
{%- do adapter.create_schema(upstream) -%}
{% set sql = create_view_as(upstream, 'select 2 as id') %}
{% do run_query(sql) %}
{% endif %}
select * from {{ upstream }}
"""


class BaseAdapterMethod:
"""
This test will leverage the following adapter methods:
get_relation
get_columns_in_relation
drop_schema
create_schema
It will aims to make sure drop_shema actually works, for more context
checkout #1983
"""

@pytest.fixture(scope="class")
def tests(self):
return {"get_columns_in_relation.sql": tests__get_columns_in_relation_sql}

@pytest.fixture(scope="class")
def models(self):
return {
"upstream.sql": models__upstream_sql,
"expected.sql": models__expected_sql,
"model.sql": models__model_sql,
}

@pytest.fixture(scope="class")
def project_files(
self,
project_root,
tests,
models,
):
write_project_files(project_root, "tests", tests)
write_project_files(project_root, "models", models)

@pytest.fixture(scope="class")
def project_config_update(self):
return {
"name": "adapter_methods",
}

@pytest.fixture(autouse=True)
def clean_up(self, project):
yield
with project.adapter.connection_named("__test"):
relation = project.adapter.Relation.create(
database=project.database, schema=project.test_schema
)
project.adapter.drop_schema(relation)

pass

# snowflake need all tables in CAP name
@pytest.fixture(scope="class")
def equal_tables(self):
return ["model", "expected"]

def test_adapter_methods(self, project, equal_tables):
run_dbt(["compile"]) # trigger any compile-time issues
result = run_dbt()
assert len(result) == 3
check_relations_equal(project.adapter, equal_tables)


class TestBaseCaching(BaseAdapterMethod):
pass
2 changes: 1 addition & 1 deletion tests/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def generate_name_macros(package):
else:
source = f"target.{component}"
name = f"generate_{component}_name"
sql = f"{{% macro {name}(value, node) %}} {{% if value %}} {{{{ value }}}} {{% else %}} {{{{ {source} }}}} {{% endif %}} {{% endmacro %}}"
sql = f"{{% macro {name}(value, node) %}} {{% if value %}} {{{{value}}}} {{% else %}} {{{{{source}}}}} {{% endif %}} {{% endmacro %}}"
name_sql[name] = sql

all_sql = "\n".join(name_sql.values())
Expand Down
13 changes: 10 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
skipsdist = True
envlist = py3{8,9,10,11}{-iris,}
envlist = py3{9,10,11,12}{-iris,},lint

[testenv:{py37,py38,py39,py310}]
[testenv:{py39,py310,py311,py312}]
description = unit testing
skip_install = True
passenv = DBT_*,PYTEST_ADOPTS
Expand All @@ -12,7 +12,7 @@ deps =
-r requirements-dev.txt
-e.

[testenv:py3{8,9,10,11}-iris]
[testenv:py3{9,10,11,12}-iris]
description = adapter plugin functional testing
skip_install = true
passenv = DBT_*,IRIS_TEST_*,PYTEST_ADOPTS
Expand All @@ -22,3 +22,10 @@ deps =
-r requirements-iris.txt
-r requirements-dev.txt
-e.

[testenv:lint]
commands = pre-commit run --all-files
deps =
-r requirements-iris.txt
-r requirements-dev.txt
-e.

0 comments on commit b00652a

Please sign in to comment.