@query-farm/vgi 0.22.0 → 0.24.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.
@@ -322,6 +322,8 @@ export interface CatalogAttachResult {
322
322
  comment?: string | null;
323
323
  tags: Record<string, string>;
324
324
  supports_column_statistics: boolean;
325
+ global_functions: Uint8Array[];
326
+ global_function_prefix: string;
325
327
  resolved_data_version?: string | null;
326
328
  resolved_implementation_version?: string | null;
327
329
  }
package/dist/index.js CHANGED
@@ -6242,6 +6242,8 @@ var CatalogAttachResultSchema = schema2([
6242
6242
  field2("comment", utf82(), true),
6243
6243
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
6244
6244
  field2("supports_column_statistics", bool2(), false),
6245
+ field2("global_functions", list2(field2("item", binary2(), true)), false),
6246
+ field2("global_function_prefix", utf82(), false),
6245
6247
  field2("resolved_data_version", utf82(), true),
6246
6248
  field2("resolved_implementation_version", utf82(), true)
6247
6249
  ]);
@@ -7080,6 +7082,8 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
7080
7082
  comment: this._descriptor.comment ?? null,
7081
7083
  tags: this._descriptor.tags ?? {},
7082
7084
  supports_column_statistics: true,
7085
+ global_functions: this._globalFunctionInfos().map(encodeFunctionInfo),
7086
+ global_function_prefix: this._descriptor.globalFunctionPrefix ?? "",
7083
7087
  resolved_data_version: null,
7084
7088
  resolved_implementation_version: null
7085
7089
  };
@@ -7266,56 +7270,76 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
7266
7270
  if (t === "AGGREGATE_FUNCTION")
7267
7271
  return f.kind === "aggregate";
7268
7272
  return true;
7269
- }).map((f) => {
7270
- const meta = resolveMetadata(f);
7271
- const argSchema = argumentSpecsToSchema(f.argumentSpecs);
7272
- const argBytes = serializeSchema(argSchema);
7273
- const outputSchemaBytes = serializeSchema(f.defaultOutputSchema ?? schema2([]));
7274
- const requiredSecrets = (meta.requiredSecrets ?? []).map((secretType) => ({ secret_type: secretType, scope: null, secret_name: null }));
7275
- const derivedTags = {};
7276
- const tags = { ...derivedTags, ...meta.tags ?? {} };
7277
- return {
7278
- comment: null,
7279
- tags,
7280
- name: f.meta.name,
7281
- schema_name: name,
7282
- function_type: meta.functionType.toUpperCase(),
7283
- arguments: argBytes,
7284
- output_schema: outputSchemaBytes,
7285
- stability: meta.stability,
7286
- null_handling: meta.nullHandling,
7287
- description: meta.description,
7288
- examples: meta.examples.map((e) => ({
7289
- sql: e.sql,
7290
- description: e.description,
7291
- expected_output: null
7292
- })),
7293
- categories: meta.categories,
7294
- projection_pushdown: meta.projectionPushdown,
7295
- filter_pushdown: meta.filterPushdown,
7296
- sampling_pushdown: meta.samplingPushdown,
7297
- late_materialization: f.kind === "table" && f.meta.lateMaterialization === true ? true : null,
7298
- supported_expression_filters: meta.supportedExpressionFilters,
7299
- order_preservation: meta.preservesOrder,
7300
- max_workers: meta.maxWorkers ?? DEFAULT_MAX_WORKERS,
7301
- supports_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true || f.kind === "table" && f.meta.supportsBatchIndex === true,
7302
- partition_kind: f.kind === "table" && f.meta.partitionKind ? f.meta.partitionKind : "NOT_PARTITIONED",
7303
- order_dependent: meta.orderDependent,
7304
- distinct_dependent: meta.distinctDependent,
7305
- supports_window: false,
7306
- streaming_partitioned: false,
7307
- has_finalize: f.kind === "table_in_out" && f.meta.hasFinalize === true || f.kind === "table_buffering",
7308
- source_order_dependent: f.kind === "table_buffering" && f.meta.sourceOrderDependent === true,
7309
- sink_order_dependent: f.kind === "table_buffering" && f.meta.sinkOrderDependent === true,
7310
- requires_input_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true,
7311
- input_from_args: f.kind === "table_in_out" && f.meta.inputFromArgs === true,
7312
- required_settings: meta.requiredSettings,
7313
- required_secrets: requiredSecrets.map((s) => ({
7314
- secret_type: s.secret_type,
7315
- scope: s.scope,
7316
- secret_name: s.secret_name
7317
- }))
7318
- };
7273
+ }).map((f) => this._functionToInfo(f, name));
7274
+ }
7275
+ _functionToInfo(f, name) {
7276
+ const meta = resolveMetadata(f);
7277
+ const argSchema = argumentSpecsToSchema(f.argumentSpecs);
7278
+ const argBytes = serializeSchema(argSchema);
7279
+ const outputSchemaBytes = serializeSchema(f.defaultOutputSchema ?? schema2([]));
7280
+ const requiredSecrets = (meta.requiredSecrets ?? []).map((secretType) => ({ secret_type: secretType, scope: null, secret_name: null }));
7281
+ const derivedTags = {};
7282
+ const tags = { ...derivedTags, ...meta.tags ?? {} };
7283
+ return {
7284
+ comment: null,
7285
+ tags,
7286
+ name: f.meta.name,
7287
+ schema_name: name,
7288
+ function_type: meta.functionType.toUpperCase(),
7289
+ arguments: argBytes,
7290
+ output_schema: outputSchemaBytes,
7291
+ stability: meta.stability,
7292
+ null_handling: meta.nullHandling,
7293
+ description: meta.description,
7294
+ examples: meta.examples.map((e) => ({
7295
+ sql: e.sql,
7296
+ description: e.description,
7297
+ expected_output: null
7298
+ })),
7299
+ categories: meta.categories,
7300
+ projection_pushdown: meta.projectionPushdown,
7301
+ filter_pushdown: meta.filterPushdown,
7302
+ sampling_pushdown: meta.samplingPushdown,
7303
+ late_materialization: f.kind === "table" && f.meta.lateMaterialization === true ? true : null,
7304
+ supported_expression_filters: meta.supportedExpressionFilters,
7305
+ order_preservation: meta.preservesOrder,
7306
+ max_workers: meta.maxWorkers ?? DEFAULT_MAX_WORKERS,
7307
+ supports_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true || f.kind === "table" && f.meta.supportsBatchIndex === true,
7308
+ partition_kind: f.kind === "table" && f.meta.partitionKind ? f.meta.partitionKind : "NOT_PARTITIONED",
7309
+ order_dependent: meta.orderDependent,
7310
+ distinct_dependent: meta.distinctDependent,
7311
+ supports_window: false,
7312
+ streaming_partitioned: false,
7313
+ has_finalize: f.kind === "table_in_out" && f.meta.hasFinalize === true || f.kind === "table_buffering",
7314
+ source_order_dependent: f.kind === "table_buffering" && f.meta.sourceOrderDependent === true,
7315
+ sink_order_dependent: f.kind === "table_buffering" && f.meta.sinkOrderDependent === true,
7316
+ requires_input_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true,
7317
+ input_from_args: f.kind === "table_in_out" && f.meta.inputFromArgs === true,
7318
+ required_settings: meta.requiredSettings,
7319
+ required_secrets: requiredSecrets.map((s) => ({
7320
+ secret_type: s.secret_type,
7321
+ scope: s.scope,
7322
+ secret_name: s.secret_name
7323
+ }))
7324
+ };
7325
+ }
7326
+ _globalFunctionInfos() {
7327
+ const globals = this._descriptor.globalFunctions ?? [];
7328
+ if (globals.length === 0)
7329
+ return [];
7330
+ const schemaOf = new Map;
7331
+ for (const sch of this._descriptor.schemas) {
7332
+ for (const fn of sch.functions ?? []) {
7333
+ if (!schemaOf.has(fn))
7334
+ schemaOf.set(fn, sch.name);
7335
+ }
7336
+ }
7337
+ return globals.map((fn) => {
7338
+ const schemaName = schemaOf.get(fn);
7339
+ if (schemaName === undefined) {
7340
+ throw new Error(`Catalog '${this._descriptor.name}': '${fn.meta.name}' is listed in ` + `globalFunctions but is not declared in any schema.`);
7341
+ }
7342
+ return this._functionToInfo(fn, schemaName);
7319
7343
  });
7320
7344
  }
7321
7345
  schemaContentsMacros(attachOpaqueData, name, type, transactionOpaqueData) {
@@ -9424,8 +9448,13 @@ function registerFunctionMethods(protocol, config) {
9424
9448
  // src/protocol/handlers/aggregate.ts
9425
9449
  init_arrow();
9426
9450
  function registerAggregateMethods(protocol, registry) {
9427
- function resolveAggregate(name) {
9428
- const func = registry.get(name, { arguments: new Arguments, inputSchema: null, isScalar: false });
9451
+ function resolveAggregate(name, schemaName) {
9452
+ const func = registry.get(name, {
9453
+ arguments: new Arguments,
9454
+ inputSchema: null,
9455
+ isScalar: false,
9456
+ schemaName: schemaName ?? null
9457
+ });
9429
9458
  if (!func || func.kind !== "aggregate") {
9430
9459
  throw new Error(`Function '${name}' is not an aggregate function`);
9431
9460
  }
@@ -9437,7 +9466,7 @@ function registerAggregateMethods(protocol, registry) {
9437
9466
  handler: async (params) => {
9438
9467
  const innerParams = unwrapRequest(params.request);
9439
9468
  const functionName = innerParams.function_name;
9440
- const cfg = resolveAggregate(functionName);
9469
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
9441
9470
  const argBytes = toUint8Array(innerParams.arguments);
9442
9471
  const args = deserializeArguments(argBytes);
9443
9472
  const inputSchema = innerParams.input_schema ? deserializeSchema(toUint8Array(innerParams.input_schema)) : null;
@@ -9470,7 +9499,7 @@ function registerAggregateMethods(protocol, registry) {
9470
9499
  const innerParams = unwrapRequest(params.request);
9471
9500
  const functionName = innerParams.function_name;
9472
9501
  const executionId = toUint8Array(innerParams.execution_id);
9473
- const cfg = resolveAggregate(functionName);
9502
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
9474
9503
  const batch = readSingleBatch(toUint8Array(innerParams.input_batch));
9475
9504
  if (!batch || batch.numRows === 0)
9476
9505
  return wrapResult({}, schema2([]));
@@ -9523,7 +9552,7 @@ function registerAggregateMethods(protocol, registry) {
9523
9552
  const innerParams = unwrapRequest(params.request);
9524
9553
  const functionName = innerParams.function_name;
9525
9554
  const executionId = toUint8Array(innerParams.execution_id);
9526
- const cfg = resolveAggregate(functionName);
9555
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
9527
9556
  const batch = readSingleBatch(toUint8Array(innerParams.merge_batch));
9528
9557
  if (!batch || batch.numRows === 0)
9529
9558
  return wrapResult({}, schema2([]));
@@ -9568,7 +9597,7 @@ function registerAggregateMethods(protocol, registry) {
9568
9597
  const innerParams = unwrapRequest(params.request);
9569
9598
  const functionName = innerParams.function_name;
9570
9599
  const executionId = toUint8Array(innerParams.execution_id);
9571
- const cfg = resolveAggregate(functionName);
9600
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
9572
9601
  const outputSchema = deserializeSchema(toUint8Array(innerParams.output_schema));
9573
9602
  const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
9574
9603
  const groupIds = [];
@@ -9682,11 +9711,12 @@ function serializeBatchWithSchema(batch) {
9682
9711
  init_arrow();
9683
9712
  init_storage();
9684
9713
  function registerTableBufferingMethods(protocol, registry, signingKey) {
9685
- function resolveBuffering(name) {
9714
+ function resolveBuffering(name, schemaName) {
9686
9715
  const func = registry.get(name, {
9687
9716
  arguments: new Arguments,
9688
9717
  inputSchema: null,
9689
- isScalar: false
9718
+ isScalar: false,
9719
+ schemaName: schemaName ?? null
9690
9720
  });
9691
9721
  if (!func || func.kind !== "table_buffering") {
9692
9722
  throw new Error(`Function '${name}' is not a table_buffering function`);
@@ -9699,7 +9729,7 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
9699
9729
  const rawAttach = inner.attach_opaque_data ? toUint8Array(inner.attach_opaque_data) : null;
9700
9730
  const attach = rawAttach && rawAttach.length > 0 ? await openAttach(rawAttach, ctx?.auth, signingKey) : rawAttach;
9701
9731
  const transactionId = inner.transaction_id ? toUint8Array(inner.transaction_id) : null;
9702
- const func = resolveBuffering(functionName);
9732
+ const func = resolveBuffering(functionName, inner.schema_name ?? null);
9703
9733
  const bound = new BoundStorage(storage, executionId);
9704
9734
  const payload = await bound.stateGet(FrameworkNS.BUFFERING_INIT, BoundStorage.packIntKey(-1));
9705
9735
  if (payload == null) {
@@ -9839,6 +9869,8 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
9839
9869
  comment: result.comment ?? null,
9840
9870
  tags: result.tags ?? {},
9841
9871
  supports_column_statistics: result.supports_column_statistics ?? true,
9872
+ global_functions: result.global_functions ?? [],
9873
+ global_function_prefix: result.global_function_prefix ?? "",
9842
9874
  resolved_data_version: result.resolved_data_version ?? null,
9843
9875
  resolved_implementation_version: result.resolved_implementation_version ?? null
9844
9876
  }, CatalogAttachResultSchema);
@@ -11341,6 +11373,8 @@ class VgiClient {
11341
11373
  comment: inner.comment ?? null,
11342
11374
  tags: deserializeTags(inner.tags),
11343
11375
  supports_column_statistics: inner.supports_column_statistics ?? false,
11376
+ global_functions: inner.global_functions ? (Array.isArray(inner.global_functions) ? inner.global_functions : [...inner.global_functions]).map(toUint8Array) : [],
11377
+ global_function_prefix: inner.global_function_prefix ?? "",
11344
11378
  resolved_data_version: inner.resolved_data_version ?? null,
11345
11379
  resolved_implementation_version: inner.resolved_implementation_version ?? null
11346
11380
  };
@@ -12136,4 +12170,4 @@ export {
12136
12170
  ArgumentValidationError
12137
12171
  };
12138
12172
 
12139
- //# debugId=AC11F66207EB748964756E2164756E21
12173
+ //# debugId=F2B3478BD764EF8C64756E2164756E21