Files
zeekay 75dd1132bd rename: zero ClickHouse — datastore_connect speaks X-Datastore-*
The wire protocol was the last holdout and it was not cosmetic: the Hanzo
Datastore server reads X-Datastore-User, and answers a request bearing
X-ClickHouse-User with 401. Verified against the live server, both directions.
So a client still sending the old headers is not merely off-brand, it cannot
authenticate over HTTP.

Everything else follows: types, dialects, error modules, docstrings and doc
links now name Datastore, and doc URLs point at docs.hanzo.ai/datastore rather
than the upstream vendor's site. Zero occurrences of the old name remain.

Still cut from the pinned upstream version, so behaviour is unchanged.
2026-07-26 11:06:05 -07:00

50 lines
2.1 KiB
Python

import os
import random
from datastore_connect.datatypes.registry import get_from_name
from datastore_connect.driver.common import coerce_bool
from datastore_connect.driver.buffer import ResponseBuffer as PyBuff
from datastore_connect.driverc.buffer import ResponseBuffer as CBuff # pylint: disable=no-name-in-module
from tests.helpers import random_columns, random_data, native_transform, native_insert_block, bytes_source
TEST_COLUMNS = 12
MAX_DATA_ROWS = 100
use_c = coerce_bool(os.environ.get('DATASTORE_CONNECT_USE_C', True))
BuffCls = CBuff if use_c else PyBuff
# pylint: disable=duplicate-code
def test_native_round_trips():
test_runs = int(os.environ.get('DATASTORE_CONNECT_TEST_FUZZ', '200'))
for _ in range(test_runs):
data_rows = random.randint(1, MAX_DATA_ROWS)
col_names, col_types = random_columns(TEST_COLUMNS)
data = random_data(col_types, data_rows)
col_names = ('row_id',) + col_names
col_types = (get_from_name('UInt32'),) + col_types
assert len(data) == data_rows
output = native_insert_block(data, column_names=col_names, column_types=col_types)
data_result = native_transform.parse_response(bytes_source(output, cls=BuffCls))
assert data_result.column_names == col_names
assert data_result.column_types == col_types
dataset = data_result.result_set
for row in range(data_rows):
for col in range(TEST_COLUMNS):
assert dataset[row][col] == data[row][col]
def test_native_small():
test_runs = int(os.environ.get('DATASTORE_CONNECT_TEST_FUZZ', '200'))
for _ in range(test_runs):
col_names, col_types = random_columns(1)
data = random_data(col_types, 2)
col_names = ('row_id',) + col_names
col_types = (get_from_name('UInt32'),) + col_types
output = native_insert_block(data, column_names=col_names, column_types=col_types)
data_result = native_transform.parse_response(bytes_source(output, cls=BuffCls))
assert data_result.column_names == col_names
assert data_result.column_types == col_types
assert data_result.result_set == data