@query-farm/vgi 0.17.0 → 0.19.0
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.
- package/dist/arrow/impl-arrowjs/index.d.ts +1 -0
- package/dist/arrow/impl-arrowjs/metadata.d.ts +12 -0
- package/dist/arrow/impl-flechette/index.d.ts +1 -0
- package/dist/arrow/impl-flechette/metadata.d.ts +13 -0
- package/dist/arrow/index.d.ts +1 -1
- package/dist/catalog/descriptors.d.ts +13 -7
- package/dist/client-entry.js +16 -5
- package/dist/client-entry.js.map +9 -8
- package/dist/functions/scalar.d.ts +10 -0
- package/dist/functions/table-in-out.d.ts +121 -0
- package/dist/functions/types.d.ts +12 -0
- package/dist/generated/vgi-client.d.ts +3 -1
- package/dist/index.core.d.ts +1 -1
- package/dist/index.js +310 -21
- package/dist/index.js.map +16 -15
- package/dist/protocol/types.d.ts +12 -0
- package/dist/serve-entry.js +14 -4
- package/dist/serve-entry.js.map +8 -7
- package/dist/worker-cf-entry.js +188 -26
- package/dist/worker-cf-entry.js.map +14 -13
- package/dist/worker.d.ts +1 -1
- package/package.json +3 -3
- package/src/arrow/impl-arrowjs/index.ts +1 -0
- package/src/arrow/impl-arrowjs/metadata.ts +20 -0
- package/src/arrow/impl-flechette/index.ts +1 -0
- package/src/arrow/impl-flechette/metadata.ts +25 -0
- package/src/arrow/index.ts +2 -0
- package/src/catalog/descriptors.ts +13 -7
- package/src/catalog/read-only.ts +31 -14
- package/src/client/client.ts +1 -0
- package/src/functions/registry.ts +53 -5
- package/src/functions/scalar.ts +17 -1
- package/src/functions/table-in-out.ts +480 -4
- package/src/functions/types.ts +12 -0
- package/src/generated/vgi-client.ts +4 -2
- package/src/generated/vgi-protocol-schemas.ts +3 -2
- package/src/index.core.ts +11 -1
- package/src/protocol/serializers/init.ts +7 -0
- package/src/protocol/types.ts +12 -0
- package/src/worker.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1586,6 +1586,14 @@ function projectBatch(projectionIds, batch) {
|
|
|
1586
1586
|
}
|
|
1587
1587
|
var init_project = () => {};
|
|
1588
1588
|
|
|
1589
|
+
// src/arrow/impl-arrowjs/metadata.ts
|
|
1590
|
+
import { RecordBatch as RecordBatch4 } from "@query-farm/apache-arrow";
|
|
1591
|
+
function withBatchMetadata(batch, metadata) {
|
|
1592
|
+
const a = batch;
|
|
1593
|
+
return new RecordBatch4(a.schema, a.data, metadata);
|
|
1594
|
+
}
|
|
1595
|
+
var init_metadata = () => {};
|
|
1596
|
+
|
|
1589
1597
|
// src/arrow/impl-arrowjs/ipc.ts
|
|
1590
1598
|
import {
|
|
1591
1599
|
Schema as Schema4,
|
|
@@ -1634,7 +1642,7 @@ import {
|
|
|
1634
1642
|
Field as Field3,
|
|
1635
1643
|
Null,
|
|
1636
1644
|
makeData as makeData5,
|
|
1637
|
-
RecordBatch as
|
|
1645
|
+
RecordBatch as RecordBatch6,
|
|
1638
1646
|
Struct as Struct5,
|
|
1639
1647
|
SparseUnion,
|
|
1640
1648
|
Schema as Schema5,
|
|
@@ -1746,7 +1754,7 @@ function assemble(columnNames, minData, maxData, hasNull, hasNotNull, distinctCo
|
|
|
1746
1754
|
];
|
|
1747
1755
|
const structType = new Struct5(schema2.fields);
|
|
1748
1756
|
const data = makeData5({ type: structType, length: n, children, nullCount: 0 });
|
|
1749
|
-
return new
|
|
1757
|
+
return new RecordBatch6(schema2, data);
|
|
1750
1758
|
}
|
|
1751
1759
|
var init_statistics = __esm(() => {
|
|
1752
1760
|
init_registry();
|
|
@@ -1756,6 +1764,7 @@ var init_statistics = __esm(() => {
|
|
|
1756
1764
|
// src/arrow/impl-arrowjs/index.ts
|
|
1757
1765
|
var exports_impl_arrowjs = {};
|
|
1758
1766
|
__export(exports_impl_arrowjs, {
|
|
1767
|
+
withBatchMetadata: () => withBatchMetadata,
|
|
1759
1768
|
utf8: () => utf8,
|
|
1760
1769
|
union: () => union,
|
|
1761
1770
|
uint8: () => uint8,
|
|
@@ -1830,6 +1839,7 @@ var init_impl_arrowjs = __esm(() => {
|
|
|
1830
1839
|
init_filter();
|
|
1831
1840
|
init_project();
|
|
1832
1841
|
init_canonical();
|
|
1842
|
+
init_metadata();
|
|
1833
1843
|
init_ipc();
|
|
1834
1844
|
init_statistics();
|
|
1835
1845
|
backend = { name: "arrow-js" };
|
|
@@ -1928,6 +1938,7 @@ var init_branded = __esm(() => {
|
|
|
1928
1938
|
// src/arrow/index.ts
|
|
1929
1939
|
var exports_arrow = {};
|
|
1930
1940
|
__export(exports_arrow, {
|
|
1941
|
+
withBatchMetadata: () => withBatchMetadata,
|
|
1931
1942
|
utf8: () => utf82,
|
|
1932
1943
|
union: () => union2,
|
|
1933
1944
|
uint8: () => uint82,
|
|
@@ -3085,7 +3096,7 @@ function defineScalarFunction(config) {
|
|
|
3085
3096
|
if (outputBatch.numRows !== input.numRows) {
|
|
3086
3097
|
throw new RowCountMismatchError(input.numRows, outputBatch.numRows);
|
|
3087
3098
|
}
|
|
3088
|
-
out.emit(outputBatch);
|
|
3099
|
+
out.emit(outputBatch, config.cacheControl ? cacheControlMetadata(config.cacheControl) : undefined);
|
|
3089
3100
|
}
|
|
3090
3101
|
};
|
|
3091
3102
|
}
|
|
@@ -4544,7 +4555,8 @@ function defineTableInOutFunction(config) {
|
|
|
4544
4555
|
settings,
|
|
4545
4556
|
secrets,
|
|
4546
4557
|
pushdownFilters,
|
|
4547
|
-
storage: boundStorage
|
|
4558
|
+
storage: boundStorage,
|
|
4559
|
+
substreamId: request.substream_id ?? null
|
|
4548
4560
|
};
|
|
4549
4561
|
const phase = request.phase;
|
|
4550
4562
|
if (phase === "FINALIZE" /* FINALIZE */) {
|
|
@@ -4587,7 +4599,14 @@ function defineTableInOutFunction(config) {
|
|
|
4587
4599
|
inputSchema: request.bind_call.input_schema ?? undefined,
|
|
4588
4600
|
exchangeInit: () => ({ state, processParams }),
|
|
4589
4601
|
exchangeFn: async (eState, input, out) => {
|
|
4590
|
-
|
|
4602
|
+
applyRevalidationValidators(eState.processParams, input);
|
|
4603
|
+
let wrappedOut = makeMetadataBakingCollector(out);
|
|
4604
|
+
if (projIds) {
|
|
4605
|
+
wrappedOut = makeSchemaReconcilingCollector(wrappedOut, outputSchema);
|
|
4606
|
+
}
|
|
4607
|
+
if (config.autoApplyFilters && pushdownFilters) {
|
|
4608
|
+
wrappedOut = new FilteringOutputCollector(wrappedOut, pushdownFilters);
|
|
4609
|
+
}
|
|
4591
4610
|
await processFn(eState.processParams, eState.state, input, wrappedOut);
|
|
4592
4611
|
if (eState.state != null) {
|
|
4593
4612
|
const serialized = serializeUserState(eState.state);
|
|
@@ -4600,6 +4619,230 @@ function defineTableInOutFunction(config) {
|
|
|
4600
4619
|
}
|
|
4601
4620
|
};
|
|
4602
4621
|
}
|
|
4622
|
+
function applyRevalidationValidators(params, input) {
|
|
4623
|
+
const md = input?.metadata;
|
|
4624
|
+
params.ifNoneMatch = md?.get(CACHE_IF_NONE_MATCH_KEY);
|
|
4625
|
+
params.ifModifiedSince = md?.get(CACHE_IF_MODIFIED_SINCE_KEY);
|
|
4626
|
+
}
|
|
4627
|
+
function makeMetadataBakingCollector(inner) {
|
|
4628
|
+
return new Proxy(inner, {
|
|
4629
|
+
get(target, prop, receiver) {
|
|
4630
|
+
if (prop === "emit") {
|
|
4631
|
+
return function(batchOrColumns, metadata) {
|
|
4632
|
+
if (batchOrColumns && typeof batchOrColumns.getChild === "function" && metadata && metadata.size > 0) {
|
|
4633
|
+
const batch = batchOrColumns;
|
|
4634
|
+
const merged = new Map(batch.metadata ?? []);
|
|
4635
|
+
for (const [k, v2] of metadata)
|
|
4636
|
+
merged.set(k, v2);
|
|
4637
|
+
return target.emit(withBatchMetadata(batch, merged), merged);
|
|
4638
|
+
}
|
|
4639
|
+
return target.emit(batchOrColumns, metadata);
|
|
4640
|
+
};
|
|
4641
|
+
}
|
|
4642
|
+
const v = Reflect.get(target, prop, receiver);
|
|
4643
|
+
return typeof v === "function" ? v.bind(target) : v;
|
|
4644
|
+
}
|
|
4645
|
+
});
|
|
4646
|
+
}
|
|
4647
|
+
function makeSchemaReconcilingCollector(inner, targetSchema) {
|
|
4648
|
+
function reconcile(batch) {
|
|
4649
|
+
const batchFields = batch.schema.fields;
|
|
4650
|
+
if (batchFields.length === targetSchema.fields.length && targetSchema.fields.every((f, i) => batchFields[i].name === f.name)) {
|
|
4651
|
+
return batch;
|
|
4652
|
+
}
|
|
4653
|
+
const ids = [];
|
|
4654
|
+
for (const f of targetSchema.fields) {
|
|
4655
|
+
const idx = batchFields.findIndex((bf) => bf.name === f.name);
|
|
4656
|
+
if (idx < 0) {
|
|
4657
|
+
throw new Error(`emitted batch is missing projected output column '${f.name}' ` + `(emitted: [${batchFields.map((bf) => bf.name).join(", ")}])`);
|
|
4658
|
+
}
|
|
4659
|
+
ids.push(idx);
|
|
4660
|
+
}
|
|
4661
|
+
return projectBatch(ids, batch);
|
|
4662
|
+
}
|
|
4663
|
+
return new Proxy(inner, {
|
|
4664
|
+
get(target, prop, receiver) {
|
|
4665
|
+
if (prop === "emit") {
|
|
4666
|
+
return function(batchOrColumns, metadata) {
|
|
4667
|
+
if (batchOrColumns && typeof batchOrColumns.getChild === "function") {
|
|
4668
|
+
return target.emit(reconcile(batchOrColumns), metadata);
|
|
4669
|
+
}
|
|
4670
|
+
return target.emit(batchOrColumns, metadata);
|
|
4671
|
+
};
|
|
4672
|
+
}
|
|
4673
|
+
const v = Reflect.get(target, prop, receiver);
|
|
4674
|
+
return typeof v === "function" ? v.bind(target) : v;
|
|
4675
|
+
}
|
|
4676
|
+
});
|
|
4677
|
+
}
|
|
4678
|
+
var PARENT_ROW_METADATA_KEY = "vgi_rpc.parent_row#b64";
|
|
4679
|
+
function parentRowsMetadata(parentRows, outputRows, extra) {
|
|
4680
|
+
if (parentRows.length !== outputRows) {
|
|
4681
|
+
throw new Error(`parentRowsMetadata: length ${parentRows.length} != output rows ${outputRows}; ` + `parentRows must carry exactly one input-row index per emitted output row`);
|
|
4682
|
+
}
|
|
4683
|
+
const md = new Map(extra ?? []);
|
|
4684
|
+
if (outputRows === 0) {
|
|
4685
|
+
return md;
|
|
4686
|
+
}
|
|
4687
|
+
const raw = new Uint8Array(parentRows.length * 4);
|
|
4688
|
+
const dv = new DataView(raw.buffer);
|
|
4689
|
+
for (let i = 0;i < parentRows.length; i++) {
|
|
4690
|
+
dv.setInt32(i * 4, parentRows[i], true);
|
|
4691
|
+
}
|
|
4692
|
+
md.set(PARENT_ROW_METADATA_KEY, base64Encode(raw));
|
|
4693
|
+
return md;
|
|
4694
|
+
}
|
|
4695
|
+
function base64Encode(bytes) {
|
|
4696
|
+
if (typeof globalThis.Buffer !== "undefined") {
|
|
4697
|
+
return globalThis.Buffer.from(bytes).toString("base64");
|
|
4698
|
+
}
|
|
4699
|
+
let bin = "";
|
|
4700
|
+
for (let i = 0;i < bytes.length; i++)
|
|
4701
|
+
bin += String.fromCharCode(bytes[i]);
|
|
4702
|
+
return globalThis.btoa(bin);
|
|
4703
|
+
}
|
|
4704
|
+
function defineRowTransformFunction(config) {
|
|
4705
|
+
const numPositional = Object.keys(config.args ?? {}).length + (config.varargs ? 1 : 0);
|
|
4706
|
+
if (numPositional === 0) {
|
|
4707
|
+
throw new Error(`${config.name}: a blended row-transform function needs at least one ` + `positional arg (its per-row input column); found none.`);
|
|
4708
|
+
}
|
|
4709
|
+
const specs = [];
|
|
4710
|
+
let posIdx = 0;
|
|
4711
|
+
if (config.args) {
|
|
4712
|
+
for (const [name, type] of Object.entries(config.args)) {
|
|
4713
|
+
specs.push({
|
|
4714
|
+
name,
|
|
4715
|
+
position: posIdx++,
|
|
4716
|
+
arrowType: type,
|
|
4717
|
+
doc: config.argDocs?.[name]
|
|
4718
|
+
});
|
|
4719
|
+
}
|
|
4720
|
+
}
|
|
4721
|
+
if (config.varargs) {
|
|
4722
|
+
specs.push({
|
|
4723
|
+
name: config.varargs.name,
|
|
4724
|
+
position: posIdx++,
|
|
4725
|
+
arrowType: config.varargs.type,
|
|
4726
|
+
isVarargs: true,
|
|
4727
|
+
doc: config.varargs.doc ?? config.argDocs?.[config.varargs.name]
|
|
4728
|
+
});
|
|
4729
|
+
}
|
|
4730
|
+
if (config.namedArgs) {
|
|
4731
|
+
for (const [name, type] of Object.entries(config.namedArgs)) {
|
|
4732
|
+
specs.push({
|
|
4733
|
+
name,
|
|
4734
|
+
position: name,
|
|
4735
|
+
arrowType: type,
|
|
4736
|
+
doc: config.argDocs?.[name]
|
|
4737
|
+
});
|
|
4738
|
+
}
|
|
4739
|
+
}
|
|
4740
|
+
const meta = {
|
|
4741
|
+
name: config.name,
|
|
4742
|
+
description: config.description,
|
|
4743
|
+
stability: config.stability,
|
|
4744
|
+
projectionPushdown: config.projectionPushdown,
|
|
4745
|
+
filterPushdown: config.filterPushdown,
|
|
4746
|
+
autoApplyFilters: config.autoApplyFilters,
|
|
4747
|
+
examples: config.examples,
|
|
4748
|
+
categories: config.categories,
|
|
4749
|
+
tags: config.tags,
|
|
4750
|
+
maxWorkers: config.maxWorkers,
|
|
4751
|
+
requiredSettings: config.requiredSettings,
|
|
4752
|
+
requiredSecrets: config.requiredSecrets,
|
|
4753
|
+
hasFinalize: false,
|
|
4754
|
+
inputFromArgs: true
|
|
4755
|
+
};
|
|
4756
|
+
function extractArgs(request) {
|
|
4757
|
+
const args = {};
|
|
4758
|
+
for (const spec of specs) {
|
|
4759
|
+
if (typeof spec.position !== "string")
|
|
4760
|
+
continue;
|
|
4761
|
+
const defaultVal = config.argDefaults?.[spec.name] !== undefined ? config.argDefaults[spec.name] : undefined;
|
|
4762
|
+
let val = request.arguments.get(spec.position, defaultVal ?? null);
|
|
4763
|
+
if (typeof val === "bigint")
|
|
4764
|
+
val = Number(val);
|
|
4765
|
+
args[spec.name] = val;
|
|
4766
|
+
}
|
|
4767
|
+
return args;
|
|
4768
|
+
}
|
|
4769
|
+
return {
|
|
4770
|
+
kind: "table_in_out",
|
|
4771
|
+
meta,
|
|
4772
|
+
argumentSpecs: specs,
|
|
4773
|
+
async bind(request) {
|
|
4774
|
+
const args = extractArgs(request);
|
|
4775
|
+
const settings = batchToScalarDict(request.settings);
|
|
4776
|
+
const secrets = batchToSecretDict(request.secrets);
|
|
4777
|
+
const result = await config.onBind({
|
|
4778
|
+
args,
|
|
4779
|
+
bindCall: request,
|
|
4780
|
+
settings,
|
|
4781
|
+
secrets
|
|
4782
|
+
});
|
|
4783
|
+
return {
|
|
4784
|
+
output_schema: result.outputSchema,
|
|
4785
|
+
opaque_data: result.opaqueData ?? null
|
|
4786
|
+
};
|
|
4787
|
+
},
|
|
4788
|
+
async globalInit(request) {
|
|
4789
|
+
if (request.execution_id) {
|
|
4790
|
+
return {
|
|
4791
|
+
max_workers: DEFAULT_MAX_WORKERS,
|
|
4792
|
+
execution_id: request.execution_id,
|
|
4793
|
+
opaque_data: null
|
|
4794
|
+
};
|
|
4795
|
+
}
|
|
4796
|
+
const executionId = new Uint8Array(16);
|
|
4797
|
+
crypto.getRandomValues(executionId);
|
|
4798
|
+
return {
|
|
4799
|
+
max_workers: config.maxWorkers ?? 1,
|
|
4800
|
+
execution_id: executionId,
|
|
4801
|
+
opaque_data: null
|
|
4802
|
+
};
|
|
4803
|
+
},
|
|
4804
|
+
createStreamHandlers(request, response, _accumulatedState) {
|
|
4805
|
+
const args = extractArgs(request.bind_call);
|
|
4806
|
+
const settings = batchToScalarDict(request.bind_call.settings);
|
|
4807
|
+
const secrets = batchToSecretDict(request.bind_call.secrets);
|
|
4808
|
+
const projIds = request.projection_ids && meta.projectionPushdown ? request.projection_ids : null;
|
|
4809
|
+
const outputSchema = projIds ? projectSchema(projIds, request.output_schema) : request.output_schema;
|
|
4810
|
+
const joinKeysLookup = buildJoinKeysLookup(request.join_keys);
|
|
4811
|
+
const pushdownFilters = request.pushdown_filters ? deserializeFilters(request.pushdown_filters, joinKeysLookup) : undefined;
|
|
4812
|
+
const boundStorage = new BoundStorage(storage, response.execution_id ?? new Uint8Array(16));
|
|
4813
|
+
const processParams = {
|
|
4814
|
+
args,
|
|
4815
|
+
initCall: request,
|
|
4816
|
+
initResponse: response,
|
|
4817
|
+
outputSchema,
|
|
4818
|
+
settings,
|
|
4819
|
+
secrets,
|
|
4820
|
+
pushdownFilters,
|
|
4821
|
+
storage: boundStorage,
|
|
4822
|
+
substreamId: request.substream_id ?? null
|
|
4823
|
+
};
|
|
4824
|
+
if (request.phase === "FINALIZE" /* FINALIZE */) {
|
|
4825
|
+
throw new Error(`${config.name}: a blended row-transform function has no FINALIZE ` + `phase (it is a per-row map; has_finalize is advertised false).`);
|
|
4826
|
+
}
|
|
4827
|
+
return {
|
|
4828
|
+
outputSchema,
|
|
4829
|
+
inputSchema: request.bind_call.input_schema ?? undefined,
|
|
4830
|
+
exchangeInit: () => ({ state: null, processParams }),
|
|
4831
|
+
exchangeFn: async (eState, input, out) => {
|
|
4832
|
+
applyRevalidationValidators(eState.processParams, input);
|
|
4833
|
+
let wrappedOut = makeMetadataBakingCollector(out);
|
|
4834
|
+
if (projIds) {
|
|
4835
|
+
wrappedOut = makeSchemaReconcilingCollector(wrappedOut, outputSchema);
|
|
4836
|
+
}
|
|
4837
|
+
if (config.autoApplyFilters && pushdownFilters) {
|
|
4838
|
+
wrappedOut = new FilteringOutputCollector(wrappedOut, pushdownFilters);
|
|
4839
|
+
}
|
|
4840
|
+
await config.process(eState.processParams, input, wrappedOut);
|
|
4841
|
+
}
|
|
4842
|
+
};
|
|
4843
|
+
}
|
|
4844
|
+
};
|
|
4845
|
+
}
|
|
4603
4846
|
// src/functions/table-buffering.ts
|
|
4604
4847
|
init_arrow();
|
|
4605
4848
|
init_arrow();
|
|
@@ -4961,6 +5204,7 @@ var INIT_REQUEST_SCHEMA = schema2([
|
|
|
4961
5204
|
field2("phase", utf82(), true),
|
|
4962
5205
|
field2("execution_id", binary2(), true),
|
|
4963
5206
|
field2("init_opaque_data", binary2(), true),
|
|
5207
|
+
field2("substream_id", binary2(), true),
|
|
4964
5208
|
field2("order_by_column_name", utf82(), true),
|
|
4965
5209
|
field2("order_by_direction", utf82(), true),
|
|
4966
5210
|
field2("order_by_null_order", utf82(), true),
|
|
@@ -4987,6 +5231,7 @@ function serializeInitRequest(req) {
|
|
|
4987
5231
|
phase: req.phase ?? null,
|
|
4988
5232
|
execution_id: req.execution_id ?? null,
|
|
4989
5233
|
init_opaque_data: req.init_opaque_data ?? null,
|
|
5234
|
+
substream_id: req.substream_id ?? null,
|
|
4990
5235
|
order_by_column_name: req.order_by_column_name ?? null,
|
|
4991
5236
|
order_by_direction: req.order_by_direction ?? null,
|
|
4992
5237
|
order_by_null_order: req.order_by_null_order ?? null,
|
|
@@ -5048,6 +5293,7 @@ function deserializeInitRequest(params) {
|
|
|
5048
5293
|
finalize_state_id: params.finalize_state_id ? toUint8Array2(params.finalize_state_id) : null,
|
|
5049
5294
|
execution_id: params.execution_id ? toUint8Array2(params.execution_id) : null,
|
|
5050
5295
|
init_opaque_data: params.init_opaque_data ? toUint8Array2(params.init_opaque_data) : null,
|
|
5296
|
+
substream_id: params.substream_id ? toUint8Array2(params.substream_id) : null,
|
|
5051
5297
|
order_by_column_name: parseEnum(decodeDictValue(params.order_by_column_name)) ?? null,
|
|
5052
5298
|
order_by_direction: parseDirection(decodeDictValue(params.order_by_direction)),
|
|
5053
5299
|
order_by_null_order: parseNullOrder(decodeDictValue(params.order_by_null_order)),
|
|
@@ -5796,7 +6042,7 @@ var TableInfoSchema = schema2([
|
|
|
5796
6042
|
field2("cardinality_max", int642(), false),
|
|
5797
6043
|
field2("column_statistics", binary2(), false),
|
|
5798
6044
|
field2("bind_result", binary2(), false),
|
|
5799
|
-
field2("
|
|
6045
|
+
field2("required_filters", list2(field2("item", list2(field2("item", utf82(), true)), true)), false)
|
|
5800
6046
|
]);
|
|
5801
6047
|
var ViewInfoSchema = schema2([
|
|
5802
6048
|
field2("comment", utf82(), true),
|
|
@@ -5836,6 +6082,7 @@ var FunctionInfoSchema = schema2([
|
|
|
5836
6082
|
field2("source_order_dependent", bool2(), false),
|
|
5837
6083
|
field2("sink_order_dependent", bool2(), false),
|
|
5838
6084
|
field2("requires_input_batch_index", bool2(), false),
|
|
6085
|
+
field2("input_from_args", bool2(), false),
|
|
5839
6086
|
field2("required_settings", list2(field2("item", utf82(), true)), false),
|
|
5840
6087
|
field2("required_secrets", list2(field2("item", struct2([field2("secret_type", utf82(), false), field2("scope", utf82(), true), field2("secret_name", utf82(), true)]), true)), false)
|
|
5841
6088
|
]);
|
|
@@ -6868,16 +7115,21 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
6868
7115
|
const uniqueIndices = resolveIndexGroups(colSchema, t.unique);
|
|
6869
7116
|
const pkIndices = resolveIndexGroups(colSchema, t.primaryKey);
|
|
6870
7117
|
const fkBytes = serializeForeignKeys(t.foreignKey, name);
|
|
6871
|
-
const
|
|
6872
|
-
if (
|
|
7118
|
+
const requiredFilters = t.requiredFilters ?? [];
|
|
7119
|
+
if (requiredFilters.length > 0) {
|
|
6873
7120
|
const columnNames = new Set(colSchema.fields.map((f) => f.name));
|
|
6874
|
-
for (const
|
|
6875
|
-
if (!
|
|
6876
|
-
throw new Error(`Table '${t.name}':
|
|
7121
|
+
for (const group of requiredFilters) {
|
|
7122
|
+
if (!group || group.length === 0) {
|
|
7123
|
+
throw new Error(`Table '${t.name}': requiredFilters must not contain empty groups`);
|
|
6877
7124
|
}
|
|
6878
|
-
const
|
|
6879
|
-
|
|
6880
|
-
|
|
7125
|
+
for (const path2 of group) {
|
|
7126
|
+
if (!path2) {
|
|
7127
|
+
throw new Error(`Table '${t.name}': requiredFilters must not contain empty strings`);
|
|
7128
|
+
}
|
|
7129
|
+
const head = path2.split(".", 1)[0];
|
|
7130
|
+
if (!columnNames.has(head)) {
|
|
7131
|
+
throw new Error(`Table '${t.name}': requiredFilters path '${path2}' references ` + `unknown column '${head}'. Available columns: ${[...columnNames].sort().join(", ")}`);
|
|
7132
|
+
}
|
|
6881
7133
|
}
|
|
6882
7134
|
}
|
|
6883
7135
|
}
|
|
@@ -6903,7 +7155,7 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
6903
7155
|
delete_function: null,
|
|
6904
7156
|
cardinality_estimate: t.inlinedCardinality ? Number(t.inlinedCardinality.estimate) : null,
|
|
6905
7157
|
cardinality_max: t.inlinedCardinality ? Number(t.inlinedCardinality.max) : null,
|
|
6906
|
-
|
|
7158
|
+
required_filters: requiredFilters
|
|
6907
7159
|
};
|
|
6908
7160
|
}));
|
|
6909
7161
|
}
|
|
@@ -6990,6 +7242,7 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
6990
7242
|
source_order_dependent: f.kind === "table_buffering" && f.meta.sourceOrderDependent === true,
|
|
6991
7243
|
sink_order_dependent: f.kind === "table_buffering" && f.meta.sinkOrderDependent === true,
|
|
6992
7244
|
requires_input_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true,
|
|
7245
|
+
input_from_args: f.kind === "table_in_out" && f.meta.inputFromArgs === true,
|
|
6993
7246
|
required_settings: meta.requiredSettings,
|
|
6994
7247
|
required_secrets: requiredSecrets.map((s) => ({
|
|
6995
7248
|
secret_type: s.secret_type,
|
|
@@ -7534,10 +7787,27 @@ function filterByArgumentTypes(candidates, args, inputSchema, isScalar) {
|
|
|
7534
7787
|
} else {
|
|
7535
7788
|
const posSpecs = specs.filter((s) => typeof s.position === "number" && !s.isTableInput).sort((a, b) => a.position - b.position);
|
|
7536
7789
|
const posTypes = [];
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7790
|
+
if (func.meta.inputFromArgs) {
|
|
7791
|
+
if (inputSchema) {
|
|
7792
|
+
let varArgsSpec = null;
|
|
7793
|
+
for (const spec of posSpecs) {
|
|
7794
|
+
if (spec.isVarargs)
|
|
7795
|
+
varArgsSpec = spec;
|
|
7796
|
+
const pos = spec.position;
|
|
7797
|
+
posTypes.push(pos < inputSchema.fields.length ? inputSchema.fields[pos].type : null);
|
|
7798
|
+
}
|
|
7799
|
+
if (varArgsSpec) {
|
|
7800
|
+
for (let i = varArgsSpec.position + 1;i < inputSchema.fields.length; i++) {
|
|
7801
|
+
posTypes.push(inputSchema.fields[i].type);
|
|
7802
|
+
}
|
|
7803
|
+
}
|
|
7804
|
+
}
|
|
7805
|
+
} else {
|
|
7806
|
+
const argsSchema = args.argumentsSchema;
|
|
7807
|
+
for (let i = 0;i < args.positional.length; i++) {
|
|
7808
|
+
const field3 = argsSchema?.fields.find((f) => f.name === `positional_${i}`);
|
|
7809
|
+
posTypes.push(field3 ? field3.type : null);
|
|
7810
|
+
}
|
|
7541
7811
|
}
|
|
7542
7812
|
const r = scoreTypes(posSpecs, posTypes);
|
|
7543
7813
|
score += r.score;
|
|
@@ -7596,6 +7866,21 @@ class FunctionRegistry {
|
|
|
7596
7866
|
const posSpecs = func.argumentSpecs.filter((s) => typeof s.position === "number" && !s.isTableInput);
|
|
7597
7867
|
const hasVarargs = posSpecs.some((s) => s.isVarargs);
|
|
7598
7868
|
const nonVarargs = posSpecs.filter((s) => !s.isVarargs).length;
|
|
7869
|
+
if (func.meta.inputFromArgs) {
|
|
7870
|
+
const numInputCols = context.inputSchema?.fields.length ?? 0;
|
|
7871
|
+
if (hasVarargs) {
|
|
7872
|
+
if (numInputCols < nonVarargs)
|
|
7873
|
+
return false;
|
|
7874
|
+
} else if (numInputCols !== posSpecs.length) {
|
|
7875
|
+
return false;
|
|
7876
|
+
}
|
|
7877
|
+
const validNamed = new Set(func.argumentSpecs.filter((s) => typeof s.position === "string").map((s) => s.position));
|
|
7878
|
+
for (const key of args.named.keys()) {
|
|
7879
|
+
if (!validNamed.has(key))
|
|
7880
|
+
return false;
|
|
7881
|
+
}
|
|
7882
|
+
return true;
|
|
7883
|
+
}
|
|
7599
7884
|
if (hasVarargs) {
|
|
7600
7885
|
return numArgs >= nonVarargs;
|
|
7601
7886
|
}
|
|
@@ -10657,7 +10942,8 @@ class VgiClient {
|
|
|
10657
10942
|
tablesample_percentage: ts?.percentage ?? null,
|
|
10658
10943
|
tablesample_seed: ts?.seed == null ? null : BigInt(ts.seed),
|
|
10659
10944
|
execution_id: opts?.executionId ?? null,
|
|
10660
|
-
init_opaque_data: null
|
|
10945
|
+
init_opaque_data: null,
|
|
10946
|
+
substream_id: null
|
|
10661
10947
|
};
|
|
10662
10948
|
const initBatch = serializeInitRequest(initRequest);
|
|
10663
10949
|
const session = await this.rpc.stream("init", wrapRequest(initBatch));
|
|
@@ -11505,6 +11791,7 @@ export {
|
|
|
11505
11791
|
readCanonicalValue,
|
|
11506
11792
|
projectSchema,
|
|
11507
11793
|
projectBatch,
|
|
11794
|
+
parentRowsMetadata,
|
|
11508
11795
|
nullType2 as nullType,
|
|
11509
11796
|
metadatasToArrow,
|
|
11510
11797
|
map2 as map,
|
|
@@ -11576,6 +11863,7 @@ export {
|
|
|
11576
11863
|
defineTableFunction,
|
|
11577
11864
|
defineTableBufferingFunction,
|
|
11578
11865
|
defineScalarFunction,
|
|
11866
|
+
defineRowTransformFunction,
|
|
11579
11867
|
defineCopyToFunction,
|
|
11580
11868
|
defineCopyFromFunction,
|
|
11581
11869
|
defineAggregate,
|
|
@@ -11643,6 +11931,7 @@ export {
|
|
|
11643
11931
|
RowCountMismatchError,
|
|
11644
11932
|
ReadOnlyCatalogInterface,
|
|
11645
11933
|
PushdownFilters,
|
|
11934
|
+
PARENT_ROW_METADATA_KEY,
|
|
11646
11935
|
OutputCollector,
|
|
11647
11936
|
OrderPreservation,
|
|
11648
11937
|
OrderDependence,
|
|
@@ -11691,4 +11980,4 @@ export {
|
|
|
11691
11980
|
ArgumentValidationError
|
|
11692
11981
|
};
|
|
11693
11982
|
|
|
11694
|
-
//# debugId=
|
|
11983
|
+
//# debugId=8787F3CC30C0C60C64756E2164756E21
|