Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up some TODOs #75

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/dl_connector_chyt/dl_connector_chyt/core/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ def spec(self) -> CHYTTableDataSourceSpec:

@property
def default_title(self) -> str:
return self.spec.table_name.split("/")[-1] # type: ignore # TODO: fix
assert self.spec.table_name is not None
return self.spec.table_name.split("/")[-1]

@require_table_name
def get_sql_source(self, alias: Optional[str] = None) -> Any:
if alias:
return sa.alias(self.get_sql_source(), name=alias)
path = self.spec.table_name
path = self.normalize_path(path) # type: ignore # TODO: fix
assert path is not None
path = self.normalize_path(path)
return sa.table(path)

@require_table_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def is_compatible_with_type(cls, source_type: DataSourceType) -> bool:
}


class ClickHouseSubselectDataSource(ActualClickHouseBaseMixin, CommonClickHouseSubselectDataSource): # type: ignore # TODO: fix
class ClickHouseSubselectDataSource(ActualClickHouseBaseMixin, CommonClickHouseSubselectDataSource):
"""Clickhouse subselect"""

conn_type = CONNECTION_TYPE_CLICKHOUSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from dl_core import exc
from dl_core.connection_executors.models.scoped_rci import DBAdapterScopedRCI
from dl_core.connectors.base.error_transformer import DBExcKWArgs
from dl_core.db import (
SchemaColumn,
make_sa_type,
Expand Down Expand Up @@ -187,11 +188,12 @@ def create_column_sql(
) -> str:
native_type = tt.type_user_to_native(user_t=col.user_type, native_t=col.native_type)

nullable: Optional[bool]
if partition_fields and col.name in partition_fields:
# Partition column cannot be nullable. Enforcing it in here.
nullable = False
else:
nullable = None # type: ignore # TODO: fix
nullable = None

if nullable is not None:
native_type = native_type.as_common().clone(nullable=nullable)
Expand All @@ -204,7 +206,10 @@ def create_column_sql(
return sa_ddl_obj.string


def ensure_db_message(exc_cls, kw): # type: ignore # TODO: fix
def ensure_db_message(
exc_cls: Type[exc.DatabaseQueryError],
kw: DBExcKWArgs,
) -> tuple[Type[exc.DatabaseQueryError], DBExcKWArgs]:
db_message = kw.get("db_message")
details = kw.get("details")
if db_message and details is not None and not details.get("db_message"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ClickHouseBaseMixin(BaseSQLDataSource):
compiler_cls = ClickHouseQueryCompiler

def get_connect_args(self) -> dict:
return dict(super().get_connect_args(), server_version=self.db_version or self.default_server_version) # type: ignore # TODO: fix # noqa
return dict(super().get_connect_args(), server_version=self.db_version or self.default_server_version)


class ActualClickHouseBaseMixin(ClickHouseBaseMixin):
Expand All @@ -59,5 +59,5 @@ class ActualClickHouseBaseMixin(ClickHouseBaseMixin):
conn_type = CONNECTION_TYPE_CLICKHOUSE


class ClickHouseDataSourceBase(ActualClickHouseBaseMixin, StandardSQLDataSource, metaclass=abc.ABCMeta): # type: ignore # TODO: fix
class ClickHouseDataSourceBase(ActualClickHouseBaseMixin, StandardSQLDataSource, metaclass=abc.ABCMeta):
"""ClickHouse table. Might not work correctly for views."""
Loading