Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Aug 13, 2024
1 parent dbcd5e8 commit e0ed470
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
33 changes: 7 additions & 26 deletions singer_sdk/connectors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FullyQualifiedName(UserString):
def __init__(
self,
*,
table: str | None = None,
table: str = "",
schema: str | None = None,
database: str | None = None,
delimiter: str = ".",
Expand Down Expand Up @@ -341,7 +341,7 @@ def get_fully_qualified_name(
The fully qualified name as a string.
"""
return FullyQualifiedName(
table=table_name,
table=table_name, # type: ignore[arg-type]
schema=schema_name,
database=db_name,
delimiter=delimiter,
Expand Down Expand Up @@ -473,25 +473,6 @@ def get_object_names(
view_names = []
return [(t, False) for t in table_names] + [(v, True) for v in view_names]

def _get_stream_name( # noqa: PLR6301
self,
table_name: str,
*,
schema_name: str | None = None,
) -> str:
"""Return a unique stream name.
Args:
schema_name: Schema name
table_name: Table or view name
Returns:
A unique stream name
"""
if schema_name:
return f"{schema_name}-{table_name}"
return table_name

# TODO maybe should be splitted into smaller parts?
def discover_catalog_entry(
self,
Expand All @@ -514,7 +495,7 @@ def discover_catalog_entry(
`CatalogEntry` object for the given table or a view
"""
# Initialize unique stream name
unique_stream_id = self._get_stream_name(table_name, schema_name=schema_name)
unique_stream_id = f"{schema_name}-{table_name}"

# Detect key properties
possible_primary_keys: list[list[str]] = []
Expand Down Expand Up @@ -647,7 +628,7 @@ def parse_full_table_name( # noqa: PLR6301

return db_name, schema_name, table_name

def table_exists(self, full_table_name: str) -> bool:
def table_exists(self, full_table_name: str | FullyQualifiedName) -> bool:
"""Determine if the target table already exists.
Args:
Expand Down Expand Up @@ -1067,7 +1048,7 @@ def _get_column_type(

def get_column_add_ddl(
self,
table_name: str,
table_name: str | FullyQualifiedName,
column_name: str,
column_type: sa.types.TypeEngine,
) -> sa.DDL:
Expand Down Expand Up @@ -1100,7 +1081,7 @@ def get_column_add_ddl(

@staticmethod
def get_column_rename_ddl(
table_name: str,
table_name: str | FullyQualifiedName,
column_name: str,
new_column_name: str,
) -> sa.DDL:
Expand Down Expand Up @@ -1128,7 +1109,7 @@ def get_column_rename_ddl(

@staticmethod
def get_column_alter_ddl(
table_name: str,
table_name: str | FullyQualifiedName,
column_name: str,
column_type: sa.types.TypeEngine,
) -> sa.DDL:
Expand Down
3 changes: 2 additions & 1 deletion singer_sdk/streams/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from singer_sdk.streams.core import REPLICATION_INCREMENTAL, Stream

if t.TYPE_CHECKING:
from singer_sdk.connectors.sql import FullyQualifiedName
from singer_sdk.helpers.types import Context
from singer_sdk.tap_base import Tap

Expand Down Expand Up @@ -124,7 +125,7 @@ def primary_keys(self, new_value: t.Sequence[str]) -> None:
self._singer_catalog_entry.metadata.root.table_key_properties = new_value

@property
def fully_qualified_name(self) -> str:
def fully_qualified_name(self) -> FullyQualifiedName:
"""Generate the fully qualified version of the table name.
Raises:
Expand Down

0 comments on commit e0ed470

Please sign in to comment.