|
35 | 35 | from pathlib import Path |
36 | 36 | from random import choice, randint |
37 | 37 | from tempfile import TemporaryDirectory |
38 | | -from typing import ( |
39 | | - TYPE_CHECKING, |
40 | | - Any, |
41 | | - Dict, |
42 | | - Generator, |
43 | | - List, |
44 | | - Optional, |
45 | | -) |
| 38 | +from typing import TYPE_CHECKING, Any, Dict, Generator, List, Optional |
46 | 39 |
|
47 | 40 | import boto3 |
48 | 41 | import pytest |
49 | 42 | from moto import mock_aws |
| 43 | +from sqlalchemy import Connection |
50 | 44 |
|
51 | 45 | from pyiceberg.catalog import Catalog, load_catalog |
52 | 46 | from pyiceberg.catalog.noop import NoopCatalog |
@@ -141,6 +135,18 @@ def pytest_addoption(parser: pytest.Parser) -> None: |
141 | 135 | "--gcs.oauth2.token", action="store", default="anon", help="The GCS authentication method for tests marked gcs" |
142 | 136 | ) |
143 | 137 | parser.addoption("--gcs.project-id", action="store", default="test", help="The GCP project for tests marked gcs") |
| 138 | + parser.addoption( |
| 139 | + "--trino.rest.endpoint", |
| 140 | + action="store", |
| 141 | + default="trino://test@localhost:8082/warehouse_rest", |
| 142 | + help="The Trino REST endpoint URL for tests marked as integration_trino", |
| 143 | + ) |
| 144 | + parser.addoption( |
| 145 | + "--trino.hive.endpoint", |
| 146 | + action="store", |
| 147 | + default="trino://test@localhost:8082/warehouse_hive", |
| 148 | + help="The Trino Hive endpoint URL for tests marked as integration_trino", |
| 149 | + ) |
144 | 150 |
|
145 | 151 |
|
146 | 152 | @pytest.fixture(scope="session") |
@@ -2436,6 +2442,28 @@ def bound_reference_uuid() -> BoundReference[str]: |
2436 | 2442 | return BoundReference(field=NestedField(1, "field", UUIDType(), required=False), accessor=Accessor(position=0, inner=None)) |
2437 | 2443 |
|
2438 | 2444 |
|
| 2445 | +@pytest.fixture(scope="session") |
| 2446 | +def trino_hive_conn(request: pytest.FixtureRequest) -> Generator[Connection, None, None]: |
| 2447 | + from sqlalchemy import create_engine |
| 2448 | + |
| 2449 | + trino_endpoint = request.config.getoption("--trino.hive.endpoint") |
| 2450 | + engine = create_engine(trino_endpoint) |
| 2451 | + connection = engine.connect() |
| 2452 | + yield connection |
| 2453 | + connection.close() |
| 2454 | + |
| 2455 | + |
| 2456 | +@pytest.fixture(scope="session") |
| 2457 | +def trino_rest_conn(request: pytest.FixtureRequest) -> Generator[Connection, None, None]: |
| 2458 | + from sqlalchemy import create_engine |
| 2459 | + |
| 2460 | + trino_endpoint = request.config.getoption("--trino.rest.endpoint") |
| 2461 | + engine = create_engine(trino_endpoint) |
| 2462 | + connection = engine.connect() |
| 2463 | + yield connection |
| 2464 | + connection.close() |
| 2465 | + |
| 2466 | + |
2439 | 2467 | @pytest.fixture(scope="session") |
2440 | 2468 | def session_catalog() -> Catalog: |
2441 | 2469 | return load_catalog( |
|
0 commit comments