Skip to content

Commit

Permalink
Finalize wireframing #1055
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Coetzee <[email protected]>
  • Loading branch information
Pipboyguy committed Mar 12, 2024
1 parent 9b3ef87 commit ed218e5
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
32 changes: 32 additions & 0 deletions dlt/destinations/impl/clickhouse/clickhouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from typing import ClassVar, Optional

from dlt.common.destination import DestinationCapabilitiesContext
from dlt.common.destination.reference import SupportsStagingDestination
from dlt.common.schema import Schema, TColumnSchema
from dlt.common.schema.typing import TColumnType, TTableFormat
from dlt.destinations.impl.clickhouse import capabilities
from dlt.destinations.impl.clickhouse.configuration import ClickhouseClientConfiguration
from dlt.destinations.job_client_impl import SqlJobClientWithStaging
from dlt.destinations.sql_client import SqlClientBase
from dlt.destinations.typing import TNativeConn


class ClickhouseClient(SqlJobClientWithStaging, SupportsStagingDestination):
capabilities: ClassVar[DestinationCapabilitiesContext] = capabilities()

def __init__(
self,
schema: Schema,
config: ClickhouseClientConfiguration,
sql_client: SqlClientBase[TNativeConn],
) -> None:
super().__init__(schema, config, sql_client)
...

def _get_column_def_sql(self, c: TColumnSchema, table_format: TTableFormat = None) -> str:
pass

def _from_db_type(
self, db_type: str, precision: Optional[int], scale: Optional[int]
) -> TColumnType:
pass
44 changes: 44 additions & 0 deletions dlt/destinations/impl/clickhouse/factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import typing as t

from dlt.common.destination import Destination, DestinationCapabilitiesContext
from dlt.destinations.impl.clickhouse import capabilities
from dlt.destinations.impl.clickhouse.configuration import (
ClickhouseClientConfiguration,
ClickhouseCredentials,
)


if t.TYPE_CHECKING:
from dlt.destinations.impl.clickhouse.clickhouse import ClickhouseClient


# noinspection PyPep8Naming
class clickhouse(Destination[ClickhouseClientConfiguration, ClickhouseClient]):
spec = ClickhouseClientConfiguration

def capabilities(self) -> DestinationCapabilitiesContext:
return capabilities()

@property
def client_class(self) -> t.Type["ClickhouseClient"]:
from dlt.destinations.impl.clickhouse.clickhouse import ClickhouseClient

return ClickhouseClient

def __init__(
self,
credentials: ClickhouseCredentials = None,
dataset_name: str = None,
default_schema_name: str = None,
destination_name: str = None,
environment: str = None,
**kwargs: t.Any,
) -> None:
super().__init__(
credentials=credentials,
dataset_name=dataset_name,
default_schema_name=default_schema_name,
destination_name=destination_name,
environment=environment,
**kwargs,
)

0 comments on commit ed218e5

Please sign in to comment.