Files
zeekay 999d38466d rename: this fork is ours — datastore_connect
Imports read `datastore_connect`, distribution `datastore-connect`, so nothing has to
import another product's name to talk to Hanzo Datastore.

Cut from upstream 0.8.17 — the version this stack already ran — rather than from
upstream HEAD, so it is a PURE RENAME with no behaviour change. Forking from
HEAD would have dragged versions along with the name (connect alone jumped
0.8.17 -> 1.6.0, a major), which is a different and much riskier change wearing
a rename's clothes.

X-ClickHouse-* headers are untouched: they are wire protocol the server sends
and expects, and a different token shape from the module name.
2026-07-26 11:01:30 -07:00

41 lines
2.0 KiB
Python

from pathlib import Path
from typing import Callable
from datastore_connect.driver import Client
from datastore_connect.driver.tools import insert_file
from tests.integration_tests.conftest import TestConfig
def test_csv_upload(test_client: Client, table_context: Callable):
data_file = f'{Path(__file__).parent}/movies.csv.gz'
with table_context('test_csv_upload', ['movie String', 'year UInt16', 'rating Decimal32(3)']):
insert_file(test_client, 'test_csv_upload', data_file,
settings={'input_format_allow_errors_ratio': .2,
'input_format_allow_errors_num': 5})
res = test_client.query(
'SELECT count() as count, sum(rating) as rating, max(year) as year FROM test_csv_upload').first_item
assert res['count'] == 248
assert res['year'] == 2022
def test_parquet_upload(test_config: TestConfig, test_client: Client, table_context: Callable):
data_file = f'{Path(__file__).parent}/movies.parquet'
full_table = f'{test_config.test_database}.test_parquet_upload'
with table_context(full_table, ['movie String', 'year UInt16', 'rating Float64']):
insert_file(test_client, full_table, data_file, 'Parquet',
settings={'output_format_parquet_string_as_string': 1})
res = test_client.query(
f'SELECT count() as count, sum(rating) as rating, max(year) as year FROM {full_table}').first_item
assert res['count'] == 250
assert res['year'] == 2022
def test_json_insert(test_client: Client, table_context: Callable):
data_file = f'{Path(__file__).parent}/json_test.ndjson'
with table_context('test_json_upload', ['key UInt16', 'flt_val Float64', 'int_val Int8']):
insert_file(test_client, 'test_json_upload', data_file, 'JSONEachRow')
res = test_client.query('SELECT * FROM test_json_upload ORDER BY key').result_rows
assert res[1][0] == 17
assert res[1][1] == 5.3
assert res[1][2] == 121