Skip to content

Commit 83cd0d8

Browse files
committed
renames
1 parent e23df30 commit 83cd0d8

17 files changed

Lines changed: 114 additions & 120 deletions

‎CLAUDE.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ class SequenceFunction(TableFunctionGenerator):
209209

210210
## Using DuckDB Settings
211211

212-
Functions can declare required DuckDB settings via `Meta.required_settings` and
212+
Functions can declare required settings via `Meta.required_settings` and
213213
access them via `self.settings` or `self.get_setting()`. Settings are available
214214
during the bind phase, allowing output schema to depend on setting values.
215215

216216
```python
217217
class SettingsAwareFunction(TableFunctionGenerator):
218-
"""Function that uses DuckDB settings to determine output."""
218+
"""Function that uses settings to determine output."""
219219

220220
class Meta:
221221
required_settings = ["vgi_verbose_mode"] # Declare required settings
@@ -249,7 +249,7 @@ with Client("vgi-example-worker") as client:
249249
for batch in client.table_function(
250250
function_name="settings_aware",
251251
arguments=Arguments(positional=(pa.scalar(10),)),
252-
duckdb_settings={"vgi_verbose_mode": "true"},
252+
settings={"vgi_verbose_mode": "true"},
253253
):
254254
process(batch)
255255
```
@@ -336,7 +336,7 @@ output_schema = schema_like(self.input_schema, rename={"old": "new"})
336336

337337
| Property/Method | Description |
338338
|-----------------|-------------|
339-
| `settings` | Dict of DuckDB settings passed to function |
339+
| `settings` | Dict of settings passed to function |
340340
| `get_setting(name, default)` | Get specific setting value |
341341

342342
### Pattern Decision Tree

‎docs/design-duckdb-settings.md‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
VGI functions need access to DuckDB settings/pragmas to:
5+
VGI functions need access to settings/pragmas to:
66
1. Determine output schema during bind phase (e.g., timezone affects datetime output)
77
2. Influence processing behavior (e.g., thread limits, memory settings)
88
3. Maintain consistency with DuckDB's execution environment
@@ -44,22 +44,22 @@ Settings are passed as a dict in the `Invocation`:
4444
@dataclass(frozen=True, slots=True)
4545
class Invocation:
4646
# ... existing fields ...
47-
duckdb_settings: dict[str, str] | None = None # New field
47+
settings: dict[str, str] | None = None # New field
4848
```
4949

5050
**Changes to `vgi/invocation.py`:**
51-
- Add `duckdb_settings: dict[str, str] | None = None` field
51+
- Add `settings: dict[str, str] | None = None` field
5252
- Serialize as `pa.map_(pa.utf8(), pa.utf8())` type in Arrow IPC
5353
- Deserialize with backward compatibility (None if field missing)
5454

5555
**Serialization Format:**
5656
```python
5757
# In serialize():
58-
pa.field("duckdb_settings", pa.map_(pa.utf8(), pa.utf8()), nullable=True)
58+
pa.field("settings", pa.map_(pa.utf8(), pa.utf8()), nullable=True)
5959

6060
# Value encoding:
61-
"duckdb_settings": (
62-
list(self.duckdb_settings.items()) if self.duckdb_settings else None
61+
"settings": (
62+
list(self.settings.items()) if self.settings else None
6363
)
6464
```
6565

@@ -71,8 +71,8 @@ Functions access settings via the `Function` base class:
7171
class Function:
7272
@property
7373
def settings(self) -> dict[str, str]:
74-
"""All DuckDB settings passed to this function."""
75-
return dict(self.invocation.duckdb_settings or {})
74+
"""All settings passed to this function."""
75+
return dict(self.invocation.settings or {})
7676

7777
def get_setting(self, name: str, default: str | None = None) -> str | None:
7878
"""Get a specific DuckDB setting value.
@@ -84,9 +84,9 @@ class Function:
8484
Returns:
8585
Setting value or default
8686
"""
87-
if self.invocation.duckdb_settings is None:
87+
if self.invocation.settings is None:
8888
return default
89-
return self.invocation.duckdb_settings.get(name, default)
89+
return self.invocation.settings.get(name, default)
9090
```
9191

9292
**Changes to `vgi/function.py`:**
@@ -111,7 +111,7 @@ def _validate_required_settings(
111111
if not required:
112112
return # No settings required
113113

114-
provided = set(invocation.duckdb_settings.keys()) if invocation.duckdb_settings else set()
114+
provided = set(invocation.settings.keys()) if invocation.settings else set()
115115
missing = required - provided
116116

117117
if missing:
@@ -135,12 +135,12 @@ def invoke(
135135
self,
136136
function_name: str,
137137
...,
138-
duckdb_settings: dict[str, str] | None = None, # New parameter
138+
settings: dict[str, str] | None = None, # New parameter
139139
) -> ...:
140140
```
141141

142142
**Changes to `vgi/client/client.py`:**
143-
- Add `duckdb_settings` parameter to `_initialize_stream_common()` and related methods
143+
- Add `settings` parameter to `_initialize_stream_common()` and related methods
144144
- Include in `Invocation` creation
145145

146146
## Protocol Flow
@@ -152,7 +152,7 @@ Client Worker
152152
│ ├─ function_name: "timezone_func" │
153153
│ ├─ arguments: {...} │
154154
│ ├─ input_schema: {...} │
155-
│ └─ duckdb_settings: { │
155+
│ └─ settings: { │
156156
│ "TimeZone": "America/New_York", │
157157
│ "threads": "4" │
158158
│ } │
@@ -209,10 +209,10 @@ class DebugOutputFunction(TableInOutFunction):
209209
| File | Changes |
210210
|------|---------|
211211
| `vgi/metadata.py` | Add `required_settings` to Meta, ResolvedMetadata, Arrow schema |
212-
| `vgi/invocation.py` | Add `duckdb_settings` field, serialization |
212+
| `vgi/invocation.py` | Add `settings` field, serialization |
213213
| `vgi/function.py` | Add `settings` property, `get_setting()` method |
214214
| `vgi/worker.py` | Add settings validation during bind |
215-
| `vgi/client/client.py` | Add `duckdb_settings` parameter |
215+
| `vgi/client/client.py` | Add `settings` parameter |
216216
| `docs/protocol.md` | Document settings in protocol |
217217
| `docs/metadata.md` | Document `required_settings` |
218218
| `CLAUDE.md` | Add settings usage example |
@@ -230,7 +230,7 @@ class DebugOutputFunction(TableInOutFunction):
230230
## Implementation Order
231231

232232
1. `vgi/metadata.py` - Add required_settings to Meta
233-
2. `vgi/invocation.py` - Add duckdb_settings field
233+
2. `vgi/invocation.py` - Add settings field
234234
3. `vgi/function.py` - Add settings accessor
235235
4. `vgi/worker.py` - Add validation
236236
5. `vgi/client/client.py` - Add settings parameter

‎docs/generator-api.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ class MyTableFunction(TableFunctionGenerator):
120120
| `cardinality()` | Provide row count estimates | Returns None |
121121
| `setup()` | Acquire resources | No-op |
122122
| `teardown()` | Release resources | No-op |
123-
| `perform_init()` | Distributed init (primary) | Default impl |
124-
| `retrieve_init()` | Distributed init (secondary) | Default impl |
123+
| `initialize_global_state()` | Distributed init (primary) | Default impl |
124+
| `load_global_state()` | Distributed init (secondary) | Default impl |
125125

126126
### Table Function Patterns
127127

@@ -149,11 +149,11 @@ def process(self):
149149

150150
**Parallel generation with work queue:**
151151
```python
152-
def perform_init(self, init_input):
152+
def initialize_global_state(self, init_input):
153153
# Primary worker: populate work queue
154154
work_items = [chunk.serialize() for chunk in self.create_chunks()]
155155
self.enqueue_work(work_items)
156-
return InitResult(self.init_identifier)
156+
return InitResult(self.execution_identifier)
157157

158158
def process(self):
159159
# All workers: pull from queue until empty

‎docs/protocol.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ The Invocation message contains the following fields:
9999
| `global_execution_identifier` | binary | Shared state ID for parallel workers |
100100
| `client_features` | list\<string\> | Feature flags from client |
101101
| `attach_id` | binary | DuckDB attachment identifier (nullable) |
102-
| `duckdb_settings` | map\<string, string\> | DuckDB settings/pragmas (nullable) |
102+
| `settings` | map\<string, string\> | settings/pragmas (nullable) |
103103

104104
## DuckDB Settings
105105

106-
Functions can declare required DuckDB settings via `Meta.required_settings`. These
106+
Functions can declare required settings via `Meta.required_settings`. These
107107
settings are passed from client to worker in the Invocation during the bind phase.
108108

109109
```python

‎tests/conftest.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def make_invocation(
2828
function_type: InvocationType = InvocationType.TABLE,
2929
arguments: Arguments | None = None,
3030
function_name: str = "test",
31-
duckdb_settings: dict[str, str] | None = None,
31+
settings: dict[str, str] | None = None,
3232
) -> Invocation:
3333
"""Create a test invocation with flexible parameters."""
3434
return Invocation(
@@ -38,7 +38,7 @@ def make_invocation(
3838
correlation_id="test",
3939
invocation_id=b"test",
4040
arguments=arguments or Arguments(),
41-
duckdb_settings=duckdb_settings,
41+
settings=settings,
4242
)
4343

4444

‎tests/table/generator/test_projected_data_function.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ def test_output_schema_reflects_projection(self) -> None:
168168
logger=structlog.get_logger(),
169169
)
170170

171-
# Without init_data, should return full schema
171+
# Without init_input, should return full schema
172172
assert func.output_schema == ProjectedDataFunction.FULL_SCHEMA
173173

174-
# After setting init_data with projection, should return projected schema
175-
func.init_data = TableFunctionInitInput(projection_ids=[0, 2])
174+
# After setting init_input with projection, should return projected schema
175+
func.init_input = TableFunctionInitInput(projection_ids=[0, 2])
176176
schema = func.output_schema
177177
assert len(schema) == 2
178178
assert schema.names == ["id", "value"]

‎tests/table/generator/test_settings_function.py‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Tests for the DuckDB settings feature."""
1+
"""Tests for the settings feature."""
22

33
import pyarrow as pa
44
import pytest
@@ -35,7 +35,7 @@ def test_settings_accessor_returns_settings(self) -> None:
3535
invocation = make_invocation(
3636
function_name="settings_aware",
3737
arguments=Arguments(positional=(pa.scalar(3),)),
38-
duckdb_settings={"vgi_verbose_mode": "true", "other": "value"},
38+
settings={"vgi_verbose_mode": "true", "other": "value"},
3939
)
4040
func = SettingsAwareFunction(
4141
invocation=invocation,
@@ -61,7 +61,7 @@ def test_get_setting_returns_value(self) -> None:
6161
invocation = make_invocation(
6262
function_name="settings_aware",
6363
arguments=Arguments(positional=(pa.scalar(3),)),
64-
duckdb_settings={"vgi_verbose_mode": "true"},
64+
settings={"vgi_verbose_mode": "true"},
6565
)
6666
func = SettingsAwareFunction(
6767
invocation=invocation,
@@ -74,7 +74,7 @@ def test_output_schema_without_verbose(self) -> None:
7474
invocation = make_invocation(
7575
function_name="settings_aware",
7676
arguments=Arguments(positional=(pa.scalar(3),)),
77-
duckdb_settings={"vgi_verbose_mode": "false"},
77+
settings={"vgi_verbose_mode": "false"},
7878
)
7979
func = SettingsAwareFunction(
8080
invocation=invocation,
@@ -88,7 +88,7 @@ def test_output_schema_with_verbose(self) -> None:
8888
invocation = make_invocation(
8989
function_name="settings_aware",
9090
arguments=Arguments(positional=(pa.scalar(3),)),
91-
duckdb_settings={"vgi_verbose_mode": "true"},
91+
settings={"vgi_verbose_mode": "true"},
9292
)
9393
func = SettingsAwareFunction(
9494
invocation=invocation,
@@ -108,7 +108,7 @@ def test_settings_passed_to_function_verbose_false(self) -> None:
108108
client.table_function(
109109
function_name="settings_aware",
110110
arguments=Arguments(positional=(pa.scalar(3),)),
111-
duckdb_settings={"vgi_verbose_mode": "false"},
111+
settings={"vgi_verbose_mode": "false"},
112112
)
113113
)
114114

@@ -125,7 +125,7 @@ def test_settings_passed_to_function_verbose_true(self) -> None:
125125
client.table_function(
126126
function_name="settings_aware",
127127
arguments=Arguments(positional=(pa.scalar(3),)),
128-
duckdb_settings={"vgi_verbose_mode": "true"},
128+
settings={"vgi_verbose_mode": "true"},
129129
)
130130
)
131131

@@ -145,7 +145,7 @@ def test_missing_required_setting_fails(self) -> None:
145145
client.table_function(
146146
function_name="settings_aware",
147147
arguments=Arguments(positional=(pa.scalar(3),)),
148-
# No duckdb_settings provided
148+
# No settings provided
149149
)
150150
)
151151

@@ -167,14 +167,14 @@ def test_settings_roundtrip(self) -> None:
167167
function_type=InvocationType.TABLE,
168168
correlation_id="test",
169169
invocation_id=b"test-id",
170-
duckdb_settings={"TimeZone": "UTC", "threads": "4"},
170+
settings={"TimeZone": "UTC", "threads": "4"},
171171
)
172172

173173
serialized = original.serialize()
174174
batch = pa.ipc.open_stream(pa.py_buffer(serialized)).read_all().to_batches()[0]
175175
deserialized = Invocation.deserialize(batch)
176176

177-
assert deserialized.duckdb_settings == {"TimeZone": "UTC", "threads": "4"}
177+
assert deserialized.settings == {"TimeZone": "UTC", "threads": "4"}
178178

179179
def test_none_settings_roundtrip(self) -> None:
180180
"""None settings should survive serialization."""
@@ -186,14 +186,14 @@ def test_none_settings_roundtrip(self) -> None:
186186
function_type=InvocationType.TABLE,
187187
correlation_id="test",
188188
invocation_id=b"test-id",
189-
duckdb_settings=None,
189+
settings=None,
190190
)
191191

192192
serialized = original.serialize()
193193
batch = pa.ipc.open_stream(pa.py_buffer(serialized)).read_all().to_batches()[0]
194194
deserialized = Invocation.deserialize(batch)
195195

196-
assert deserialized.duckdb_settings is None
196+
assert deserialized.settings is None
197197

198198

199199
class TestMetadataSerialization:

0 commit comments

Comments
 (0)