vgi-python 0.8.0__py3-none-any.whl
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.
- vgi/__init__.py +152 -0
- vgi/_duckdb.py +62 -0
- vgi/_storage_profile.py +132 -0
- vgi/_test_fixtures/__init__.py +20 -0
- vgi/_test_fixtures/accumulate/__init__.py +19 -0
- vgi/_test_fixtures/accumulate/worker.py +762 -0
- vgi/_test_fixtures/aggregate/__init__.py +62 -0
- vgi/_test_fixtures/aggregate/_common.py +21 -0
- vgi/_test_fixtures/aggregate/basic.py +232 -0
- vgi/_test_fixtures/aggregate/dynamic.py +409 -0
- vgi/_test_fixtures/aggregate/generic.py +86 -0
- vgi/_test_fixtures/aggregate/listagg.py +71 -0
- vgi/_test_fixtures/aggregate/percentile.py +107 -0
- vgi/_test_fixtures/aggregate/streaming.py +192 -0
- vgi/_test_fixtures/aggregate/varargs.py +75 -0
- vgi/_test_fixtures/aggregate/window.py +380 -0
- vgi/_test_fixtures/attach_options.py +308 -0
- vgi/_test_fixtures/bad_protocol.py +62 -0
- vgi/_test_fixtures/cancellable.py +336 -0
- vgi/_test_fixtures/catalog.py +813 -0
- vgi/_test_fixtures/http_server.py +394 -0
- vgi/_test_fixtures/nest_tensor.py +614 -0
- vgi/_test_fixtures/orchard_catalog.py +47 -0
- vgi/_test_fixtures/projection_repro/__init__.py +6 -0
- vgi/_test_fixtures/projection_repro/worker.py +454 -0
- vgi/_test_fixtures/scalar/__init__.py +116 -0
- vgi/_test_fixtures/scalar/_common.py +69 -0
- vgi/_test_fixtures/scalar/arithmetic.py +321 -0
- vgi/_test_fixtures/scalar/binary.py +120 -0
- vgi/_test_fixtures/scalar/formatting.py +176 -0
- vgi/_test_fixtures/scalar/geo.py +300 -0
- vgi/_test_fixtures/scalar/null_handling.py +107 -0
- vgi/_test_fixtures/scalar/random_demo.py +171 -0
- vgi/_test_fixtures/scalar/settings_secrets.py +102 -0
- vgi/_test_fixtures/scalar/type_info.py +219 -0
- vgi/_test_fixtures/schema_reconcile/__init__.py +29 -0
- vgi/_test_fixtures/schema_reconcile/worker.py +653 -0
- vgi/_test_fixtures/simple_writable.py +793 -0
- vgi/_test_fixtures/table/__init__.py +221 -0
- vgi/_test_fixtures/table/_common.py +162 -0
- vgi/_test_fixtures/table/batch_index.py +283 -0
- vgi/_test_fixtures/table/batch_index_broken.py +200 -0
- vgi/_test_fixtures/table/catalog_scans.py +162 -0
- vgi/_test_fixtures/table/filters.py +1005 -0
- vgi/_test_fixtures/table/late_materialization.py +249 -0
- vgi/_test_fixtures/table/make_series.py +273 -0
- vgi/_test_fixtures/table/misc.py +499 -0
- vgi/_test_fixtures/table/order_modes.py +164 -0
- vgi/_test_fixtures/table/pairs.py +437 -0
- vgi/_test_fixtures/table/partition_columns.py +472 -0
- vgi/_test_fixtures/table/partition_columns_broken.py +304 -0
- vgi/_test_fixtures/table/profiling_example.py +195 -0
- vgi/_test_fixtures/table/required_filters.py +234 -0
- vgi/_test_fixtures/table/sequence.py +710 -0
- vgi/_test_fixtures/table/settings.py +426 -0
- vgi/_test_fixtures/table/transaction_storage.py +162 -0
- vgi/_test_fixtures/table/tt_pushdown.py +191 -0
- vgi/_test_fixtures/table/versioned.py +230 -0
- vgi/_test_fixtures/table_in_out.py +1392 -0
- vgi/_test_fixtures/versioned.py +155 -0
- vgi/_test_fixtures/versioned_tables.py +595 -0
- vgi/_test_fixtures/worker.py +1631 -0
- vgi/_test_fixtures/writable/__init__.py +8 -0
- vgi/_test_fixtures/writable/generic.py +236 -0
- vgi/_test_fixtures/writable/table.py +149 -0
- vgi/_test_fixtures/writable/worker.py +1148 -0
- vgi/aggregate_function.py +607 -0
- vgi/argument_spec.py +472 -0
- vgi/arguments.py +1747 -0
- vgi/auth.py +55 -0
- vgi/catalog/__init__.py +88 -0
- vgi/catalog/attach_option.py +206 -0
- vgi/catalog/catalog_interface.py +2767 -0
- vgi/catalog/descriptors.py +870 -0
- vgi/catalog/duckdb_statistics.py +377 -0
- vgi/catalog/secret_type.py +96 -0
- vgi/catalog/setting.py +253 -0
- vgi/catalog/storage.py +372 -0
- vgi/client/__init__.py +67 -0
- vgi/client/catalog_mixin.py +1251 -0
- vgi/client/cli.py +582 -0
- vgi/client/cli_catalog.py +182 -0
- vgi/client/cli_schema.py +270 -0
- vgi/client/cli_table.py +907 -0
- vgi/client/cli_transaction.py +97 -0
- vgi/client/cli_utils.py +441 -0
- vgi/client/cli_view.py +303 -0
- vgi/client/client.py +2183 -0
- vgi/exceptions.py +205 -0
- vgi/function.py +245 -0
- vgi/function_storage.py +1636 -0
- vgi/function_storage_azure_sql.py +922 -0
- vgi/function_storage_cf_do.py +740 -0
- vgi/http/__init__.py +25 -0
- vgi/http/demo_storage.py +212 -0
- vgi/http/worker_page.py +1252 -0
- vgi/invocation.py +154 -0
- vgi/logging_config.py +93 -0
- vgi/meta_worker.py +661 -0
- vgi/metadata.py +1403 -0
- vgi/otel.py +406 -0
- vgi/protocol.py +2418 -0
- vgi/protocol_version.txt +1 -0
- vgi/py.typed +0 -0
- vgi/scalar_function.py +1211 -0
- vgi/schema_utils.py +234 -0
- vgi/secret_protocol.py +124 -0
- vgi/secret_service.py +238 -0
- vgi/serve.py +769 -0
- vgi/table_buffering_function.py +443 -0
- vgi/table_filter_pushdown.py +1528 -0
- vgi/table_function.py +1130 -0
- vgi/table_in_out_function.py +383 -0
- vgi/transactor/__init__.py +24 -0
- vgi/transactor/_duckdb_compat.py +27 -0
- vgi/transactor/client.py +137 -0
- vgi/transactor/protocol.py +149 -0
- vgi/transactor/server.py +740 -0
- vgi/worker.py +4761 -0
- vgi_python-0.8.0.dist-info/METADATA +735 -0
- vgi_python-0.8.0.dist-info/RECORD +124 -0
- vgi_python-0.8.0.dist-info/WHEEL +4 -0
- vgi_python-0.8.0.dist-info/entry_points.txt +5 -0
- vgi_python-0.8.0.dist-info/licenses/LICENSE +134 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
|
+
|
|
3
|
+
"""TransactorProtocol — RPC interface for the db-transactor.
|
|
4
|
+
|
|
5
|
+
Defines the Protocol class that both the server and client use.
|
|
6
|
+
Uses ``vgi_rpc`` streaming patterns:
|
|
7
|
+
|
|
8
|
+
- **Exchange streams** (table-in-out) for INSERT/UPDATE/DELETE
|
|
9
|
+
- **Producer streams** (table function) for SELECT/SCAN
|
|
10
|
+
- **Unary calls** for transaction lifecycle and DDL
|
|
11
|
+
|
|
12
|
+
All methods that operate on a database take ``attach_opaque_data`` to identify
|
|
13
|
+
which database to use. The transactor manages multiple databases, one
|
|
14
|
+
per catalog attachment.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from typing import Protocol
|
|
20
|
+
|
|
21
|
+
from vgi_rpc.rpc import ExchangeState, ProducerState, Stream
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class TransactorProtocol(Protocol):
|
|
25
|
+
"""RPC interface for the db-transactor subprocess."""
|
|
26
|
+
|
|
27
|
+
# ========== Database lifecycle (unary) ==========
|
|
28
|
+
|
|
29
|
+
def register(
|
|
30
|
+
self, attach_opaque_data: bytes, catalog_name: str = "", ddl_statements: list[str] | None = None
|
|
31
|
+
) -> None:
|
|
32
|
+
"""Register a new database for this attach_opaque_data and run initial DDL."""
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
def catalog_version(self, attach_opaque_data: bytes) -> int:
|
|
36
|
+
"""Return the catalog version for the database (incremented on DDL)."""
|
|
37
|
+
...
|
|
38
|
+
|
|
39
|
+
# ========== Transaction lifecycle (unary) ==========
|
|
40
|
+
|
|
41
|
+
def begin(self, attach_opaque_data: bytes) -> bytes:
|
|
42
|
+
"""Begin a transaction. Returns the transactor-generated tx_id."""
|
|
43
|
+
...
|
|
44
|
+
|
|
45
|
+
def commit(self, attach_opaque_data: bytes, tx_id: bytes) -> None:
|
|
46
|
+
"""Commit a transaction."""
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
def rollback(self, attach_opaque_data: bytes, tx_id: bytes) -> None:
|
|
50
|
+
"""Rollback a transaction."""
|
|
51
|
+
...
|
|
52
|
+
|
|
53
|
+
# ========== Write operations (streaming exchange) ==========
|
|
54
|
+
|
|
55
|
+
def insert(
|
|
56
|
+
self,
|
|
57
|
+
attach_opaque_data: bytes,
|
|
58
|
+
tx_id: bytes,
|
|
59
|
+
table_name: str,
|
|
60
|
+
schema_name: str = "",
|
|
61
|
+
returning: bool = False,
|
|
62
|
+
) -> Stream[ExchangeState]:
|
|
63
|
+
"""Insert rows into a table via lockstep exchange."""
|
|
64
|
+
...
|
|
65
|
+
|
|
66
|
+
def delete(
|
|
67
|
+
self,
|
|
68
|
+
attach_opaque_data: bytes,
|
|
69
|
+
tx_id: bytes,
|
|
70
|
+
table_name: str,
|
|
71
|
+
schema_name: str = "",
|
|
72
|
+
returning: bool = False,
|
|
73
|
+
) -> Stream[ExchangeState]:
|
|
74
|
+
"""Delete rows from a table via lockstep exchange."""
|
|
75
|
+
...
|
|
76
|
+
|
|
77
|
+
def update(
|
|
78
|
+
self,
|
|
79
|
+
attach_opaque_data: bytes,
|
|
80
|
+
tx_id: bytes,
|
|
81
|
+
table_name: str,
|
|
82
|
+
schema_name: str = "",
|
|
83
|
+
columns: list[str] | None = None,
|
|
84
|
+
returning: bool = False,
|
|
85
|
+
) -> Stream[ExchangeState]:
|
|
86
|
+
"""Update rows in a table via lockstep exchange."""
|
|
87
|
+
...
|
|
88
|
+
|
|
89
|
+
# ========== Read (streaming producer) ==========
|
|
90
|
+
|
|
91
|
+
def scan(
|
|
92
|
+
self,
|
|
93
|
+
attach_opaque_data: bytes,
|
|
94
|
+
tx_id: bytes,
|
|
95
|
+
table_name: str,
|
|
96
|
+
columns: list[str],
|
|
97
|
+
schema_name: str = "",
|
|
98
|
+
pushdown_filters: bytes | None = None,
|
|
99
|
+
) -> Stream[ProducerState]:
|
|
100
|
+
"""Scan rows from a table with optional predicate pushdown."""
|
|
101
|
+
...
|
|
102
|
+
|
|
103
|
+
# ========== DDL (unary) ==========
|
|
104
|
+
|
|
105
|
+
def execute_ddl(self, attach_opaque_data: bytes, sql: str) -> None:
|
|
106
|
+
"""Execute a DDL statement on the database (non-transactional)."""
|
|
107
|
+
...
|
|
108
|
+
|
|
109
|
+
def execute_ddl_tx(
|
|
110
|
+
self, attach_opaque_data: bytes, tx_id: bytes, sql: str, strip_catalog: str | None = None
|
|
111
|
+
) -> None:
|
|
112
|
+
"""Execute DDL within a transaction."""
|
|
113
|
+
...
|
|
114
|
+
|
|
115
|
+
# ========== Metadata (unary) ==========
|
|
116
|
+
|
|
117
|
+
def list_schemas(self, attach_opaque_data: bytes, tx_id: bytes) -> list[str]:
|
|
118
|
+
"""List schema names within a transaction."""
|
|
119
|
+
...
|
|
120
|
+
|
|
121
|
+
def list_user_tables(self, attach_opaque_data: bytes, tx_id: bytes, schema_name: str = "main") -> list[str]:
|
|
122
|
+
"""List user-created table names in the given schema within a transaction."""
|
|
123
|
+
...
|
|
124
|
+
|
|
125
|
+
def table_schema(self, attach_opaque_data: bytes, table_name: str, tx_id: bytes) -> bytes:
|
|
126
|
+
"""Get Arrow schema for a table as serialized IPC bytes."""
|
|
127
|
+
...
|
|
128
|
+
|
|
129
|
+
def table_comment(self, attach_opaque_data: bytes, table_name: str, tx_id: bytes) -> str | None:
|
|
130
|
+
"""Get the comment on a table, or None if no comment is set."""
|
|
131
|
+
...
|
|
132
|
+
|
|
133
|
+
def list_user_views(self, attach_opaque_data: bytes, tx_id: bytes, schema_name: str = "main") -> list[str]:
|
|
134
|
+
"""List user-created view names in the given schema within a transaction."""
|
|
135
|
+
...
|
|
136
|
+
|
|
137
|
+
def view_info(self, attach_opaque_data: bytes, view_name: str, tx_id: bytes) -> str:
|
|
138
|
+
"""Get view info as JSON (definition, comment)."""
|
|
139
|
+
...
|
|
140
|
+
|
|
141
|
+
# ========== Lifecycle (unary) ==========
|
|
142
|
+
|
|
143
|
+
def ping(self) -> None:
|
|
144
|
+
"""Health check."""
|
|
145
|
+
...
|
|
146
|
+
|
|
147
|
+
def shutdown(self) -> None:
|
|
148
|
+
"""Graceful shutdown."""
|
|
149
|
+
...
|