Skip to content

Commit

Permalink
Rename ClickhouseAPI -> ClickhouseServerAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
ADBond committed Dec 16, 2024
1 parent b90861e commit 446b1ba
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ Nevertheless if you depend on this package it is recommended to pin a version to

### Clickhouse server

Import `ClickhouseAPI`, which accepts a `clickhouse_connect` client, configured with attributes relevant for your connection:
Import `ClickhouseServerAPI`, which accepts a `clickhouse_connect` client, configured with attributes relevant for your connection:
```python
import clickhouse_connect
import splink.comparison_library as cl
from splink import Linker, SettingsCreator, block_on, splink_datasets

from splinkclickhouse import ClickhouseAPI
from splinkclickhouse import ClickhouseServerAPI

df = splink_datasets.fake_1000

Expand All @@ -68,7 +68,7 @@ client = clickhouse_connect.get_client(
database=db_name,
)

db_api = ClickhouseAPI(client)
db_api = ClickhouseServerAPI(client)

# can have at most one tf-adjusted comparison, see caveats below
settings = SettingsCreator(
Expand Down Expand Up @@ -238,8 +238,8 @@ import splink.comparison_level as cl
first_name_comparison = cl.DamerauLevenshteinAtThresholds("NULLIF(first_name, '')")
```

### `ClickhouseAPI` pandas registration
### `ClickhouseServerAPI` pandas registration

`ClickhouseAPI` will allow registration of pandas dataframes, by inferring the types of columns. It currently only does this for string, integer, and float columns, and will always make them `Nullable`.
`ClickhouseServerAPI` will allow registration of pandas dataframes, by inferring the types of columns. It currently only does this for string, integer, and float columns, and will always make them `Nullable`.

If you require other data types, or more fine-grained control, it is recommended to import the data into Clickhouse yourself, and then pass the table name (as a string) to the `Linker` instead.
4 changes: 2 additions & 2 deletions benchmarking/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)
from utils.timer import MultiTimer, Timer

from splinkclickhouse import ChDBAPI, ClickhouseAPI
from splinkclickhouse import ChDBAPI, ClickhouseServerAPI

# settings for something fake_1000-shaped
config_fake_1000 = {
Expand Down Expand Up @@ -101,7 +101,7 @@ def timed_full_run(data: str, config: dict, backend_to_use: str) -> Timer:
username="splinkognito",
password="splink123!",
)
db_api = ClickhouseAPI(client)
db_api = ClickhouseServerAPI(client)
elif backend_to_use == "duckdb":
db_api = DuckDBAPI()
else:
Expand Down
2 changes: 1 addition & 1 deletion dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ uv run python scripts/getting_started_chdb.py
Import the relevant api:

```python
from splinkclickhouse import ClickhouseAPI
from splinkclickhouse import ClickhouseServerAPI
```

You can run a local instance in docker with provided docker-compose file:
Expand Down
4 changes: 2 additions & 2 deletions scripts/getting_started_clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import splink.comparison_library as cl
from splink import Linker, SettingsCreator, block_on, splink_datasets

from splinkclickhouse import ClickhouseAPI
from splinkclickhouse import ClickhouseServerAPI

df = splink_datasets.fake_1000

Expand All @@ -22,7 +22,7 @@
database=db_name,
)

db_api = ClickhouseAPI(client)
db_api = ClickhouseServerAPI(client)

settings = SettingsCreator(
link_type="dedupe_only",
Expand Down
4 changes: 2 additions & 2 deletions splinkclickhouse/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from .clickhouse.database_api import ClickhouseAPI
from .clickhouse.database_api import ClickhouseServerAPI

__version__ = "0.3.4"

Expand All @@ -22,4 +22,4 @@ def __getattr__(name: str) -> Any:
raise ImportError(f"cannot import name '{name}' from splinkclickhouse") from None


__all__ = ["ChDBAPI", "ClickhouseAPI"]
__all__ = ["ChDBAPI", "ClickhouseServerAPI"]
4 changes: 2 additions & 2 deletions splinkclickhouse/clickhouse/database_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
logger = logging.getLogger(__name__)


class ClickhouseAPI(DatabaseAPI[None]):
class ClickhouseServerAPI(DatabaseAPI[None]):
sql_dialect = ClickhouseDialect()

def __init__(
Expand Down Expand Up @@ -41,7 +41,7 @@ def _table_registration(self, input, table_name) -> None:
self.client.query(sql)
else:
raise TypeError(
"ClickhouseAPI currently only accepts table names (str) "
"ClickhouseServerAPI currently only accepts table names (str) "
"or pandas DataFrames as inputs for table registration. "
f"Received type {type(input)}"
)
Expand Down
4 changes: 2 additions & 2 deletions splinkclickhouse/clickhouse/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

logger = logging.getLogger(__name__)
if TYPE_CHECKING:
from .database_api import ClickhouseAPI
from .database_api import ClickhouseServerAPI


class ClickhouseDataFrame(SplinkDataFrame):
db_api: ClickhouseAPI
db_api: ClickhouseServerAPI

def __init__(self, df_name, physical_name, db_api):
super().__init__(df_name, physical_name, db_api)
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pytest import fixture, mark, param
from splink import ColumnExpression, SettingsCreator, block_on, splink_datasets

from splinkclickhouse import ChDBAPI, ClickhouseAPI
from splinkclickhouse import ChDBAPI, ClickhouseServerAPI

df = splink_datasets.fake_1000

Expand Down Expand Up @@ -73,7 +73,7 @@ def clickhouse_api_factory():
database=db_name,
)

yield lambda: ClickhouseAPI(client)
yield lambda: ClickhouseServerAPI(client)
client.close()
default_client.command(f"DROP DATABASE {db_name}")
default_client.close()
Expand Down

0 comments on commit 446b1ba

Please sign in to comment.