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

Cut from upstream 0.2.9 — 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:28 -07:00

62 lines
1.4 KiB
Python

def get_inner_spec(column_name, spec):
brackets = 0
offset = len(column_name)
i = offset
for i, ch in enumerate(spec[offset:], offset):
if ch == '(':
brackets += 1
elif ch == ')':
brackets -= 1
if brackets == 0:
break
return spec[offset + 1:i]
def get_inner_columns(spec):
brackets = 0
column_begin = 0
columns = []
for i, x in enumerate(spec + ','):
if x == ',':
if brackets == 0:
columns.append(spec[column_begin:i])
column_begin = i + 1
elif x == '(':
brackets += 1
elif x == ')':
brackets -= 1
elif x == ' ':
if brackets == 0:
column_begin = i + 1
return columns
def get_inner_columns_with_types(spec):
spec = spec.strip()
brackets = 0
prev_comma = 0
prev_space = 0
columns = []
for i, x in enumerate(spec.strip() + ','):
if x == ',':
if brackets == 0:
columns.append((
spec[prev_comma:prev_space].strip(),
spec[prev_space:i]
))
prev_comma = i + 1
elif x == '(':
brackets += 1
elif x == ')':
brackets -= 1
elif x == ' ':
if brackets == 0:
prev_space = i + 1
return columns