Skip to content

Commit

Permalink
test: Test with singer-sdk @ main
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Aug 13, 2024
1 parent a8cb2b9 commit 0588e79
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
22 changes: 13 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sqlalchemy = "~=2.0"
sshtunnel = "0.4.0"

[tool.poetry.dependencies.singer-sdk]
version = "~=0.39.0"
git = "https://github.com/meltano/sdk.git"

[tool.poetry.group.dev.dependencies]
pytest = ">=7.4.2"
Expand Down
11 changes: 7 additions & 4 deletions target_postgres/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
)
from sshtunnel import SSHTunnelForwarder

if t.TYPE_CHECKING:
from singer_sdk.connectors.sql import FullyQualifiedName


class PostgresConnector(SQLConnector):
"""Sets up SQL Alchemy, and other Postgres related stuff."""
Expand Down Expand Up @@ -94,7 +97,7 @@ def interpret_content_encoding(self) -> bool:

def prepare_table( # type: ignore[override]
self,
full_table_name: str,
full_table_name: str | FullyQualifiedName,
schema: dict,
primary_keys: t.Sequence[str],
connection: sa.engine.Connection,
Expand Down Expand Up @@ -156,7 +159,7 @@ def prepare_table( # type: ignore[override]

def copy_table_structure(
self,
full_table_name: str,
full_table_name: str | FullyQualifiedName,
from_table: sa.Table,
connection: sa.engine.Connection,
as_temp_table: bool = False,
Expand Down Expand Up @@ -426,7 +429,7 @@ def create_empty_table( # type: ignore[override]

def prepare_column(
self,
full_table_name: str,
full_table_name: str | FullyQualifiedName,
column_name: str,
sql_type: sa.types.TypeEngine,
connection: sa.engine.Connection | None = None,
Expand Down Expand Up @@ -846,7 +849,7 @@ def get_table_columns( # type: ignore[override]

def column_exists( # type: ignore[override]
self,
full_table_name: str,
full_table_name: str | FullyQualifiedName,
column_name: str,
connection: sa.engine.Connection,
) -> bool:
Expand Down
19 changes: 17 additions & 2 deletions target_postgres/sinks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
"""Postgres target sink class, which handles writing streams."""

from __future__ import annotations

import datetime
import uuid
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union, cast
from typing import (
TYPE_CHECKING,
Any,
Dict,
Iterable,
List,
Optional,
Sequence,
Union,
cast,
)

import sqlalchemy as sa
from singer_sdk.sinks import SQLSink
Expand All @@ -11,6 +23,9 @@

from target_postgres.connector import PostgresConnector

if TYPE_CHECKING:
from singer_sdk.connectors.sql import FullyQualifiedName


class PostgresSink(SQLSink):
"""Postgres target sink class."""
Expand Down Expand Up @@ -261,7 +276,7 @@ def column_representation(

def generate_insert_statement(
self,
full_table_name: str,
full_table_name: str | FullyQualifiedName,
columns: List[sa.Column], # type: ignore[override]
) -> Union[str, Executable]:
"""Generate an insert statement for the given records.
Expand Down
4 changes: 1 addition & 3 deletions target_postgres/tests/test_target_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

# flake8: noqa
import copy
import datetime
import io
from contextlib import redirect_stdout
from decimal import Decimal
from pathlib import Path

import jsonschema
import pytest
import sqlalchemy
from singer_sdk.exceptions import InvalidRecord, MissingKeyPropertiesError
from singer_sdk.testing import get_target_test_class, sync_end_to_end
from singer_sdk.testing import sync_end_to_end
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.types import TEXT, TIMESTAMP

Expand Down

0 comments on commit 0588e79

Please sign in to comment.