Files
Joe SpadolaandGitHub 62d1020777 implement lazy loading of heavy optional deps (#689)
* implement lazy loading of np, pd, pl, arrow

* linting
2026-03-25 16:50:13 -07:00

10 lines
332 B
Python

from clickhouse_connect.driver import options
from clickhouse_connect.driver.types import ByteSource
def read_numpy_array(source: ByteSource, np_type: str, num_rows: int):
np = options.np
dtype = np.dtype(np_type)
buffer = source.read_bytes(dtype.itemsize * num_rows)
return np.frombuffer(buffer, dtype, num_rows)