Skip to content

Commit 7773276

Browse files
committed
ran linting + updated docstring in ddl function
1 parent 8f8da0b commit 7773276

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

clickhouse_connect/driver/ddl.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def create_table(table_name: str, columns: Sequence[TableColumnDef], engine: str
2929
return stmt
3030

3131

32-
def _arrow_type_to_ch(arrow_type: "pa.DataType") -> str:
32+
def _arrow_type_to_ch(arrow_type: "pa.DataType") -> str: # pylint: disable=too-many-return-statements
3333
"""
3434
Best-effort mapping from common PyArrow types to ClickHouse type names.
3535
@@ -99,9 +99,10 @@ def arrow_schema_to_column_defs(schema: "pa.Schema") -> list[TableColumnDef]:
9999
non-nullable ClickHouse types, even though Arrow fields are nullable by
100100
default.
101101
102-
If the user later inserts an Arrow table that contains nulls, ClickHouse
103-
will raise an error for that insert, and the user can adjust the DDL
104-
(e.g. wrap specific types in Nullable(...)) to match their data.
102+
Note that if the user inserts a table with nulls into a non-Nullable column,
103+
ClickHouse will silently convert those nulls to default values due to the default
104+
server setting input_format_null_as_default=1 and current lack of client-side
105+
validation on arrow inserts.
105106
"""
106107
pa = check_arrow()
107108

tests/integration_tests/test_pyarrow_ddl_integration.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import pytest
2-
3-
from clickhouse_connect.driver import Client
4-
5-
pytest.importorskip("pyarrow")
6-
72
import pyarrow as pa
83

4+
from clickhouse_connect.driver import Client
95
from clickhouse_connect.driver.ddl import (
106
arrow_schema_to_column_defs,
117
create_table,
128
create_table_from_arrow_schema,
139
)
1410

11+
pytest.importorskip("pyarrow")
12+
1513

1614
def test_arrow_create_table_and_insert(test_client: Client):
1715
if not test_client.min_version("20"):
@@ -20,9 +18,9 @@ def test_arrow_create_table_and_insert(test_client: Client):
2018
)
2119

2220
table_name = "test_arrow_basic_integration"
23-
21+
2422
test_client.command(f"DROP TABLE IF EXISTS {table_name}")
25-
23+
2624
schema = pa.schema(
2725
[
2826
("id", pa.int64()),

tests/unit_tests/test_pyarrow_ddl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import pytest
2-
3-
pytest.importorskip("pyarrow")
4-
52
import pyarrow as pa
63

74
from clickhouse_connect.driver.ddl import (
@@ -10,6 +7,8 @@
107
create_table_from_arrow_schema,
118
)
129

10+
pytest.importorskip("pyarrow")
11+
1312

1413
def test_arrow_schema_to_column_defs_basic_mappings():
1514
schema = pa.schema(

0 commit comments

Comments
 (0)