@query-farm/vgi 0.25.1 → 0.25.2
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createVgiFetch } from "./http/fetch.js";
|
|
2
2
|
export type { VgiFetchOptions } from "./http/fetch.js";
|
|
3
|
-
export { defineScalarFunction, defineTableFunction, defineAggregate, defineTableInOutFunction, FunctionRegistry, ReadOnlyCatalogInterface, CompositeCatalogInterface, CatalogInterface, Arguments, FunctionType, serializeAttachOptionSpec, serializeAttachOptionSpecs, serializeColumnStatistics, BindResultSchema, ScanFunctionResultSchema, } from "./index.core.js";
|
|
4
|
-
export type { AttachOptionSpec, ColumnStatistics, CatalogAttachResult, CatalogDescriptor, CatalogInfo, TableInfo, AttachOpaqueData, TransactionOpaqueData, SchemaInfo, VgiFunction, TableProcessParams, } from "./index.core.js";
|
|
3
|
+
export { defineScalarFunction, defineTableFunction, defineAggregate, defineTableInOutFunction, defineRowTransformFunction, parentRowsMetadata, PARENT_ROW_METADATA_KEY, constraintSpecFields, FunctionRegistry, ReadOnlyCatalogInterface, CompositeCatalogInterface, CatalogInterface, Arguments, FunctionType, serializeAttachOptionSpec, serializeAttachOptionSpecs, serializeColumnStatistics, BindResultSchema, ScanFunctionResultSchema, } from "./index.core.js";
|
|
4
|
+
export type { AttachOptionSpec, ColumnStatistics, CatalogAttachResult, CatalogDescriptor, CatalogInfo, TableInfo, AttachOpaqueData, TransactionOpaqueData, SchemaInfo, VgiFunction, TableProcessParams, ArgumentSpec, ArgumentConstraints, RowTransformConfig, RowTransformProcessParams, TableInOutBindParams, } from "./index.core.js";
|
|
5
5
|
export type { ProtocolConfig } from "./protocol/dispatch.js";
|
|
6
6
|
export type { LandingInfo } from "@query-farm/vgi-rpc";
|
|
7
7
|
export { TypeId, isNull, isInt, isFloat, isBinary, isUtf8, isBool, isDecimal, isDate, isTime, isTimestamp, isInterval, isList, isStruct, isUnion, isFixedSizeBinary, isFixedSizeList, isMap, isDuration, isDictionary, isBatch, backend, schema, field, nullType, bool, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, utf8, binary, fixedSizeBinary, decimal, decimal128, decimal256, date, dateDay, dateMillisecond, time, timeSecond, timeMillisecond, timeMicrosecond, timeNanosecond, timestamp, duration, interval, list, fixedSizeList, struct, map, dictionary, union, sparseUnion, denseUnion, TimeUnit, DateUnit, IntervalUnit, UnionMode, emptyBatch, batchFromRows, batchFromColumns, columnFromArray, iterRows, batchToScalarDict, batchToSecretDict, safeNumber, decodeDictValue, filterBatch, projectSchema, projectBatch, serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, buildStatisticsBatch, } from "./arrow/index.js";
|
package/dist/worker-cf-entry.js
CHANGED
|
@@ -8026,6 +8026,174 @@ function makeSchemaReconcilingCollector(inner, targetSchema) {
|
|
|
8026
8026
|
}
|
|
8027
8027
|
});
|
|
8028
8028
|
}
|
|
8029
|
+
var PARENT_ROW_METADATA_KEY = "vgi_rpc.parent_row#b64";
|
|
8030
|
+
function parentRowsMetadata(parentRows, outputRows, extra) {
|
|
8031
|
+
if (parentRows.length !== outputRows) {
|
|
8032
|
+
throw new Error(`parentRowsMetadata: length ${parentRows.length} != output rows ${outputRows}; ` + `parentRows must carry exactly one input-row index per emitted output row`);
|
|
8033
|
+
}
|
|
8034
|
+
const md = new Map(extra ?? []);
|
|
8035
|
+
if (outputRows === 0) {
|
|
8036
|
+
return md;
|
|
8037
|
+
}
|
|
8038
|
+
const raw = new Uint8Array(parentRows.length * 4);
|
|
8039
|
+
const dv = new DataView(raw.buffer);
|
|
8040
|
+
for (let i = 0;i < parentRows.length; i++) {
|
|
8041
|
+
dv.setInt32(i * 4, parentRows[i], true);
|
|
8042
|
+
}
|
|
8043
|
+
md.set(PARENT_ROW_METADATA_KEY, base64Encode(raw));
|
|
8044
|
+
return md;
|
|
8045
|
+
}
|
|
8046
|
+
function base64Encode(bytes) {
|
|
8047
|
+
if (typeof globalThis.Buffer !== "undefined") {
|
|
8048
|
+
return globalThis.Buffer.from(bytes).toString("base64");
|
|
8049
|
+
}
|
|
8050
|
+
let bin = "";
|
|
8051
|
+
for (let i = 0;i < bytes.length; i++)
|
|
8052
|
+
bin += String.fromCharCode(bytes[i]);
|
|
8053
|
+
return globalThis.btoa(bin);
|
|
8054
|
+
}
|
|
8055
|
+
function defineRowTransformFunction(config) {
|
|
8056
|
+
const numPositional = Object.keys(config.args ?? {}).length + (config.varargs ? 1 : 0);
|
|
8057
|
+
if (numPositional === 0) {
|
|
8058
|
+
throw new Error(`${config.name}: a blended row-transform function needs at least one ` + `positional arg (its per-row input column); found none.`);
|
|
8059
|
+
}
|
|
8060
|
+
const specs = [];
|
|
8061
|
+
let posIdx = 0;
|
|
8062
|
+
if (config.args) {
|
|
8063
|
+
for (const [name, type] of Object.entries(config.args)) {
|
|
8064
|
+
specs.push({
|
|
8065
|
+
name,
|
|
8066
|
+
position: posIdx++,
|
|
8067
|
+
arrowType: type,
|
|
8068
|
+
doc: config.argDocs?.[name]
|
|
8069
|
+
});
|
|
8070
|
+
}
|
|
8071
|
+
}
|
|
8072
|
+
if (config.varargs) {
|
|
8073
|
+
specs.push({
|
|
8074
|
+
name: config.varargs.name,
|
|
8075
|
+
position: posIdx++,
|
|
8076
|
+
arrowType: config.varargs.type,
|
|
8077
|
+
isVarargs: true,
|
|
8078
|
+
doc: config.varargs.doc ?? config.argDocs?.[config.varargs.name]
|
|
8079
|
+
});
|
|
8080
|
+
}
|
|
8081
|
+
if (config.namedArgs) {
|
|
8082
|
+
for (const [name, type] of Object.entries(config.namedArgs)) {
|
|
8083
|
+
specs.push({
|
|
8084
|
+
name,
|
|
8085
|
+
position: name,
|
|
8086
|
+
arrowType: type,
|
|
8087
|
+
doc: config.argDocs?.[name]
|
|
8088
|
+
});
|
|
8089
|
+
}
|
|
8090
|
+
}
|
|
8091
|
+
const meta = {
|
|
8092
|
+
name: config.name,
|
|
8093
|
+
description: config.description,
|
|
8094
|
+
stability: config.stability,
|
|
8095
|
+
projectionPushdown: config.projectionPushdown,
|
|
8096
|
+
filterPushdown: config.filterPushdown,
|
|
8097
|
+
autoApplyFilters: config.autoApplyFilters,
|
|
8098
|
+
examples: config.examples,
|
|
8099
|
+
categories: config.categories,
|
|
8100
|
+
tags: config.tags,
|
|
8101
|
+
maxWorkers: config.maxWorkers,
|
|
8102
|
+
requiredSettings: config.requiredSettings,
|
|
8103
|
+
requiredSecrets: config.requiredSecrets,
|
|
8104
|
+
hasFinalize: false,
|
|
8105
|
+
inputFromArgs: true
|
|
8106
|
+
};
|
|
8107
|
+
function extractArgs(request) {
|
|
8108
|
+
const args = {};
|
|
8109
|
+
for (const spec of specs) {
|
|
8110
|
+
if (typeof spec.position !== "string")
|
|
8111
|
+
continue;
|
|
8112
|
+
const defaultVal = config.argDefaults?.[spec.name] !== undefined ? config.argDefaults[spec.name] : undefined;
|
|
8113
|
+
let val = request.arguments.get(spec.position, defaultVal ?? null);
|
|
8114
|
+
if (typeof val === "bigint")
|
|
8115
|
+
val = Number(val);
|
|
8116
|
+
args[spec.name] = val;
|
|
8117
|
+
}
|
|
8118
|
+
return args;
|
|
8119
|
+
}
|
|
8120
|
+
return {
|
|
8121
|
+
kind: "table_in_out",
|
|
8122
|
+
meta,
|
|
8123
|
+
argumentSpecs: specs,
|
|
8124
|
+
async bind(request) {
|
|
8125
|
+
const args = extractArgs(request);
|
|
8126
|
+
const settings = batchToScalarDict(request.settings);
|
|
8127
|
+
const secrets = batchToSecretDict(request.secrets);
|
|
8128
|
+
const result = await config.onBind({
|
|
8129
|
+
args,
|
|
8130
|
+
bindCall: request,
|
|
8131
|
+
settings,
|
|
8132
|
+
secrets
|
|
8133
|
+
});
|
|
8134
|
+
return {
|
|
8135
|
+
output_schema: result.outputSchema,
|
|
8136
|
+
opaque_data: result.opaqueData ?? null
|
|
8137
|
+
};
|
|
8138
|
+
},
|
|
8139
|
+
async globalInit(request) {
|
|
8140
|
+
if (request.execution_id) {
|
|
8141
|
+
return {
|
|
8142
|
+
max_workers: DEFAULT_MAX_WORKERS,
|
|
8143
|
+
execution_id: request.execution_id,
|
|
8144
|
+
opaque_data: null
|
|
8145
|
+
};
|
|
8146
|
+
}
|
|
8147
|
+
const executionId = new Uint8Array(16);
|
|
8148
|
+
crypto.getRandomValues(executionId);
|
|
8149
|
+
return {
|
|
8150
|
+
max_workers: config.maxWorkers ?? 1,
|
|
8151
|
+
execution_id: executionId,
|
|
8152
|
+
opaque_data: null
|
|
8153
|
+
};
|
|
8154
|
+
},
|
|
8155
|
+
createStreamHandlers(request, response, _accumulatedState) {
|
|
8156
|
+
const args = extractArgs(request.bind_call);
|
|
8157
|
+
const settings = batchToScalarDict(request.bind_call.settings);
|
|
8158
|
+
const secrets = batchToSecretDict(request.bind_call.secrets);
|
|
8159
|
+
const projIds = request.projection_ids && meta.projectionPushdown ? request.projection_ids : null;
|
|
8160
|
+
const outputSchema = projIds ? projectSchema(projIds, request.output_schema) : request.output_schema;
|
|
8161
|
+
const joinKeysLookup = buildJoinKeysLookup(request.join_keys);
|
|
8162
|
+
const pushdownFilters = request.pushdown_filters ? deserializeFilters(request.pushdown_filters, joinKeysLookup) : undefined;
|
|
8163
|
+
const boundStorage = new BoundStorage(storage, response.execution_id ?? new Uint8Array(16));
|
|
8164
|
+
const processParams = {
|
|
8165
|
+
args,
|
|
8166
|
+
initCall: request,
|
|
8167
|
+
initResponse: response,
|
|
8168
|
+
outputSchema,
|
|
8169
|
+
settings,
|
|
8170
|
+
secrets,
|
|
8171
|
+
pushdownFilters,
|
|
8172
|
+
storage: boundStorage,
|
|
8173
|
+
substreamId: request.substream_id ?? null
|
|
8174
|
+
};
|
|
8175
|
+
if (request.phase === "FINALIZE" /* FINALIZE */) {
|
|
8176
|
+
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).`);
|
|
8177
|
+
}
|
|
8178
|
+
return {
|
|
8179
|
+
outputSchema,
|
|
8180
|
+
inputSchema: request.bind_call.input_schema ?? undefined,
|
|
8181
|
+
exchangeInit: () => ({ state: null, processParams }),
|
|
8182
|
+
exchangeFn: async (eState, input, out) => {
|
|
8183
|
+
applyRevalidationValidators(eState.processParams, input);
|
|
8184
|
+
let wrappedOut = makeMetadataBakingCollector(out);
|
|
8185
|
+
if (projIds) {
|
|
8186
|
+
wrappedOut = makeSchemaReconcilingCollector(wrappedOut, outputSchema);
|
|
8187
|
+
}
|
|
8188
|
+
if (config.autoApplyFilters && pushdownFilters) {
|
|
8189
|
+
wrappedOut = new FilteringOutputCollector(wrappedOut, pushdownFilters);
|
|
8190
|
+
}
|
|
8191
|
+
await config.process(eState.processParams, input, wrappedOut);
|
|
8192
|
+
}
|
|
8193
|
+
};
|
|
8194
|
+
}
|
|
8195
|
+
};
|
|
8196
|
+
}
|
|
8029
8197
|
// src/catalog/read-only.ts
|
|
8030
8198
|
init_arrow();
|
|
8031
8199
|
|
|
@@ -9244,6 +9412,7 @@ export {
|
|
|
9244
9412
|
safeNumber,
|
|
9245
9413
|
projectSchema,
|
|
9246
9414
|
projectBatch,
|
|
9415
|
+
parentRowsMetadata,
|
|
9247
9416
|
nullType2 as nullType,
|
|
9248
9417
|
map2 as map,
|
|
9249
9418
|
list2 as list,
|
|
@@ -9290,6 +9459,7 @@ export {
|
|
|
9290
9459
|
defineTableInOutFunction,
|
|
9291
9460
|
defineTableFunction,
|
|
9292
9461
|
defineScalarFunction,
|
|
9462
|
+
defineRowTransformFunction,
|
|
9293
9463
|
defineAggregate,
|
|
9294
9464
|
decodeDictValue,
|
|
9295
9465
|
decimal2562 as decimal256,
|
|
@@ -9299,6 +9469,7 @@ export {
|
|
|
9299
9469
|
dateDay2 as dateDay,
|
|
9300
9470
|
date2 as date,
|
|
9301
9471
|
createVgiFetch,
|
|
9472
|
+
constraintSpecFields,
|
|
9302
9473
|
columnFromArray,
|
|
9303
9474
|
buildStatisticsBatch,
|
|
9304
9475
|
bool2 as bool,
|
|
@@ -9314,6 +9485,7 @@ export {
|
|
|
9314
9485
|
TimeUnit2 as TimeUnit,
|
|
9315
9486
|
ScanFunctionResultSchema,
|
|
9316
9487
|
ReadOnlyCatalogInterface,
|
|
9488
|
+
PARENT_ROW_METADATA_KEY,
|
|
9317
9489
|
OutputCollector2 as OutputCollector,
|
|
9318
9490
|
IntervalUnit2 as IntervalUnit,
|
|
9319
9491
|
FunctionType,
|
|
@@ -9327,4 +9499,4 @@ export {
|
|
|
9327
9499
|
Arguments
|
|
9328
9500
|
};
|
|
9329
9501
|
|
|
9330
|
-
//# debugId=
|
|
9502
|
+
//# debugId=372B5FB94FE209FC64756E2164756E21
|