Skip to content

Commit 1f4012f

Browse files
committed
wip
1 parent 92d01da commit 1f4012f

7 files changed

Lines changed: 279 additions & 181 deletions

File tree

‎docs/catalog-interface.md‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,6 @@ SELECT * FROM information_schema.schemata WHERE catalog_name = 'mydb';
2727
| Discovery | `Worker.functions` list | `CatalogInterface.catalogs()` |
2828

2929
---
30-
31-
## Architecture
32-
33-
```
34-
┌─────────────────────────────────────────────────────────────────────┐
35-
│ DuckDB / Client │
36-
│ ┌───────────────────────────────────────────────────────────────┐ │
37-
│ │ ATTACH 'db1' (TYPE 'vgi', LOCATION './worker') │ │
38-
│ │ ↓ │ │
39-
│ │ CatalogClientMixin.catalog_attach(name='db1') │ │
40-
│ └───────────────────────────────────────────────────────────────┘ │
41-
│ │ stdin/stdout │
42-
│ ▼ │
43-
│ ┌───────────────────────────────────────────────────────────────┐ │
44-
│ │ Worker Process │ │
45-
│ │ vgi_rpc dispatch → CatalogInterface.{method_name}(**kwargs) │ │
46-
│ │ ↓ │ │
47-
│ │ Typed response (serialized by vgi_rpc) │ │
48-
│ └───────────────────────────────────────────────────────────────┘ │
49-
└─────────────────────────────────────────────────────────────────────┘
50-
```
51-
52-
---
53-
5430
## Protocol
5531

5632
Catalog methods are dispatched via `vgi_rpc` typed protocol methods. Each method has its own typed request/response defined in `vgi.protocol`, with automatic Arrow serialization handled by the RPC layer. This is simpler than the function protocol — no bind/init phases.

‎vgi/catalog/catalog_interface.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Literal,
1717
NewType,
1818
Self,
19+
cast,
1920
overload,
2021
)
2122

@@ -312,7 +313,7 @@ def deserialize(cls, batch: pa.RecordBatch) -> Self:
312313
# Deserialize the nested arguments batch.
313314
# row["arguments"] is already bytes (_validate_single_row_batch returns
314315
# Python values, not PyArrow scalars).
315-
arguments_bytes: bytes = row["arguments"]
316+
arguments_bytes = cast(bytes, row["arguments"])
316317
arguments_batch, _ = deserialize_record_batch(arguments_bytes)
317318

318319
# Extract positional and named arguments from the batch
@@ -327,10 +328,10 @@ def deserialize(cls, batch: pa.RecordBatch) -> Self:
327328
named_arguments[arg_field.name] = value
328329

329330
return cls(
330-
function_name=row["function_name"],
331+
function_name=cast(str, row["function_name"]),
331332
positional_arguments=positional_arguments,
332333
named_arguments=named_arguments,
333-
required_extensions=list(row.get("required_extensions") or []),
334+
required_extensions=list(cast("list[str]", row.get("required_extensions") or [])),
334335
)
335336

336337

‎vgi/catalog/setting.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Annotated,
1212
Any,
1313
ClassVar,
14+
cast,
1415
get_args,
1516
get_origin,
1617
get_type_hints,
@@ -94,18 +95,18 @@ def deserialize(cls, batch: pa.RecordBatch) -> "Self":
9495
required_fields=["name", "description", "type"],
9596
)
9697
# Deserialize type from schema bytes
97-
type_schema = pa.ipc.read_schema(pa.py_buffer(row["type"]))
98+
type_schema = pa.ipc.read_schema(pa.py_buffer(cast(bytes, row["type"])))
9899
data_type = type_schema.field("value").type
99100

100101
# Deserialize default value if present
101102
default: Any = None
102103
if row["default_value"] is not None:
103-
default_batch, _ = deserialize_record_batch(row["default_value"])
104+
default_batch, _ = deserialize_record_batch(cast(bytes, row["default_value"]))
104105
default = default_batch.column("value")[0].as_py()
105106

106107
return cls(
107-
name=row["name"],
108-
desc=row["description"],
108+
name=cast(str, row["name"]),
109+
desc=cast(str, row["description"]),
109110
type=data_type,
110111
default=default,
111112
)

0 commit comments

Comments
 (0)