Skip to content

Commit 1c4cf8b

Browse files
committed
address PR review
1 parent 4f0d9ce commit 1c4cf8b

File tree

1 file changed

+12
-2
lines changed
  • clickhouse_connect/driver

1 file changed

+12
-2
lines changed

clickhouse_connect/driver/ddl.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def _arrow_type_to_ch(arrow_type: "pa.DataType") -> str:
4040
Covers core scalar types. For anything unknown, we raise so the
4141
caller is aware that the automatic mapping is not implemented for that Arrow type.
4242
"""
43+
if pa is None:
44+
raise ImportError(
45+
"PyArrow is required, but it is not installed."
46+
)
47+
4348
pat = pa.types
4449

4550
# Signed ints
@@ -65,7 +70,7 @@ def _arrow_type_to_ch(arrow_type: "pa.DataType") -> str:
6570
# Floats
6671
if pat.is_float16(arrow_type) or pat.is_float32(arrow_type):
6772
return 'Float32'
68-
if pat.is_floating(arrow_type):
73+
if pat.is_float64(arrow_type):
6974
return 'Float64'
7075

7176
# Boolean
@@ -86,7 +91,7 @@ class _DDLType:
8691
Minimal helper used to satisfy TableColumnDef.ch_type.
8792
8893
create_table() only needs ch_type.name when building the DDL string,
89-
so gonna wrap the ClickHouse type name in this tiny object instead of
94+
so we'll wrap the ClickHouse type name in this tiny object instead of
9095
constructing full ClickHouseType instances here.
9196
"""
9297
def __init__(self, name: str):
@@ -97,6 +102,11 @@ def arrow_schema_to_column_defs(schema: "pa.Schema") -> list[TableColumnDef]:
97102
"""
98103
Convert a PyArrow Schema into a list of TableColumnDef objects.
99104
"""
105+
if pa is None:
106+
raise ImportError(
107+
"PyArrow is required, but it is not installed."
108+
)
109+
100110
if not isinstance(schema, pa.Schema):
101111
raise TypeError(f'Expected pyarrow.Schema, got {type(schema)!r}')
102112

0 commit comments

Comments
 (0)