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
vgi/client/cli_view.py
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
|
+
|
|
3
|
+
"""View CLI commands for VGI.
|
|
4
|
+
|
|
5
|
+
This module provides CLI commands for view operations:
|
|
6
|
+
- get: Get view info
|
|
7
|
+
- create: Create a new view
|
|
8
|
+
- drop: Drop a view
|
|
9
|
+
- rename: Rename a view
|
|
10
|
+
- comment: Update view comment
|
|
11
|
+
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import click
|
|
17
|
+
|
|
18
|
+
from vgi.catalog import OnConflict
|
|
19
|
+
from vgi.client.cli_utils import (
|
|
20
|
+
get_attach_opaque_data_from_options,
|
|
21
|
+
hex_to_transaction_opaque_data,
|
|
22
|
+
output_json,
|
|
23
|
+
parse_json_option,
|
|
24
|
+
view_info_to_dict,
|
|
25
|
+
)
|
|
26
|
+
from vgi.client.client import Client
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@click.group()
|
|
30
|
+
def view() -> None:
|
|
31
|
+
"""Manage views in a catalog."""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@view.command("get")
|
|
35
|
+
@click.argument("schema_name")
|
|
36
|
+
@click.argument("name")
|
|
37
|
+
@click.option("--attach-opaque-data", help="Hex-encoded attach ID")
|
|
38
|
+
@click.option("--catalog", "catalog_name", help="Catalog name for auto-attach")
|
|
39
|
+
@click.option("--attach-options", default="{}", help="Attach options as JSON")
|
|
40
|
+
@click.option("--worker", "-w", required=True, help="VGI worker command")
|
|
41
|
+
@click.option("--transaction-opaque-data", help="Transaction ID (hex) for transactional read")
|
|
42
|
+
def view_get(
|
|
43
|
+
schema_name: str,
|
|
44
|
+
name: str,
|
|
45
|
+
attach_opaque_data: str | None,
|
|
46
|
+
catalog_name: str | None,
|
|
47
|
+
attach_options: str,
|
|
48
|
+
worker: str,
|
|
49
|
+
transaction_opaque_data: str | None,
|
|
50
|
+
) -> None:
|
|
51
|
+
"""Get information about a view.
|
|
52
|
+
|
|
53
|
+
SCHEMA_NAME is the schema containing the view.
|
|
54
|
+
NAME is the view name.
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
client = Client(worker)
|
|
58
|
+
opts = parse_json_option(attach_options, "--attach-options")
|
|
59
|
+
resolved_attach_opaque_data, is_stateful = get_attach_opaque_data_from_options(
|
|
60
|
+
client, attach_opaque_data, catalog_name, opts
|
|
61
|
+
)
|
|
62
|
+
if is_stateful and catalog_name:
|
|
63
|
+
click.echo(
|
|
64
|
+
"Warning: Using --catalog with a stateful catalog. "
|
|
65
|
+
"Consider using --attach-opaque-data for session persistence.",
|
|
66
|
+
err=True,
|
|
67
|
+
)
|
|
68
|
+
view_info = client.view_get(
|
|
69
|
+
attach_opaque_data=resolved_attach_opaque_data,
|
|
70
|
+
transaction_opaque_data=(
|
|
71
|
+
hex_to_transaction_opaque_data(transaction_opaque_data) if transaction_opaque_data else None
|
|
72
|
+
),
|
|
73
|
+
schema_name=schema_name,
|
|
74
|
+
name=name,
|
|
75
|
+
)
|
|
76
|
+
if view_info:
|
|
77
|
+
output_json(view_info_to_dict(view_info))
|
|
78
|
+
else:
|
|
79
|
+
output_json({"error": "not_found", "schema": schema_name, "name": name})
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@view.command("create")
|
|
83
|
+
@click.argument("schema_name")
|
|
84
|
+
@click.argument("name")
|
|
85
|
+
@click.option("--attach-opaque-data", help="Hex-encoded attach ID")
|
|
86
|
+
@click.option("--catalog", "catalog_name", help="Catalog name for auto-attach")
|
|
87
|
+
@click.option("--attach-options", default="{}", help="Attach options as JSON")
|
|
88
|
+
@click.option("--worker", "-w", required=True, help="VGI worker command")
|
|
89
|
+
@click.option("--transaction-opaque-data", help="Transaction ID (hex)")
|
|
90
|
+
@click.option("--definition", required=True, help="View definition SQL")
|
|
91
|
+
@click.option(
|
|
92
|
+
"--on-conflict",
|
|
93
|
+
type=click.Choice(["error", "ignore", "replace"]),
|
|
94
|
+
default="error",
|
|
95
|
+
help="Behavior if view already exists",
|
|
96
|
+
)
|
|
97
|
+
def view_create(
|
|
98
|
+
schema_name: str,
|
|
99
|
+
name: str,
|
|
100
|
+
attach_opaque_data: str | None,
|
|
101
|
+
catalog_name: str | None,
|
|
102
|
+
attach_options: str,
|
|
103
|
+
worker: str,
|
|
104
|
+
transaction_opaque_data: str | None,
|
|
105
|
+
definition: str,
|
|
106
|
+
on_conflict: str,
|
|
107
|
+
) -> None:
|
|
108
|
+
"""Create a new view.
|
|
109
|
+
|
|
110
|
+
SCHEMA_NAME is the schema to create the view in.
|
|
111
|
+
NAME is the name for the new view.
|
|
112
|
+
|
|
113
|
+
"""
|
|
114
|
+
client = Client(worker)
|
|
115
|
+
opts = parse_json_option(attach_options, "--attach-options")
|
|
116
|
+
resolved_attach_opaque_data, is_stateful = get_attach_opaque_data_from_options(
|
|
117
|
+
client, attach_opaque_data, catalog_name, opts
|
|
118
|
+
)
|
|
119
|
+
if is_stateful and catalog_name:
|
|
120
|
+
click.echo(
|
|
121
|
+
"Warning: Using --catalog with a stateful catalog. "
|
|
122
|
+
"Consider using --attach-opaque-data for session persistence.",
|
|
123
|
+
err=True,
|
|
124
|
+
)
|
|
125
|
+
client.view_create(
|
|
126
|
+
attach_opaque_data=resolved_attach_opaque_data,
|
|
127
|
+
transaction_opaque_data=(
|
|
128
|
+
hex_to_transaction_opaque_data(transaction_opaque_data) if transaction_opaque_data else None
|
|
129
|
+
),
|
|
130
|
+
schema_name=schema_name,
|
|
131
|
+
name=name,
|
|
132
|
+
definition=definition,
|
|
133
|
+
on_conflict=OnConflict(on_conflict),
|
|
134
|
+
)
|
|
135
|
+
output_json({"status": "created", "schema": schema_name, "name": name})
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@view.command("drop")
|
|
139
|
+
@click.argument("schema_name")
|
|
140
|
+
@click.argument("name")
|
|
141
|
+
@click.option("--attach-opaque-data", help="Hex-encoded attach ID")
|
|
142
|
+
@click.option("--catalog", "catalog_name", help="Catalog name for auto-attach")
|
|
143
|
+
@click.option("--attach-options", default="{}", help="Attach options as JSON")
|
|
144
|
+
@click.option("--worker", "-w", required=True, help="VGI worker command")
|
|
145
|
+
@click.option("--transaction-opaque-data", help="Transaction ID (hex)")
|
|
146
|
+
@click.option("--ignore-not-found", is_flag=True, help="Don't error if not found")
|
|
147
|
+
def view_drop(
|
|
148
|
+
schema_name: str,
|
|
149
|
+
name: str,
|
|
150
|
+
attach_opaque_data: str | None,
|
|
151
|
+
catalog_name: str | None,
|
|
152
|
+
attach_options: str,
|
|
153
|
+
worker: str,
|
|
154
|
+
transaction_opaque_data: str | None,
|
|
155
|
+
ignore_not_found: bool,
|
|
156
|
+
) -> None:
|
|
157
|
+
"""Drop a view.
|
|
158
|
+
|
|
159
|
+
SCHEMA_NAME is the schema containing the view.
|
|
160
|
+
NAME is the name of the view to drop.
|
|
161
|
+
|
|
162
|
+
"""
|
|
163
|
+
client = Client(worker)
|
|
164
|
+
opts = parse_json_option(attach_options, "--attach-options")
|
|
165
|
+
resolved_attach_opaque_data, is_stateful = get_attach_opaque_data_from_options(
|
|
166
|
+
client, attach_opaque_data, catalog_name, opts
|
|
167
|
+
)
|
|
168
|
+
if is_stateful and catalog_name:
|
|
169
|
+
click.echo(
|
|
170
|
+
"Warning: Using --catalog with a stateful catalog. "
|
|
171
|
+
"Consider using --attach-opaque-data for session persistence.",
|
|
172
|
+
err=True,
|
|
173
|
+
)
|
|
174
|
+
client.view_drop(
|
|
175
|
+
attach_opaque_data=resolved_attach_opaque_data,
|
|
176
|
+
transaction_opaque_data=(
|
|
177
|
+
hex_to_transaction_opaque_data(transaction_opaque_data) if transaction_opaque_data else None
|
|
178
|
+
),
|
|
179
|
+
schema_name=schema_name,
|
|
180
|
+
name=name,
|
|
181
|
+
ignore_not_found=ignore_not_found,
|
|
182
|
+
)
|
|
183
|
+
output_json({"status": "dropped", "schema": schema_name, "name": name})
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
@view.command("rename")
|
|
187
|
+
@click.argument("schema_name")
|
|
188
|
+
@click.argument("name")
|
|
189
|
+
@click.argument("new_name")
|
|
190
|
+
@click.option("--attach-opaque-data", help="Hex-encoded attach ID")
|
|
191
|
+
@click.option("--catalog", "catalog_name", help="Catalog name for auto-attach")
|
|
192
|
+
@click.option("--attach-options", default="{}", help="Attach options as JSON")
|
|
193
|
+
@click.option("--worker", "-w", required=True, help="VGI worker command")
|
|
194
|
+
@click.option("--transaction-opaque-data", help="Transaction ID (hex)")
|
|
195
|
+
@click.option("--ignore-not-found", is_flag=True, help="Don't error if not found")
|
|
196
|
+
def view_rename(
|
|
197
|
+
schema_name: str,
|
|
198
|
+
name: str,
|
|
199
|
+
new_name: str,
|
|
200
|
+
attach_opaque_data: str | None,
|
|
201
|
+
catalog_name: str | None,
|
|
202
|
+
attach_options: str,
|
|
203
|
+
worker: str,
|
|
204
|
+
transaction_opaque_data: str | None,
|
|
205
|
+
ignore_not_found: bool,
|
|
206
|
+
) -> None:
|
|
207
|
+
"""Rename a view.
|
|
208
|
+
|
|
209
|
+
SCHEMA_NAME is the schema containing the view.
|
|
210
|
+
NAME is the current view name.
|
|
211
|
+
NEW_NAME is the new name for the view.
|
|
212
|
+
|
|
213
|
+
"""
|
|
214
|
+
client = Client(worker)
|
|
215
|
+
opts = parse_json_option(attach_options, "--attach-options")
|
|
216
|
+
resolved_attach_opaque_data, is_stateful = get_attach_opaque_data_from_options(
|
|
217
|
+
client, attach_opaque_data, catalog_name, opts
|
|
218
|
+
)
|
|
219
|
+
if is_stateful and catalog_name:
|
|
220
|
+
click.echo(
|
|
221
|
+
"Warning: Using --catalog with a stateful catalog. "
|
|
222
|
+
"Consider using --attach-opaque-data for session persistence.",
|
|
223
|
+
err=True,
|
|
224
|
+
)
|
|
225
|
+
client.view_rename(
|
|
226
|
+
attach_opaque_data=resolved_attach_opaque_data,
|
|
227
|
+
transaction_opaque_data=(
|
|
228
|
+
hex_to_transaction_opaque_data(transaction_opaque_data) if transaction_opaque_data else None
|
|
229
|
+
),
|
|
230
|
+
schema_name=schema_name,
|
|
231
|
+
name=name,
|
|
232
|
+
new_name=new_name,
|
|
233
|
+
ignore_not_found=ignore_not_found,
|
|
234
|
+
)
|
|
235
|
+
output_json(
|
|
236
|
+
{
|
|
237
|
+
"status": "renamed",
|
|
238
|
+
"schema": schema_name,
|
|
239
|
+
"old": name,
|
|
240
|
+
"new": new_name,
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
@view.command("comment")
|
|
246
|
+
@click.argument("schema_name")
|
|
247
|
+
@click.argument("name")
|
|
248
|
+
@click.option("--attach-opaque-data", help="Hex-encoded attach ID")
|
|
249
|
+
@click.option("--catalog", "catalog_name", help="Catalog name for auto-attach")
|
|
250
|
+
@click.option("--attach-options", default="{}", help="Attach options as JSON")
|
|
251
|
+
@click.option("--worker", "-w", required=True, help="VGI worker command")
|
|
252
|
+
@click.option("--transaction-opaque-data", help="Transaction ID (hex)")
|
|
253
|
+
@click.option("--set", "comment_text", help="Set comment to this text")
|
|
254
|
+
@click.option("--clear", is_flag=True, help="Clear the comment")
|
|
255
|
+
@click.option("--ignore-not-found", is_flag=True, help="Don't error if not found")
|
|
256
|
+
def view_comment(
|
|
257
|
+
schema_name: str,
|
|
258
|
+
name: str,
|
|
259
|
+
attach_opaque_data: str | None,
|
|
260
|
+
catalog_name: str | None,
|
|
261
|
+
attach_options: str,
|
|
262
|
+
worker: str,
|
|
263
|
+
transaction_opaque_data: str | None,
|
|
264
|
+
comment_text: str | None,
|
|
265
|
+
clear: bool,
|
|
266
|
+
ignore_not_found: bool,
|
|
267
|
+
) -> None:
|
|
268
|
+
"""Update or clear a view's comment.
|
|
269
|
+
|
|
270
|
+
SCHEMA_NAME is the schema containing the view.
|
|
271
|
+
NAME is the view name.
|
|
272
|
+
|
|
273
|
+
Use --set to set a comment, --clear to remove it.
|
|
274
|
+
|
|
275
|
+
"""
|
|
276
|
+
if comment_text is None and not clear:
|
|
277
|
+
raise click.ClickException("Must specify either --set or --clear")
|
|
278
|
+
if comment_text is not None and clear:
|
|
279
|
+
raise click.ClickException("Cannot specify both --set and --clear")
|
|
280
|
+
|
|
281
|
+
client = Client(worker)
|
|
282
|
+
opts = parse_json_option(attach_options, "--attach-options")
|
|
283
|
+
resolved_attach_opaque_data, is_stateful = get_attach_opaque_data_from_options(
|
|
284
|
+
client, attach_opaque_data, catalog_name, opts
|
|
285
|
+
)
|
|
286
|
+
if is_stateful and catalog_name:
|
|
287
|
+
click.echo(
|
|
288
|
+
"Warning: Using --catalog with a stateful catalog. "
|
|
289
|
+
"Consider using --attach-opaque-data for session persistence.",
|
|
290
|
+
err=True,
|
|
291
|
+
)
|
|
292
|
+
client.view_comment_set(
|
|
293
|
+
attach_opaque_data=resolved_attach_opaque_data,
|
|
294
|
+
transaction_opaque_data=(
|
|
295
|
+
hex_to_transaction_opaque_data(transaction_opaque_data) if transaction_opaque_data else None
|
|
296
|
+
),
|
|
297
|
+
schema_name=schema_name,
|
|
298
|
+
name=name,
|
|
299
|
+
comment=None if clear else comment_text,
|
|
300
|
+
ignore_not_found=ignore_not_found,
|
|
301
|
+
)
|
|
302
|
+
status = "comment_cleared" if clear else "comment_set"
|
|
303
|
+
output_json({"status": status, "schema": schema_name, "name": name})
|