chtypes 2.0.0.dev1__tar.gz → 2.0.0.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/PKG-INFO +8 -6
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/README.md +7 -5
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/pyproject.toml +1 -1
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/__init__.py +11 -3
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/__main__.py +23 -5
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_decode.py +48 -1
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_input.py +42 -1
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_channel.py +4 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_ensure.py +6 -1
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_layout.py +17 -7
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/library.py +47 -5
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/registry.py +25 -1
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/results.py +32 -0
- chtypes-2.0.0.dev2/tests/abi2/test_public_server.py +268 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/test_public_setup_cases.py +50 -1
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/cli/test_devchannel.py +22 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_cache_roots.py +38 -1
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_devchannel.py +60 -2
- chtypes-2.0.0.dev2/tests/test_cache_roots_api.py +61 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/test_examples_tour.py +1 -1
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/uv.lock +1 -1
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/.gitignore +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/CHANGELOG.md +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/LICENSE +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_abi2/__init__.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_abi2/_decls.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_abi2/_errmap.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_abi2/_errors.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_abi2/_loader.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_abi2/_vocab.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ed25519.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_guard.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/__init__.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_constants.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_dsse.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_errors.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_faults.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_goldens.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_http.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_lock.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_oci.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_referrers.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_ocifetch/_unpack.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/_setup.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/errors.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/src/chtypes/py.typed +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/__init__.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/_stub_tree.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/conftest.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/test_conformance.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/test_dev_fingerprint.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/test_goldens_runner_stub.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/test_loader.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/test_public_library.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/test_public_open.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/test_public_registry.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/abi2/test_reader_rules.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/api/__init__.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/api/test_decode.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/api/test_input.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/api/test_vocab.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/cli/__init__.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/cli/conftest.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/cli/test_main.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/conftest.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/goldens_v1/__init__.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/goldens_v1/data/stub-goldens.json +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/goldens_v1/test_runner.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/__init__.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/_bundle_support.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/_registry_support.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/_sign_support.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/conftest.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_cache_strict.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_conformance.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_dsse.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_ensure.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_goldens.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_http.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_layout.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_lock.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_oci.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_seam_gate.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/ocifetch/test_unpack.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/test_abi_identity.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/test_devchannel_registry.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/test_ed25519.py +0 -0
- {chtypes-2.0.0.dev1 → chtypes-2.0.0.dev2}/tests/test_fetch_options.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: chtypes
|
|
3
|
-
Version: 2.0.0.
|
|
3
|
+
Version: 2.0.0.dev2
|
|
4
4
|
Summary: Python binding for the chtypes artifacts: ClickHouse's own type system, per version, behind the frozen chs_* C ABI
|
|
5
5
|
Project-URL: Homepage, https://github.com/wave-rf/chtypes
|
|
6
6
|
Project-URL: Repository, https://github.com/wave-rf/chtypes
|
|
@@ -20,6 +20,8 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
# chtypes — Python SDK
|
|
21
21
|
|
|
22
22
|
> **2.0.0-dev: UNSTABLE, staging only, not for production.** This is the ABI v2 development binding (public issue #511). It speaks ABI v2's unstable description, pins its dev fingerprint and refuses a library with any other ("update your dev SDK"). It fetches only from the staging dev channel (`https://registry-staging.wavehouse.dev/chtypes/v2-dev`) and trusts only the staging key; `CHTYPES_ARTIFACTS_URL`, `CHTYPES_TRUSTED_KEYS` and `CHTYPES_ALLOW_UNSIGNED`, and the `bases`, `trusted_keys` and `allow_unsigned` fetch options, are ignored, each with one warning; `--lock`, `--frozen` and `--update`, and the `frozen`, `lock_path`, `lock_write` and `update` options, are refused, because a dev build is replaceable and a superseded one expires after 14 days. Its cache is `${XDG_CACHE_HOME:-~/.cache}/chtypes/v2-dev`, or `<CHTYPES_CACHE>/v2-dev` under an explicit cache, which no 1.x SDK reads. Every vocabulary keeps a value it does not list as its `unknown(n)` member (`Outcome("x")`, whose `known` is `False`) instead of failing the document. The rules are r1 to r6 of [`docs/reference/abi-v2.md`](../docs/reference/abi-v2.md). For production, use the 1.x package: `pip install "chtypes<2"`.
|
|
23
|
+
>
|
|
24
|
+
> An explicit cache directory gets the `v2-dev` subroot whether it comes from `CHTYPES_CACHE` or from `FetchOptions(cache_dir=...)`: the layout is under `<cache_dir>/v2-dev`, never in the directory itself, so code that inspects or pre-populates a cache looks there; `chtypes.cache_root` and `chtypes.search_dirs` return the resolved paths. `CHTYPES_OFFLINE=1` is the environment twin of `FetchOptions(offline=True)` and `--offline`: the cache only, no request.
|
|
23
25
|
|
|
24
26
|
**If this row were inserted into this table on this ClickHouse version, what would happen?** chtypes answers with ClickHouse's own code: the real C++ type machinery, vendored per release into a native library behind the frozen `chs_*` C ABI and reached here through stdlib `ctypes`. Nothing semantic is reimplemented, so _"what does ClickHouse do with `256` into a `UInt8`?"_ is answered by ClickHouse rather than by a model of it. One peer binding among `{go, python, ts, rust}` — no language is privileged, and all four give one answer.
|
|
25
27
|
|
|
@@ -41,18 +43,18 @@ uv add "chtypes>=2.0.0.dev0" # or: pip install "chtypes>=2.0.0.dev0"
|
|
|
41
43
|
import chtypes
|
|
42
44
|
from chtypes import Format, Registry
|
|
43
45
|
|
|
44
|
-
chtypes.setup(timezone="UTC")
|
|
46
|
+
chtypes.setup(timezone="UTC") # once, before the first open (optional)
|
|
45
47
|
registry = Registry(autofetch=True)
|
|
46
|
-
library = registry.for_version("26.8")
|
|
48
|
+
library = registry.for_version("26.8") # a release line or an exact version
|
|
47
49
|
|
|
48
50
|
ddl = b"CREATE TABLE t (x UInt8, ts DateTime DEFAULT now()) ENGINE = Memory"
|
|
49
51
|
with library.compile_table(ddl) as schema:
|
|
50
52
|
batch = schema.rows(Format.JSON_EACH_ROW, b'{"x":256}\n')
|
|
51
53
|
|
|
52
54
|
row = batch.rows[0]
|
|
53
|
-
print(batch.outcome)
|
|
54
|
-
print(row.values[0].text)
|
|
55
|
-
print(row.transformed[0].reason)
|
|
55
|
+
print(batch.outcome) # accepted
|
|
56
|
+
print(row.values[0].text) # b'0' what would actually be stored
|
|
57
|
+
print(row.transformed[0].reason) # overflow_wrap which is the product
|
|
56
58
|
```
|
|
57
59
|
|
|
58
60
|
The row is **accepted** and `256` is silently stored as `0`. That report — `transformed` — is why chtypes exists. Names, SQL, messages and renderings come back as `bytes`, never decoded for you: a column name that is not valid UTF-8 round-trips exactly.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# chtypes — Python SDK
|
|
2
2
|
|
|
3
3
|
> **2.0.0-dev: UNSTABLE, staging only, not for production.** This is the ABI v2 development binding (public issue #511). It speaks ABI v2's unstable description, pins its dev fingerprint and refuses a library with any other ("update your dev SDK"). It fetches only from the staging dev channel (`https://registry-staging.wavehouse.dev/chtypes/v2-dev`) and trusts only the staging key; `CHTYPES_ARTIFACTS_URL`, `CHTYPES_TRUSTED_KEYS` and `CHTYPES_ALLOW_UNSIGNED`, and the `bases`, `trusted_keys` and `allow_unsigned` fetch options, are ignored, each with one warning; `--lock`, `--frozen` and `--update`, and the `frozen`, `lock_path`, `lock_write` and `update` options, are refused, because a dev build is replaceable and a superseded one expires after 14 days. Its cache is `${XDG_CACHE_HOME:-~/.cache}/chtypes/v2-dev`, or `<CHTYPES_CACHE>/v2-dev` under an explicit cache, which no 1.x SDK reads. Every vocabulary keeps a value it does not list as its `unknown(n)` member (`Outcome("x")`, whose `known` is `False`) instead of failing the document. The rules are r1 to r6 of [`docs/reference/abi-v2.md`](../docs/reference/abi-v2.md). For production, use the 1.x package: `pip install "chtypes<2"`.
|
|
4
|
+
>
|
|
5
|
+
> An explicit cache directory gets the `v2-dev` subroot whether it comes from `CHTYPES_CACHE` or from `FetchOptions(cache_dir=...)`: the layout is under `<cache_dir>/v2-dev`, never in the directory itself, so code that inspects or pre-populates a cache looks there; `chtypes.cache_root` and `chtypes.search_dirs` return the resolved paths. `CHTYPES_OFFLINE=1` is the environment twin of `FetchOptions(offline=True)` and `--offline`: the cache only, no request.
|
|
4
6
|
|
|
5
7
|
**If this row were inserted into this table on this ClickHouse version, what would happen?** chtypes answers with ClickHouse's own code: the real C++ type machinery, vendored per release into a native library behind the frozen `chs_*` C ABI and reached here through stdlib `ctypes`. Nothing semantic is reimplemented, so _"what does ClickHouse do with `256` into a `UInt8`?"_ is answered by ClickHouse rather than by a model of it. One peer binding among `{go, python, ts, rust}` — no language is privileged, and all four give one answer.
|
|
6
8
|
|
|
@@ -22,18 +24,18 @@ uv add "chtypes>=2.0.0.dev0" # or: pip install "chtypes>=2.0.0.dev0"
|
|
|
22
24
|
import chtypes
|
|
23
25
|
from chtypes import Format, Registry
|
|
24
26
|
|
|
25
|
-
chtypes.setup(timezone="UTC")
|
|
27
|
+
chtypes.setup(timezone="UTC") # once, before the first open (optional)
|
|
26
28
|
registry = Registry(autofetch=True)
|
|
27
|
-
library = registry.for_version("26.8")
|
|
29
|
+
library = registry.for_version("26.8") # a release line or an exact version
|
|
28
30
|
|
|
29
31
|
ddl = b"CREATE TABLE t (x UInt8, ts DateTime DEFAULT now()) ENGINE = Memory"
|
|
30
32
|
with library.compile_table(ddl) as schema:
|
|
31
33
|
batch = schema.rows(Format.JSON_EACH_ROW, b'{"x":256}\n')
|
|
32
34
|
|
|
33
35
|
row = batch.rows[0]
|
|
34
|
-
print(batch.outcome)
|
|
35
|
-
print(row.values[0].text)
|
|
36
|
-
print(row.transformed[0].reason)
|
|
36
|
+
print(batch.outcome) # accepted
|
|
37
|
+
print(row.values[0].text) # b'0' what would actually be stored
|
|
38
|
+
print(row.transformed[0].reason) # overflow_wrap which is the product
|
|
37
39
|
```
|
|
38
40
|
|
|
39
41
|
The row is **accepted** and `256` is silently stored as `0`. That report — `transformed` — is why chtypes exists. Names, SQL, messages and renderings come back as `bytes`, never decoded for you: a column name that is not valid UTF-8 round-trips exactly.
|
|
@@ -59,7 +59,7 @@ from ._abi2._vocab import (
|
|
|
59
59
|
Status,
|
|
60
60
|
Verdict,
|
|
61
61
|
)
|
|
62
|
-
from ._input import BytesIn, Settings
|
|
62
|
+
from ._input import BytesIn, ServerProfile, Settings
|
|
63
63
|
from ._setup import setup
|
|
64
64
|
from .errors import (
|
|
65
65
|
CODE_ARTIFACT_CORRUPT,
|
|
@@ -92,8 +92,8 @@ from .errors import (
|
|
|
92
92
|
UnsupportedError,
|
|
93
93
|
UsageError,
|
|
94
94
|
)
|
|
95
|
-
from .library import Block, Filter, Library, Schema, open_unverified
|
|
96
|
-
from .registry import FetchOptions, Registry, Resolved, TrustedKey
|
|
95
|
+
from .library import Block, Filter, Library, Schema, Server, open_unverified
|
|
96
|
+
from .registry import FetchOptions, Registry, Resolved, TrustedKey, cache_root, search_dirs
|
|
97
97
|
from .results import (
|
|
98
98
|
BatchResult,
|
|
99
99
|
BuildInfo,
|
|
@@ -111,6 +111,8 @@ from .results import (
|
|
|
111
111
|
Header,
|
|
112
112
|
RowResult,
|
|
113
113
|
SchemaDescription,
|
|
114
|
+
SchemaReplicated,
|
|
115
|
+
SchemaServer,
|
|
114
116
|
Span,
|
|
115
117
|
Transform,
|
|
116
118
|
Value,
|
|
@@ -172,6 +174,10 @@ __all__ = [
|
|
|
172
174
|
"Schema",
|
|
173
175
|
"SchemaDescription",
|
|
174
176
|
"SchemaError",
|
|
177
|
+
"SchemaReplicated",
|
|
178
|
+
"SchemaServer",
|
|
179
|
+
"Server",
|
|
180
|
+
"ServerProfile",
|
|
175
181
|
"Settings",
|
|
176
182
|
"Source",
|
|
177
183
|
"SourceForbiddenError",
|
|
@@ -186,7 +192,9 @@ __all__ = [
|
|
|
186
192
|
"UsageError",
|
|
187
193
|
"Value",
|
|
188
194
|
"Verdict",
|
|
195
|
+
"cache_root",
|
|
189
196
|
"open_unverified",
|
|
197
|
+
"search_dirs",
|
|
190
198
|
"setup",
|
|
191
199
|
]
|
|
192
200
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[--frozen] [--offline] [--update] [--strict]
|
|
6
6
|
chtypes verify [--cache <dir>] [--strict] re-verify every installed build
|
|
7
7
|
chtypes list [--cache <dir>] [--offline] [--strict]
|
|
8
|
-
chtypes where [--cache <dir>] [--strict] the cache root
|
|
8
|
+
chtypes where [--cache <dir>] [--strict] [--all] the cache root; --all: every search dir
|
|
9
9
|
|
|
10
10
|
A spelling is `26.8`, `26.8.15` or `26.8.15.10`. Exit statuses come from the
|
|
11
11
|
`errors` table of spec/fetch-v1/constants.json (generated into the fetch layer
|
|
@@ -137,7 +137,10 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
137
137
|
fetch.add_argument(
|
|
138
138
|
"--offline",
|
|
139
139
|
action="store_true",
|
|
140
|
-
help=
|
|
140
|
+
help=(
|
|
141
|
+
"never touch a source: installed and verified, or CHTYPES_ARTIFACT_MISSING "
|
|
142
|
+
"(or set CHTYPES_OFFLINE=1)"
|
|
143
|
+
),
|
|
141
144
|
)
|
|
142
145
|
|
|
143
146
|
verify = sub.add_parser(
|
|
@@ -154,11 +157,22 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
154
157
|
)
|
|
155
158
|
cache_option(listing)
|
|
156
159
|
listing.add_argument(
|
|
157
|
-
"--offline",
|
|
160
|
+
"--offline",
|
|
161
|
+
action="store_true",
|
|
162
|
+
help="list only what is installed; no network (or set CHTYPES_OFFLINE=1)",
|
|
158
163
|
)
|
|
159
164
|
|
|
160
|
-
where = sub.add_parser(
|
|
165
|
+
where = sub.add_parser(
|
|
166
|
+
"where",
|
|
167
|
+
help="the cache root",
|
|
168
|
+
description="Print the cache root; with --all, every directory searched.",
|
|
169
|
+
)
|
|
161
170
|
cache_option(where)
|
|
171
|
+
where.add_argument(
|
|
172
|
+
"--all",
|
|
173
|
+
action="store_true",
|
|
174
|
+
help="every directory searched, in order, the cache root first (one per line)",
|
|
175
|
+
)
|
|
162
176
|
return parser
|
|
163
177
|
|
|
164
178
|
|
|
@@ -294,7 +308,7 @@ def _cmd_list(args: argparse.Namespace) -> int:
|
|
|
294
308
|
sys.stdout.write(f"installed {r.version} {r.platform} {r.dir}\n")
|
|
295
309
|
sys.stdout.flush()
|
|
296
310
|
_say_notes(options)
|
|
297
|
-
if not
|
|
311
|
+
if not options.resolved_offline():
|
|
298
312
|
for tag in _published_tags(options):
|
|
299
313
|
sys.stdout.write(f"published {tag} support unknown\n")
|
|
300
314
|
sys.stdout.flush()
|
|
@@ -306,6 +320,10 @@ def _cmd_where(args: argparse.Namespace) -> int:
|
|
|
306
320
|
if options.resolved_strict():
|
|
307
321
|
# Strict mode checks the root before naming it.
|
|
308
322
|
probe_roots(search_roots(options.cache_dir, options.system_dirs), strict=True)
|
|
323
|
+
if args.all:
|
|
324
|
+
for directory in search_roots(options.cache_dir, options.system_dirs):
|
|
325
|
+
sys.stdout.write(f"{directory}\n")
|
|
326
|
+
return EXIT_OK
|
|
309
327
|
sys.stdout.write(f"{resolve_cache_root(args.cache)}\n")
|
|
310
328
|
return EXIT_OK
|
|
311
329
|
|
|
@@ -47,6 +47,8 @@ from .results import (
|
|
|
47
47
|
Header,
|
|
48
48
|
RowResult,
|
|
49
49
|
SchemaDescription,
|
|
50
|
+
SchemaReplicated,
|
|
51
|
+
SchemaServer,
|
|
50
52
|
Span,
|
|
51
53
|
Transform,
|
|
52
54
|
Value,
|
|
@@ -449,10 +451,55 @@ def _column(obj: dict[str, Any], where: str) -> Column:
|
|
|
449
451
|
)
|
|
450
452
|
|
|
451
453
|
|
|
454
|
+
def _string_map(obj: Mapping[str, Any], key: str, where: str) -> dict[str, str] | None:
|
|
455
|
+
"""An object of plain JSON strings (a server's settings or macros, the
|
|
456
|
+
caller's own values given back): None when absent, a dict, even an empty
|
|
457
|
+
one, when present, so absent and `{}` stay apart."""
|
|
458
|
+
value = obj.get(key)
|
|
459
|
+
if value is None:
|
|
460
|
+
return None
|
|
461
|
+
inner = _obj(value, where, key)
|
|
462
|
+
out: dict[str, str] = {}
|
|
463
|
+
for name, item in inner.items():
|
|
464
|
+
if not isinstance(item, str):
|
|
465
|
+
raise _wrong(f"{where}.{key}", name, "a string", item)
|
|
466
|
+
out[name] = item
|
|
467
|
+
return out
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
def _server(obj: dict[str, Any], where: str) -> SchemaServer:
|
|
471
|
+
return SchemaServer(
|
|
472
|
+
timezone=_text(obj, "timezone", where),
|
|
473
|
+
settings=_string_map(obj, "settings", where) or {},
|
|
474
|
+
macros=_string_map(obj, "macros", where),
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
def _replicated(obj: dict[str, Any], where: str) -> SchemaReplicated:
|
|
479
|
+
return SchemaReplicated(
|
|
480
|
+
zookeeper_path=_bytes(obj, "zookeeper_path", where),
|
|
481
|
+
replica_name=_bytes(obj, "replica_name", where),
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
|
|
452
485
|
def decode_schema_description(raw: bytes) -> SchemaDescription:
|
|
453
486
|
where = "schema_description"
|
|
454
487
|
obj = _obj(strict_loads(raw, where), where)
|
|
455
|
-
|
|
488
|
+
# Both are absent on a schema compiled without a server, so that document
|
|
489
|
+
# decodes exactly as it did before servers existed.
|
|
490
|
+
server = obj.get("server")
|
|
491
|
+
replicated = obj.get("replicated")
|
|
492
|
+
return SchemaDescription(
|
|
493
|
+
columns=_objects(obj, "columns", where, _column),
|
|
494
|
+
server=None
|
|
495
|
+
if server is None
|
|
496
|
+
else _server(_obj(server, where, "server"), f"{where}.server"),
|
|
497
|
+
replicated=(
|
|
498
|
+
None
|
|
499
|
+
if replicated is None
|
|
500
|
+
else _replicated(_obj(replicated, where, "replicated"), f"{where}.replicated")
|
|
501
|
+
),
|
|
502
|
+
)
|
|
456
503
|
|
|
457
504
|
|
|
458
505
|
def _discovered(obj: dict[str, Any], where: str) -> DiscoveredColumn:
|
|
@@ -12,10 +12,11 @@ from __future__ import annotations
|
|
|
12
12
|
import base64
|
|
13
13
|
import json
|
|
14
14
|
from collections.abc import Mapping, Sequence
|
|
15
|
+
from dataclasses import dataclass
|
|
15
16
|
|
|
16
17
|
from .errors import misuse
|
|
17
18
|
|
|
18
|
-
__all__ = ["BytesIn", "Settings"]
|
|
19
|
+
__all__ = ["BytesIn", "ServerProfile", "Settings"]
|
|
19
20
|
|
|
20
21
|
BytesIn = bytes | str
|
|
21
22
|
Settings = Mapping[str, str]
|
|
@@ -107,3 +108,43 @@ def columns_json(columns: Sequence[BytesIn] | None) -> bytes | None:
|
|
|
107
108
|
except UnicodeDecodeError:
|
|
108
109
|
names.append({"name_b64": base64.b64encode(raw).decode("ascii")})
|
|
109
110
|
return _dump(names)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@dataclass(frozen=True, slots=True)
|
|
114
|
+
class ServerProfile:
|
|
115
|
+
"""One ClickHouse server, as the library's `input:server_profile` describes
|
|
116
|
+
it. Every field is optional and passed through as given: the library
|
|
117
|
+
validates the zone with DateLUT, each setting with the server's own SET
|
|
118
|
+
check, and the macros with ClickHouse's own reader. The binding validates
|
|
119
|
+
nothing in it.
|
|
120
|
+
|
|
121
|
+
`timezone` is the server's zone, the one its `timezone()` returns; None or
|
|
122
|
+
"" leaves it undescribed (omitted) and the image zone applies. `settings` is
|
|
123
|
+
what the server's profile applies to every query, layered under a schema's
|
|
124
|
+
and a call's own; None omits it, and `{}` is sent as `{}`. `macros` is the
|
|
125
|
+
server's `<macros>`: None omits it, and the server's macros are UNKNOWN (a
|
|
126
|
+
schema whose engine reads one is declined); a mapping, even an empty one, is
|
|
127
|
+
sent (`{}` when empty) and is the server's COMPLETE set."""
|
|
128
|
+
|
|
129
|
+
timezone: str | None = None
|
|
130
|
+
settings: Settings | None = None
|
|
131
|
+
macros: Settings | None = None
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def server_profile_json(profile: ServerProfile) -> bytes:
|
|
135
|
+
"""The profile document: an empty or absent zone and an absent map are
|
|
136
|
+
omitted; a present map is sent as given, `{}` when empty. Absent `macros` is
|
|
137
|
+
not empty `macros`."""
|
|
138
|
+
if not isinstance(profile, ServerProfile):
|
|
139
|
+
raise TypeError(f"profile must be a ServerProfile, not {type(profile).__name__}")
|
|
140
|
+
doc: dict[str, object] = {}
|
|
141
|
+
if profile.timezone is not None:
|
|
142
|
+
if not isinstance(profile.timezone, str):
|
|
143
|
+
raise TypeError(f"timezone must be str, not {type(profile.timezone).__name__}")
|
|
144
|
+
if profile.timezone != "":
|
|
145
|
+
doc["timezone"] = profile.timezone
|
|
146
|
+
if profile.settings is not None:
|
|
147
|
+
doc["settings"] = _string_map(profile.settings, "settings")
|
|
148
|
+
if profile.macros is not None:
|
|
149
|
+
doc["macros"] = _string_map(profile.macros, "macros")
|
|
150
|
+
return _dump(doc)
|
|
@@ -69,6 +69,10 @@ DEV_KEY_ID: Final = "824345f9bcf8e5bf"
|
|
|
69
69
|
DEV_KEY_HEX: Final = "5cd30c53c65a1ebc2d85836a41deb06661bb0ae7b658adb9eb116ec2db8e9b1c"
|
|
70
70
|
# The dev channel's cache directory name: the default root's last element and
|
|
71
71
|
# an explicit cache's subroot (rule r5).
|
|
72
|
+
# The environment twin of the offline option (public issue #528): CHTYPES_OFFLINE=1
|
|
73
|
+
# reads the cache only and makes no request. It names no source, so rule r6 holds.
|
|
74
|
+
# Not a generated constant: the generated set is the v1 fetch contract's.
|
|
75
|
+
ENV_OFFLINE_NAME: Final = "CHTYPES_OFFLINE"
|
|
72
76
|
DEV_CACHE_DIR: Final = "v2-dev"
|
|
73
77
|
# The verified.json schema the dev channel writes, and the only one it reads (rule r5).
|
|
74
78
|
DEV_RECORD_SCHEMA: Final = 2
|
|
@@ -137,6 +137,8 @@ class Options:
|
|
|
137
137
|
token: str | None = None
|
|
138
138
|
trusted_keys: tuple[TrustedKey, ...] | None = None
|
|
139
139
|
allow_unsigned: bool = False
|
|
140
|
+
# Offline mode is on when this is set OR CHTYPES_OFFLINE=1; neither turns
|
|
141
|
+
# the other off (public issue #528).
|
|
140
142
|
offline: bool = False
|
|
141
143
|
frozen: bool = False
|
|
142
144
|
lock_path: str | os.PathLike[str] | None = None
|
|
@@ -185,6 +187,9 @@ class Options:
|
|
|
185
187
|
def resolved_platform(self) -> str:
|
|
186
188
|
return self.platform or detect_host_platform()
|
|
187
189
|
|
|
190
|
+
def resolved_offline(self) -> bool:
|
|
191
|
+
return self.offline or os.environ.get(_channel.ENV_OFFLINE_NAME) == "1"
|
|
192
|
+
|
|
188
193
|
def resolved_strict(self) -> bool:
|
|
189
194
|
if self.strict_cache is not None:
|
|
190
195
|
return self.strict_cache
|
|
@@ -1012,7 +1017,7 @@ def _ensure(
|
|
|
1012
1017
|
request: Request, platform_key: str, options: Options, lock: Lock | None, roots: Sequence[Path]
|
|
1013
1018
|
) -> Resolved:
|
|
1014
1019
|
try:
|
|
1015
|
-
if options.
|
|
1020
|
+
if options.resolved_offline():
|
|
1016
1021
|
resolved = resolve_installed(request, platform_key, options)
|
|
1017
1022
|
if resolved is None:
|
|
1018
1023
|
raise ArtifactMissingError(
|
|
@@ -49,20 +49,30 @@ def _expand_template(template: str) -> str:
|
|
|
49
49
|
return string.Template(out).safe_substitute(mapping)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
def _absolute(p: str | os.PathLike[str]) -> Path:
|
|
53
|
+
"""A relative cache directory is the process cwd's at this call, resolved here
|
|
54
|
+
once so every path derived from it is absolute (fetch-v1.md section 9, public
|
|
55
|
+
issue #541). Lexical, like Go's `filepath.Abs`: no symlink is followed."""
|
|
56
|
+
return Path(os.path.abspath(p))
|
|
57
|
+
|
|
58
|
+
|
|
52
59
|
def resolve_cache_root(cache_dir: str | os.PathLike[str] | None = None) -> Path:
|
|
53
60
|
"""`CHTYPES_CACHE` (or an explicit override) names the cache directory
|
|
54
61
|
ITSELF, not a parent `chtypes/` to append to (constants: `cache.root_template`).
|
|
55
62
|
|
|
56
63
|
The active fetch contract decides the rest (_channel.py): under the dev
|
|
57
|
-
channel an explicit cache
|
|
58
|
-
never as a whole layout, which a 1.x
|
|
59
|
-
the default root is
|
|
64
|
+
channel an explicit cache, from the environment or the option, is used
|
|
65
|
+
through its subroot `<cache>/v2-dev`, never as a whole layout, which a 1.x
|
|
66
|
+
binding uses (rule r5, a MUST), and the default root is
|
|
67
|
+
`${XDG_CACHE_HOME:-~/.cache}/chtypes/v2-dev`. The result is absolute (#541)."""
|
|
60
68
|
channel = _channel.active()
|
|
61
|
-
explicit = cache_dir if cache_dir is not None else
|
|
62
|
-
if
|
|
63
|
-
|
|
69
|
+
explicit = os.fspath(cache_dir) if cache_dir is not None else ""
|
|
70
|
+
if not explicit:
|
|
71
|
+
explicit = os.environ.get(C.ENV_CACHE_NAME) or ""
|
|
72
|
+
if explicit:
|
|
73
|
+
root = _absolute(explicit)
|
|
64
74
|
return root / channel.subroot if channel.subroot else root
|
|
65
|
-
return Path(_expand_template(C.CACHE_ROOT_TEMPLATE)).parent / channel.root_leaf
|
|
75
|
+
return _absolute(Path(_expand_template(C.CACHE_ROOT_TEMPLATE)).parent / channel.root_leaf)
|
|
66
76
|
|
|
67
77
|
|
|
68
78
|
def cache_root(cache_dir: str | os.PathLike[str] | None = None) -> Path:
|
|
@@ -23,9 +23,11 @@ from ._abi2._vocab import EXPORT_NONE, DocFlags, Format
|
|
|
23
23
|
from ._guard import CloseGuard
|
|
24
24
|
from ._input import (
|
|
25
25
|
BytesIn,
|
|
26
|
+
ServerProfile,
|
|
26
27
|
Settings,
|
|
27
28
|
body_bytes,
|
|
28
29
|
columns_json,
|
|
30
|
+
server_profile_json,
|
|
29
31
|
settings_json,
|
|
30
32
|
string_map_json,
|
|
31
33
|
to_bytes,
|
|
@@ -40,7 +42,7 @@ from .results import (
|
|
|
40
42
|
SchemaDescription,
|
|
41
43
|
)
|
|
42
44
|
|
|
43
|
-
__all__ = ["Block", "Filter", "Library", "Schema", "open_unverified"]
|
|
45
|
+
__all__ = ["Block", "Filter", "Library", "Schema", "Server", "open_unverified"]
|
|
44
46
|
|
|
45
47
|
# One image per file, process-wide: keyed on the realpath's device and inode, so
|
|
46
48
|
# two registries, two spellings or a hardlink of one artifact share one image
|
|
@@ -159,6 +161,19 @@ class _Handle:
|
|
|
159
161
|
self.close()
|
|
160
162
|
|
|
161
163
|
|
|
164
|
+
class Server(_Handle):
|
|
165
|
+
"""One ClickHouse server (`chs_server`), made by `Library.new_server` and
|
|
166
|
+
passed to `Library.compile_table(server=)`. Immutable once made, so safe to
|
|
167
|
+
share across threads: any number of threads may compile tables on one server
|
|
168
|
+
at once. `close` releases the caller's reference, after the compiles already
|
|
169
|
+
using the server have returned; a schema compiled on the server holds its own
|
|
170
|
+
counted reference inside the library, so a server and its schemas close in
|
|
171
|
+
any order."""
|
|
172
|
+
|
|
173
|
+
__slots__ = ()
|
|
174
|
+
_what = "Server"
|
|
175
|
+
|
|
176
|
+
|
|
162
177
|
class Block(_Handle):
|
|
163
178
|
"""A body parsed once, for evaluating many filters over it. It holds a counted
|
|
164
179
|
reference to its schema inside the library."""
|
|
@@ -388,18 +403,45 @@ class Library:
|
|
|
388
403
|
"""Live handle counts per kind in this image (a diagnostic)."""
|
|
389
404
|
return _decode.decode_live_handles(self._api.live_handles())
|
|
390
405
|
|
|
406
|
+
def new_server(self, profile: ServerProfile) -> Server:
|
|
407
|
+
"""Describe one ClickHouse server from a profile (`chs_server_create`). The
|
|
408
|
+
library validates the whole profile here, once: a zone DateLUT cannot
|
|
409
|
+
load, or a setting the server's SET check refuses, is the library's own
|
|
410
|
+
refusal (`SchemaError`); a malformed macro set is a `UsageError`; a build
|
|
411
|
+
that will not describe the profile declines it (`UnsupportedError`). The
|
|
412
|
+
binding checks none of it first. No server option is defined yet, so the
|
|
413
|
+
options document is empty."""
|
|
414
|
+
document = server_profile_json(profile)
|
|
415
|
+
return Server(self, self._api.server_create(document, None))
|
|
416
|
+
|
|
391
417
|
def compile_table(
|
|
392
418
|
self,
|
|
393
419
|
create_table: BytesIn,
|
|
394
420
|
*,
|
|
395
421
|
settings: Settings | None = None,
|
|
396
422
|
session_timezone: str | None = None,
|
|
423
|
+
server: Server | None = None,
|
|
397
424
|
) -> Schema:
|
|
398
425
|
"""Compile exactly one `CREATE TABLE` statement. `settings` is the profile;
|
|
399
|
-
a compiled type always takes the image zone, never the profile's.
|
|
426
|
+
a compiled type always takes the image zone, never the profile's.
|
|
427
|
+
|
|
428
|
+
`server` (from `new_server`) compiles the table on that server: the
|
|
429
|
+
schema's home zone is the server's timezone, the server's settings layer
|
|
430
|
+
under the schema's own, and a Replicated engine's ZooKeeper path and
|
|
431
|
+
replica name expand the server's macros. A closed server is a
|
|
432
|
+
`UsageError`, raised before any call; a server from another library is
|
|
433
|
+
that library's own refusal, also a `UsageError`. `None` is no server: the
|
|
434
|
+
schema is on the image's own server."""
|
|
400
435
|
statement = to_bytes(create_table, "create_table")
|
|
401
436
|
settings_bytes = settings_json(settings, session_timezone)
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
437
|
+
if server is not None and not isinstance(server, Server):
|
|
438
|
+
raise TypeError(f"server must be a Server, not {type(server).__name__}")
|
|
439
|
+
# No schema option is defined yet: none, which the library reads as `{}`.
|
|
440
|
+
# A closed server is refused here, before the call, because its freed
|
|
441
|
+
# handle would cross as NULL and the library would compile on the
|
|
442
|
+
# image's server instead of refusing.
|
|
443
|
+
with _hold(*(() if server is None else (server._guard,))):
|
|
444
|
+
handle = self._api.schema_create(
|
|
445
|
+
None if server is None else server._handle, statement, settings_bytes, None
|
|
446
|
+
)
|
|
405
447
|
return Schema(self, handle)
|
|
@@ -32,10 +32,11 @@ from ._ocifetch import _constants as _fetch_constants
|
|
|
32
32
|
from ._ocifetch._dsse import TrustedKey
|
|
33
33
|
from ._ocifetch._ensure import detect_host_platform, missing_notes, with_notes
|
|
34
34
|
from ._ocifetch._errors import FetchError
|
|
35
|
+
from ._ocifetch._layout import resolve_cache_root, search_roots
|
|
35
36
|
from ._ocifetch._oci import version_within_request
|
|
36
37
|
from .library import Library, open_image
|
|
37
38
|
|
|
38
|
-
__all__ = ["FetchOptions", "Registry", "Resolved", "TrustedKey"]
|
|
39
|
+
__all__ = ["FetchOptions", "Registry", "Resolved", "TrustedKey", "cache_root", "search_dirs"]
|
|
39
40
|
|
|
40
41
|
_TRUTHY = ("1", "true", "yes", "on")
|
|
41
42
|
|
|
@@ -80,6 +81,8 @@ class FetchOptions:
|
|
|
80
81
|
token: str | None = None
|
|
81
82
|
trusted_keys: Sequence[TrustedKey] | None = None
|
|
82
83
|
allow_unsigned: bool | None = None
|
|
84
|
+
# Offline reads the cache only and makes no request. It is on when this is
|
|
85
|
+
# set OR CHTYPES_OFFLINE=1; neither turns the other off (public issue #528).
|
|
83
86
|
offline: bool = False
|
|
84
87
|
frozen: bool = False
|
|
85
88
|
lock_path: str | os.PathLike[str] | None = None
|
|
@@ -120,6 +123,27 @@ class FetchOptions:
|
|
|
120
123
|
)
|
|
121
124
|
|
|
122
125
|
|
|
126
|
+
def cache_root(options: FetchOptions | None = None) -> Path:
|
|
127
|
+
"""The cache root a fetch, list or `chtypes where` with `options` would use:
|
|
128
|
+
`options.cache_dir`, else `CHTYPES_CACHE` (each used through its `v2-dev`
|
|
129
|
+
subroot, spec/abi-v2/docs.md rule r5), else
|
|
130
|
+
`${XDG_CACHE_HOME:-~/.cache}/chtypes/v2-dev`.
|
|
131
|
+
|
|
132
|
+
It is the fetch layer's own resolution, `search_dirs(options)[0]`. It
|
|
133
|
+
creates nothing and reads no cache."""
|
|
134
|
+
return resolve_cache_root((options or FetchOptions()).cache_dir)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def search_dirs(options: FetchOptions | None = None) -> tuple[Path, ...]:
|
|
138
|
+
"""Every directory a lookup reads for installed builds, in the order it reads
|
|
139
|
+
them: the cache root first, then each read-only system directory
|
|
140
|
+
(`options.system_dirs`; `None` is the built-in list, an empty sequence none).
|
|
141
|
+
The order is the fetch layer's own, and on a tie the earlier directory wins.
|
|
142
|
+
It creates nothing and touches no file."""
|
|
143
|
+
o = options or FetchOptions()
|
|
144
|
+
return search_roots(o.cache_dir, o.system_dirs)
|
|
145
|
+
|
|
146
|
+
|
|
123
147
|
def _wrap(exc: FetchError) -> errors.ArtifactError:
|
|
124
148
|
"""The fetch layer's error as the public class of its code, one family with
|
|
125
149
|
the loader's. The original stays as `__cause__`."""
|
|
@@ -11,6 +11,7 @@ vendored reader does not know a fact, the document says `null` and the field is
|
|
|
11
11
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
|
+
from collections.abc import Mapping
|
|
14
15
|
from dataclasses import dataclass
|
|
15
16
|
|
|
16
17
|
from ._abi2._vocab import DefaultKind, FilterOutcome, Outcome, Verdict
|
|
@@ -32,6 +33,8 @@ __all__ = [
|
|
|
32
33
|
"Header",
|
|
33
34
|
"RowResult",
|
|
34
35
|
"SchemaDescription",
|
|
36
|
+
"SchemaReplicated",
|
|
37
|
+
"SchemaServer",
|
|
35
38
|
"Span",
|
|
36
39
|
"Transform",
|
|
37
40
|
"Value",
|
|
@@ -210,9 +213,38 @@ class Column:
|
|
|
210
213
|
default_expr: bytes
|
|
211
214
|
|
|
212
215
|
|
|
216
|
+
@dataclass(frozen=True, slots=True)
|
|
217
|
+
class SchemaServer:
|
|
218
|
+
"""The server a schema was compiled on, as the library holds it. Its strings
|
|
219
|
+
are the caller's own profile values given back, so they are plain text, not
|
|
220
|
+
data-derived. `timezone` is the zone the schema's types bind: the profile's,
|
|
221
|
+
or else the image zone. `settings` is the profile's settings (`{}` when it
|
|
222
|
+
gave none). `macros` is None exactly when the profile carried no macros
|
|
223
|
+
(unknown), and a mapping, even an empty one, when it did (the complete set)."""
|
|
224
|
+
|
|
225
|
+
timezone: str
|
|
226
|
+
settings: Mapping[str, str]
|
|
227
|
+
macros: Mapping[str, str] | None
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
@dataclass(frozen=True, slots=True)
|
|
231
|
+
class SchemaReplicated:
|
|
232
|
+
"""What ClickHouse's own TableZnodeInfo resolved for a Replicated engine on a
|
|
233
|
+
server, fully expanded. Both expand DDL bytes, so both are `bytes`."""
|
|
234
|
+
|
|
235
|
+
zookeeper_path: bytes
|
|
236
|
+
replica_name: bytes
|
|
237
|
+
|
|
238
|
+
|
|
213
239
|
@dataclass(frozen=True, slots=True)
|
|
214
240
|
class SchemaDescription:
|
|
241
|
+
"""A schema's columns, in declared order, and the server it was compiled on.
|
|
242
|
+
`server` is None exactly when it was compiled without one; `replicated` is
|
|
243
|
+
None when the document carries none."""
|
|
244
|
+
|
|
215
245
|
columns: tuple[Column, ...]
|
|
246
|
+
server: SchemaServer | None = None
|
|
247
|
+
replicated: SchemaReplicated | None = None
|
|
216
248
|
|
|
217
249
|
|
|
218
250
|
@dataclass(frozen=True, slots=True)
|