@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.
@@ -3381,6 +3381,8 @@ var CatalogAttachResultSchema = schema2([
3381
3381
  field2("comment", utf82(), true),
3382
3382
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
3383
3383
  field2("supports_column_statistics", bool2(), false),
3384
+ field2("global_functions", list2(field2("item", binary2(), true)), false),
3385
+ field2("global_function_prefix", utf82(), false),
3384
3386
  field2("resolved_data_version", utf82(), true),
3385
3387
  field2("resolved_implementation_version", utf82(), true)
3386
3388
  ]);
@@ -5398,8 +5400,13 @@ function defineAggregate(config) {
5398
5400
 
5399
5401
  // src/protocol/handlers/aggregate.ts
5400
5402
  function registerAggregateMethods(protocol, registry) {
5401
- function resolveAggregate(name) {
5402
- const func = registry.get(name, { arguments: new Arguments, inputSchema: null, isScalar: false });
5403
+ function resolveAggregate(name, schemaName) {
5404
+ const func = registry.get(name, {
5405
+ arguments: new Arguments,
5406
+ inputSchema: null,
5407
+ isScalar: false,
5408
+ schemaName: schemaName ?? null
5409
+ });
5403
5410
  if (!func || func.kind !== "aggregate") {
5404
5411
  throw new Error(`Function '${name}' is not an aggregate function`);
5405
5412
  }
@@ -5411,7 +5418,7 @@ function registerAggregateMethods(protocol, registry) {
5411
5418
  handler: async (params) => {
5412
5419
  const innerParams = unwrapRequest(params.request);
5413
5420
  const functionName = innerParams.function_name;
5414
- const cfg = resolveAggregate(functionName);
5421
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
5415
5422
  const argBytes = toUint8Array(innerParams.arguments);
5416
5423
  const args = deserializeArguments(argBytes);
5417
5424
  const inputSchema = innerParams.input_schema ? deserializeSchema(toUint8Array(innerParams.input_schema)) : null;
@@ -5444,7 +5451,7 @@ function registerAggregateMethods(protocol, registry) {
5444
5451
  const innerParams = unwrapRequest(params.request);
5445
5452
  const functionName = innerParams.function_name;
5446
5453
  const executionId = toUint8Array(innerParams.execution_id);
5447
- const cfg = resolveAggregate(functionName);
5454
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
5448
5455
  const batch = readSingleBatch(toUint8Array(innerParams.input_batch));
5449
5456
  if (!batch || batch.numRows === 0)
5450
5457
  return wrapResult({}, schema2([]));
@@ -5497,7 +5504,7 @@ function registerAggregateMethods(protocol, registry) {
5497
5504
  const innerParams = unwrapRequest(params.request);
5498
5505
  const functionName = innerParams.function_name;
5499
5506
  const executionId = toUint8Array(innerParams.execution_id);
5500
- const cfg = resolveAggregate(functionName);
5507
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
5501
5508
  const batch = readSingleBatch(toUint8Array(innerParams.merge_batch));
5502
5509
  if (!batch || batch.numRows === 0)
5503
5510
  return wrapResult({}, schema2([]));
@@ -5542,7 +5549,7 @@ function registerAggregateMethods(protocol, registry) {
5542
5549
  const innerParams = unwrapRequest(params.request);
5543
5550
  const functionName = innerParams.function_name;
5544
5551
  const executionId = toUint8Array(innerParams.execution_id);
5545
- const cfg = resolveAggregate(functionName);
5552
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
5546
5553
  const outputSchema = deserializeSchema(toUint8Array(innerParams.output_schema));
5547
5554
  const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
5548
5555
  const groupIds = [];
@@ -6345,11 +6352,12 @@ function splitLenPrefixed(buf, count) {
6345
6352
 
6346
6353
  // src/protocol/handlers/table-buffering.ts
6347
6354
  function registerTableBufferingMethods(protocol, registry, signingKey) {
6348
- function resolveBuffering(name) {
6355
+ function resolveBuffering(name, schemaName) {
6349
6356
  const func = registry.get(name, {
6350
6357
  arguments: new Arguments,
6351
6358
  inputSchema: null,
6352
- isScalar: false
6359
+ isScalar: false,
6360
+ schemaName: schemaName ?? null
6353
6361
  });
6354
6362
  if (!func || func.kind !== "table_buffering") {
6355
6363
  throw new Error(`Function '${name}' is not a table_buffering function`);
@@ -6362,7 +6370,7 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
6362
6370
  const rawAttach = inner.attach_opaque_data ? toUint8Array(inner.attach_opaque_data) : null;
6363
6371
  const attach = rawAttach && rawAttach.length > 0 ? await openAttach(rawAttach, ctx?.auth, signingKey) : rawAttach;
6364
6372
  const transactionId = inner.transaction_id ? toUint8Array(inner.transaction_id) : null;
6365
- const func = resolveBuffering(functionName);
6373
+ const func = resolveBuffering(functionName, inner.schema_name ?? null);
6366
6374
  const bound = new BoundStorage(storage, executionId);
6367
6375
  const payload = await bound.stateGet(FrameworkNS.BUFFERING_INIT, BoundStorage.packIntKey(-1));
6368
6376
  if (payload == null) {
@@ -6477,7 +6485,6 @@ var encodeMacroInfo = (v) => encodeASD(MacroInfoSchema, v);
6477
6485
  var encodeSchemaInfo = (v) => encodeASD(SchemaInfoSchema, v);
6478
6486
  var encodeTableInfo = (v) => encodeASD(TableInfoSchema, v);
6479
6487
  var encodeViewInfo = (v) => encodeASD(ViewInfoSchema, v);
6480
-
6481
6488
  // src/catalog/interface.ts
6482
6489
  var encodeCopyFromFormatInfo = (v) => encodeASD(CopyFromFormatInfoSchema, {
6483
6490
  comment: v.comment ?? null,
@@ -6683,6 +6690,8 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
6683
6690
  comment: result.comment ?? null,
6684
6691
  tags: result.tags ?? {},
6685
6692
  supports_column_statistics: result.supports_column_statistics ?? true,
6693
+ global_functions: result.global_functions ?? [],
6694
+ global_function_prefix: result.global_function_prefix ?? "",
6686
6695
  resolved_data_version: result.resolved_data_version ?? null,
6687
6696
  resolved_implementation_version: result.resolved_implementation_version ?? null
6688
6697
  }, CatalogAttachResultSchema);
@@ -8167,6 +8176,8 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
8167
8176
  comment: this._descriptor.comment ?? null,
8168
8177
  tags: this._descriptor.tags ?? {},
8169
8178
  supports_column_statistics: true,
8179
+ global_functions: this._globalFunctionInfos().map(encodeFunctionInfo),
8180
+ global_function_prefix: this._descriptor.globalFunctionPrefix ?? "",
8170
8181
  resolved_data_version: null,
8171
8182
  resolved_implementation_version: null
8172
8183
  };
@@ -8353,56 +8364,76 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
8353
8364
  if (t === "AGGREGATE_FUNCTION")
8354
8365
  return f.kind === "aggregate";
8355
8366
  return true;
8356
- }).map((f) => {
8357
- const meta = resolveMetadata(f);
8358
- const argSchema = argumentSpecsToSchema(f.argumentSpecs);
8359
- const argBytes = serializeSchema(argSchema);
8360
- const outputSchemaBytes = serializeSchema(f.defaultOutputSchema ?? schema2([]));
8361
- const requiredSecrets = (meta.requiredSecrets ?? []).map((secretType) => ({ secret_type: secretType, scope: null, secret_name: null }));
8362
- const derivedTags = {};
8363
- const tags = { ...derivedTags, ...meta.tags ?? {} };
8364
- return {
8365
- comment: null,
8366
- tags,
8367
- name: f.meta.name,
8368
- schema_name: name,
8369
- function_type: meta.functionType.toUpperCase(),
8370
- arguments: argBytes,
8371
- output_schema: outputSchemaBytes,
8372
- stability: meta.stability,
8373
- null_handling: meta.nullHandling,
8374
- description: meta.description,
8375
- examples: meta.examples.map((e) => ({
8376
- sql: e.sql,
8377
- description: e.description,
8378
- expected_output: null
8379
- })),
8380
- categories: meta.categories,
8381
- projection_pushdown: meta.projectionPushdown,
8382
- filter_pushdown: meta.filterPushdown,
8383
- sampling_pushdown: meta.samplingPushdown,
8384
- late_materialization: f.kind === "table" && f.meta.lateMaterialization === true ? true : null,
8385
- supported_expression_filters: meta.supportedExpressionFilters,
8386
- order_preservation: meta.preservesOrder,
8387
- max_workers: meta.maxWorkers ?? DEFAULT_MAX_WORKERS,
8388
- supports_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true || f.kind === "table" && f.meta.supportsBatchIndex === true,
8389
- partition_kind: f.kind === "table" && f.meta.partitionKind ? f.meta.partitionKind : "NOT_PARTITIONED",
8390
- order_dependent: meta.orderDependent,
8391
- distinct_dependent: meta.distinctDependent,
8392
- supports_window: false,
8393
- streaming_partitioned: false,
8394
- has_finalize: f.kind === "table_in_out" && f.meta.hasFinalize === true || f.kind === "table_buffering",
8395
- source_order_dependent: f.kind === "table_buffering" && f.meta.sourceOrderDependent === true,
8396
- sink_order_dependent: f.kind === "table_buffering" && f.meta.sinkOrderDependent === true,
8397
- requires_input_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true,
8398
- input_from_args: f.kind === "table_in_out" && f.meta.inputFromArgs === true,
8399
- required_settings: meta.requiredSettings,
8400
- required_secrets: requiredSecrets.map((s) => ({
8401
- secret_type: s.secret_type,
8402
- scope: s.scope,
8403
- secret_name: s.secret_name
8404
- }))
8405
- };
8367
+ }).map((f) => this._functionToInfo(f, name));
8368
+ }
8369
+ _functionToInfo(f, name) {
8370
+ const meta = resolveMetadata(f);
8371
+ const argSchema = argumentSpecsToSchema(f.argumentSpecs);
8372
+ const argBytes = serializeSchema(argSchema);
8373
+ const outputSchemaBytes = serializeSchema(f.defaultOutputSchema ?? schema2([]));
8374
+ const requiredSecrets = (meta.requiredSecrets ?? []).map((secretType) => ({ secret_type: secretType, scope: null, secret_name: null }));
8375
+ const derivedTags = {};
8376
+ const tags = { ...derivedTags, ...meta.tags ?? {} };
8377
+ return {
8378
+ comment: null,
8379
+ tags,
8380
+ name: f.meta.name,
8381
+ schema_name: name,
8382
+ function_type: meta.functionType.toUpperCase(),
8383
+ arguments: argBytes,
8384
+ output_schema: outputSchemaBytes,
8385
+ stability: meta.stability,
8386
+ null_handling: meta.nullHandling,
8387
+ description: meta.description,
8388
+ examples: meta.examples.map((e) => ({
8389
+ sql: e.sql,
8390
+ description: e.description,
8391
+ expected_output: null
8392
+ })),
8393
+ categories: meta.categories,
8394
+ projection_pushdown: meta.projectionPushdown,
8395
+ filter_pushdown: meta.filterPushdown,
8396
+ sampling_pushdown: meta.samplingPushdown,
8397
+ late_materialization: f.kind === "table" && f.meta.lateMaterialization === true ? true : null,
8398
+ supported_expression_filters: meta.supportedExpressionFilters,
8399
+ order_preservation: meta.preservesOrder,
8400
+ max_workers: meta.maxWorkers ?? DEFAULT_MAX_WORKERS,
8401
+ supports_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true || f.kind === "table" && f.meta.supportsBatchIndex === true,
8402
+ partition_kind: f.kind === "table" && f.meta.partitionKind ? f.meta.partitionKind : "NOT_PARTITIONED",
8403
+ order_dependent: meta.orderDependent,
8404
+ distinct_dependent: meta.distinctDependent,
8405
+ supports_window: false,
8406
+ streaming_partitioned: false,
8407
+ has_finalize: f.kind === "table_in_out" && f.meta.hasFinalize === true || f.kind === "table_buffering",
8408
+ source_order_dependent: f.kind === "table_buffering" && f.meta.sourceOrderDependent === true,
8409
+ sink_order_dependent: f.kind === "table_buffering" && f.meta.sinkOrderDependent === true,
8410
+ requires_input_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true,
8411
+ input_from_args: f.kind === "table_in_out" && f.meta.inputFromArgs === true,
8412
+ required_settings: meta.requiredSettings,
8413
+ required_secrets: requiredSecrets.map((s) => ({
8414
+ secret_type: s.secret_type,
8415
+ scope: s.scope,
8416
+ secret_name: s.secret_name
8417
+ }))
8418
+ };
8419
+ }
8420
+ _globalFunctionInfos() {
8421
+ const globals = this._descriptor.globalFunctions ?? [];
8422
+ if (globals.length === 0)
8423
+ return [];
8424
+ const schemaOf = new Map;
8425
+ for (const sch of this._descriptor.schemas) {
8426
+ for (const fn of sch.functions ?? []) {
8427
+ if (!schemaOf.has(fn))
8428
+ schemaOf.set(fn, sch.name);
8429
+ }
8430
+ }
8431
+ return globals.map((fn) => {
8432
+ const schemaName = schemaOf.get(fn);
8433
+ if (schemaName === undefined) {
8434
+ throw new Error(`Catalog '${this._descriptor.name}': '${fn.meta.name}' is listed in ` + `globalFunctions but is not declared in any schema.`);
8435
+ }
8436
+ return this._functionToInfo(fn, schemaName);
8406
8437
  });
8407
8438
  }
8408
8439
  schemaContentsMacros(attachOpaqueData, name, type, transactionOpaqueData) {
@@ -9681,4 +9712,4 @@ export {
9681
9712
  Arguments
9682
9713
  };
9683
9714
 
9684
- //# debugId=0DAB6D0BDC711A3364756E2164756E21
9715
+ //# debugId=27B541E45B6B151B64756E2164756E21