@query-farm/vgi 0.47.2 → 0.48.1

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.
Files changed (105) hide show
  1. package/README.md +1 -1
  2. package/dist/arguments/argument-spec.d.ts +17 -11
  3. package/dist/catalog/descriptors.d.ts +2 -2
  4. package/dist/catalog/publication.d.ts +7 -7
  5. package/dist/client/client.d.ts +9 -3
  6. package/dist/client/errors.d.ts +2 -2
  7. package/dist/client/types.d.ts +21 -0
  8. package/dist/client-entry.d.ts +1 -1
  9. package/dist/client-entry.js +56 -7
  10. package/dist/client-entry.js.map +23 -23
  11. package/dist/filter-pushdown/deserialize.d.ts +1 -1
  12. package/dist/filter-pushdown/types.d.ts +10 -10
  13. package/dist/functions/scalar.d.ts +1 -1
  14. package/dist/functions/table-buffering.d.ts +20 -20
  15. package/dist/functions/table-in-out.d.ts +4 -4
  16. package/dist/functions/table.d.ts +7 -7
  17. package/dist/functions/types.d.ts +47 -47
  18. package/dist/generated/vgi-client.d.ts +5 -0
  19. package/dist/generated/vgi-protocol-schemas.d.ts +5 -0
  20. package/dist/generated/vgi-protocol-types.d.ts +57 -0
  21. package/dist/generated/vgi-service.d.ts +1 -1
  22. package/dist/http/fetch.d.ts +10 -10
  23. package/dist/index.core.d.ts +3 -1
  24. package/dist/index.js +289 -103
  25. package/dist/index.js.map +57 -55
  26. package/dist/protocol/dispatch.d.ts +4 -4
  27. package/dist/protocol/handlers/function.d.ts +2 -2
  28. package/dist/protocol/serializers/cardinality.d.ts +4 -1
  29. package/dist/protocol/serializers/splits.d.ts +41 -1
  30. package/dist/protocol/types.d.ts +5 -5
  31. package/dist/rpc-server.d.ts +6 -6
  32. package/dist/serve-entry.d.ts +16 -16
  33. package/dist/serve-entry.js +119 -30
  34. package/dist/serve-entry.js.map +42 -40
  35. package/dist/split-token.d.ts +6 -6
  36. package/dist/types.d.ts +9 -2
  37. package/dist/util/defined.d.ts +21 -0
  38. package/dist/worker-cf-entry.js +199 -94
  39. package/dist/worker-cf-entry.js.map +55 -53
  40. package/dist/worker.d.ts +2 -2
  41. package/package.json +6 -4
  42. package/src/arguments/argument-spec.ts +17 -11
  43. package/src/arrow/codec/registry.ts +2 -2
  44. package/src/arrow/impl-arrowjs/build.ts +1 -1
  45. package/src/arrow/impl-arrowjs/canonical.ts +23 -23
  46. package/src/arrow/impl-arrowjs/empty.ts +2 -2
  47. package/src/arrow/impl-arrowjs/ipc.ts +2 -2
  48. package/src/arrow/impl-arrowjs/iterate.ts +2 -2
  49. package/src/arrow/impl-arrowjs/project.ts +2 -2
  50. package/src/arrow/impl-flechette/build.ts +2 -1
  51. package/src/arrow/impl-flechette/canonical.ts +10 -9
  52. package/src/arrow/impl-flechette/compat.ts +3 -3
  53. package/src/arrow/impl-flechette/message-meta.ts +5 -4
  54. package/src/arrow/impl-flechette/statistics.ts +2 -2
  55. package/src/attach-ticket.ts +2 -2
  56. package/src/catalog/column-metadata.ts +1 -1
  57. package/src/catalog/composite.ts +2 -2
  58. package/src/catalog/constraints.ts +9 -9
  59. package/src/catalog/descriptors.ts +1 -1
  60. package/src/catalog/interface.ts +12 -12
  61. package/src/catalog/publication.ts +9 -8
  62. package/src/catalog/read-only.ts +9 -8
  63. package/src/catalog/sql-grammar.ts +6 -6
  64. package/src/client/client.ts +52 -15
  65. package/src/client/errors.ts +1 -1
  66. package/src/client/types.ts +23 -0
  67. package/src/client-entry.ts +2 -0
  68. package/src/codec/asd.ts +3 -3
  69. package/src/codec/conform.ts +3 -3
  70. package/src/filter-pushdown/collector.ts +1 -1
  71. package/src/filter-pushdown/deserialize.ts +13 -10
  72. package/src/filter-pushdown/evaluate.ts +3 -2
  73. package/src/filter-pushdown/history.ts +3 -2
  74. package/src/filter-pushdown/types.ts +10 -10
  75. package/src/functions/continuation.ts +1 -1
  76. package/src/functions/projection.ts +1 -1
  77. package/src/functions/registry.ts +14 -14
  78. package/src/functions/scalar.ts +3 -3
  79. package/src/functions/storage-cf-do.ts +2 -2
  80. package/src/functions/table-buffering.ts +25 -21
  81. package/src/functions/table-in-out.ts +8 -8
  82. package/src/functions/table.ts +27 -25
  83. package/src/functions/types.ts +47 -47
  84. package/src/generated/vgi-client.ts +6 -1
  85. package/src/generated/vgi-protocol-schemas.ts +36 -1
  86. package/src/generated/vgi-protocol-types.ts +130 -1
  87. package/src/generated/vgi-service.ts +7 -5
  88. package/src/http/fetch.ts +17 -12
  89. package/src/index.core.ts +34 -0
  90. package/src/protocol/carried-init-request.ts +1 -1
  91. package/src/protocol/dispatch.ts +4 -4
  92. package/src/protocol/handlers/aggregate.ts +8 -7
  93. package/src/protocol/handlers/catalog/shared.ts +1 -1
  94. package/src/protocol/handlers/function.ts +2 -2
  95. package/src/protocol/serializers/cardinality.ts +16 -3
  96. package/src/protocol/serializers/splits.ts +82 -9
  97. package/src/protocol/state-serializer.ts +1 -1
  98. package/src/protocol/types.ts +5 -5
  99. package/src/rpc-server.ts +13 -12
  100. package/src/serve-entry.ts +18 -18
  101. package/src/split-token.ts +10 -9
  102. package/src/types.ts +9 -2
  103. package/src/util/defined.ts +30 -0
  104. package/src/util/parent-rows.ts +2 -2
  105. package/src/worker.ts +15 -14
package/dist/index.js CHANGED
@@ -3496,10 +3496,11 @@ class FilterParser {
3496
3496
  if (new Set(names).size !== names.length)
3497
3497
  throw new FilterV2Error("filter payload names must be unique");
3498
3498
  for (let i = 1;i < names.length; i++) {
3499
- if (!PAYLOAD_NAME.test(names[i]))
3500
- throw new FilterV2Error(`noncanonical payload name ${names[i]}`);
3501
- if (names[i].startsWith("type_") && this.valueAt(i) !== null) {
3502
- throw new FilterV2Error(`${names[i]} must contain NULL`);
3499
+ const name = names[i];
3500
+ if (!PAYLOAD_NAME.test(name))
3501
+ throw new FilterV2Error(`noncanonical payload name ${name}`);
3502
+ if (name.startsWith("type_") && this.valueAt(i) !== null) {
3503
+ throw new FilterV2Error(`${name} must contain NULL`);
3503
3504
  }
3504
3505
  }
3505
3506
  this.context = parseContext(batch.schema);
@@ -3512,9 +3513,10 @@ class FilterParser {
3512
3513
  }
3513
3514
  valueAt(index) {
3514
3515
  const column = this.batch.getChildAt(index);
3515
- if (!column)
3516
+ const field = this.batch.schema.fields[index];
3517
+ if (!column || !field)
3516
3518
  throw new FilterV2Error(`missing payload column ${index}`);
3517
- return readCanonicalValue(this.batch.schema.fields[index].type, column, 0);
3519
+ return readCanonicalValue(field.type, column, 0);
3518
3520
  }
3519
3521
  validateContextCapability() {
3520
3522
  if (this.context.profile === NO_EVALUATION_CONTEXT)
@@ -3635,9 +3637,10 @@ class FilterParser {
3635
3637
  const ref = expectUint(rawRef, `${prefix}_ref`);
3636
3638
  const name = `${prefix}_${ref}`;
3637
3639
  const indexes = this.batch.schema.fields.flatMap((field, index) => field.name === name ? [index] : []);
3638
- if (indexes.length !== 1)
3640
+ const index = indexes.length === 1 ? indexes[0] : undefined;
3641
+ if (index === undefined)
3639
3642
  throw new FilterV2Error(`missing or duplicate payload ${name}`);
3640
- return { ref, field: this.batch.schema.fields[indexes[0]], value: this.valueAt(indexes[0]) };
3643
+ return { ref, field: this.batch.schema.fields[index], value: this.valueAt(index) };
3641
3644
  }
3642
3645
  identity(raw, where) {
3643
3646
  const object = expectObject(raw, where);
@@ -3926,7 +3929,8 @@ function resolveColumn(batch, columnName) {
3926
3929
  throw new FilterV2Error(`filter column ${columnName} is unavailable in emitted batch`);
3927
3930
  }
3928
3931
  const column = batch.getChildAt(index);
3929
- resolved = column ? { type: batch.schema.fields[index].type, column } : null;
3932
+ const field = batch.schema.fields[index];
3933
+ resolved = column && field ? { type: field.type, column } : null;
3930
3934
  byName.set(columnName, resolved);
3931
3935
  }
3932
3936
  return resolved;
@@ -4526,9 +4530,10 @@ function decodeFilterDelta(bytes) {
4526
4530
  }
4527
4531
  function deltaRevisionKeys(batch) {
4528
4532
  const column = batch.getChildAt(0);
4529
- if (!column)
4533
+ const field = batch.schema.fields[0];
4534
+ if (!column || !field)
4530
4535
  throw new FilterV2Error("delta document has no filter_spec column");
4531
- const raw = readCanonicalValue(batch.schema.fields[0].type, column, 0);
4536
+ const raw = readCanonicalValue(field.type, column, 0);
4532
4537
  const document = JSON.parse(String(raw));
4533
4538
  return (document.updates ?? []).map((update) => revisionKey(update.id, update.revision));
4534
4539
  }
@@ -4928,7 +4933,7 @@ function defineTableFunction(config) {
4928
4933
  lookup_names: result.lookupNames
4929
4934
  };
4930
4935
  },
4931
- projection: config.projection ? (proposal) => config.projection({ args: extractArgs(proposal.bindCall), bindCall: proposal.bindCall, settings: batchToScalarDict(proposal.bindCall.settings), secrets: batchToSecretDict(proposal.bindCall.secrets), resolvedSecretsProvided: proposal.bindCall.resolved_secrets_provided }, proposal) : undefined,
4936
+ ...config.projection ? { projection: (proposal) => config.projection({ args: extractArgs(proposal.bindCall), bindCall: proposal.bindCall, settings: batchToScalarDict(proposal.bindCall.settings), secrets: batchToSecretDict(proposal.bindCall.secrets), resolvedSecretsProvided: proposal.bindCall.resolved_secrets_provided }, proposal) } : {},
4932
4937
  async globalInit(request) {
4933
4938
  const executionId = new Uint8Array(16);
4934
4939
  crypto.getRandomValues(executionId);
@@ -5041,55 +5046,63 @@ function defineTableFunction(config) {
5041
5046
  }
5042
5047
  };
5043
5048
  },
5044
- cardinality: config.cardinality ? (request) => {
5045
- const args = extractArgs(request.bind_call);
5046
- const settings = batchToScalarDict(request.bind_call.settings);
5047
- const secrets = batchToSecretDict(request.bind_call.secrets);
5048
- return config.cardinality({
5049
- args,
5050
- bindCall: request.bind_call,
5051
- settings,
5052
- secrets,
5053
- resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
5054
- });
5055
- } : undefined,
5056
- plan: config.plan ? (request) => {
5057
- const args = extractArgs(request.bind_call);
5058
- const settings = batchToScalarDict(request.bind_call.settings);
5059
- const secrets = batchToSecretDict(request.bind_call.secrets);
5060
- return config.plan({
5061
- args,
5062
- bindCall: request.bind_call,
5063
- settings,
5064
- secrets,
5065
- resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
5066
- }, request);
5067
- } : undefined,
5068
- statistics: config.statistics ? (request) => {
5069
- const args = extractArgs(request.bind_call);
5070
- const settings = batchToScalarDict(request.bind_call.settings);
5071
- const secrets = batchToSecretDict(request.bind_call.secrets);
5072
- return config.statistics({
5073
- args,
5074
- bindCall: request.bind_call,
5075
- settings,
5076
- secrets,
5077
- resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
5078
- });
5079
- } : undefined,
5080
- dynamicToString: config.dynamicToString ? (request) => {
5081
- const args = extractArgs(request.bindCall);
5082
- const settings = batchToScalarDict(request.bindCall.settings);
5083
- const secrets = batchToSecretDict(request.bindCall.secrets);
5084
- const storage2 = new BoundStorage(storage, request.globalExecutionId);
5085
- return config.dynamicToString({
5086
- args,
5087
- bindCall: request.bindCall,
5088
- settings,
5089
- secrets,
5090
- resolvedSecretsProvided: request.bindCall.resolved_secrets_provided ?? false
5091
- }, request.globalExecutionId, storage2);
5092
- } : undefined
5049
+ ...config.cardinality ? {
5050
+ cardinality: (request) => {
5051
+ const args = extractArgs(request.bind_call);
5052
+ const settings = batchToScalarDict(request.bind_call.settings);
5053
+ const secrets = batchToSecretDict(request.bind_call.secrets);
5054
+ return config.cardinality({
5055
+ args,
5056
+ bindCall: request.bind_call,
5057
+ settings,
5058
+ secrets,
5059
+ resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
5060
+ });
5061
+ }
5062
+ } : {},
5063
+ ...config.plan ? {
5064
+ plan: (request) => {
5065
+ const args = extractArgs(request.bind_call);
5066
+ const settings = batchToScalarDict(request.bind_call.settings);
5067
+ const secrets = batchToSecretDict(request.bind_call.secrets);
5068
+ return config.plan({
5069
+ args,
5070
+ bindCall: request.bind_call,
5071
+ settings,
5072
+ secrets,
5073
+ resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
5074
+ }, request);
5075
+ }
5076
+ } : {},
5077
+ ...config.statistics ? {
5078
+ statistics: (request) => {
5079
+ const args = extractArgs(request.bind_call);
5080
+ const settings = batchToScalarDict(request.bind_call.settings);
5081
+ const secrets = batchToSecretDict(request.bind_call.secrets);
5082
+ return config.statistics({
5083
+ args,
5084
+ bindCall: request.bind_call,
5085
+ settings,
5086
+ secrets,
5087
+ resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
5088
+ });
5089
+ }
5090
+ } : {},
5091
+ ...config.dynamicToString ? {
5092
+ dynamicToString: (request) => {
5093
+ const args = extractArgs(request.bindCall);
5094
+ const settings = batchToScalarDict(request.bindCall.settings);
5095
+ const secrets = batchToSecretDict(request.bindCall.secrets);
5096
+ const storage2 = new BoundStorage(storage, request.globalExecutionId);
5097
+ return config.dynamicToString({
5098
+ args,
5099
+ bindCall: request.bindCall,
5100
+ settings,
5101
+ secrets,
5102
+ resolvedSecretsProvided: request.bindCall.resolved_secrets_provided ?? false
5103
+ }, request.globalExecutionId, storage2);
5104
+ }
5105
+ } : {}
5093
5106
  };
5094
5107
  }
5095
5108
  // src/functions/aggregate.ts
@@ -5795,6 +5808,20 @@ function deserializeBindResponse(params) {
5795
5808
  }
5796
5809
  // src/protocol/serializers/init.ts
5797
5810
  init_arrow();
5811
+
5812
+ // src/protocol/types.ts
5813
+ var OrderByDirection;
5814
+ ((OrderByDirection) => {
5815
+ OrderByDirection["ASC"] = "ASC";
5816
+ OrderByDirection["DESC"] = "DESC";
5817
+ })(OrderByDirection ||= {});
5818
+ var OrderByNullOrder;
5819
+ ((OrderByNullOrder) => {
5820
+ OrderByNullOrder["NULLS_FIRST"] = "NULLS_FIRST";
5821
+ OrderByNullOrder["NULLS_LAST"] = "NULLS_LAST";
5822
+ })(OrderByNullOrder ||= {});
5823
+
5824
+ // src/protocol/serializers/init.ts
5798
5825
  var INIT_REQUEST_SCHEMA = schema2([
5799
5826
  field2("bind_call", binary2(), false),
5800
5827
  field2("output_schema", binary2(), false),
@@ -5994,10 +6021,19 @@ function deserializeCardinalityRequest(params) {
5994
6021
  bind_opaque_data: params.bind_opaque_data ? toUint8Array2(params.bind_opaque_data) : null
5995
6022
  };
5996
6023
  }
6024
+ function cardinalityValue(name, v) {
6025
+ if (v === null || v === undefined)
6026
+ return null;
6027
+ if (typeof v === "bigint")
6028
+ return v;
6029
+ if (typeof v === "number" && Number.isInteger(v))
6030
+ return BigInt(v);
6031
+ throw new TypeError(`TableCardinality.${name} must be an integer number, a bigint, or null (got ${typeof v}: ${String(v)})`);
6032
+ }
5997
6033
  function serializeTableCardinality(card) {
5998
6034
  return {
5999
- estimate: card.estimate,
6000
- max: card.max
6035
+ estimate: cardinalityValue("estimate", card.estimate),
6036
+ max: cardinalityValue("max", card.max)
6001
6037
  };
6002
6038
  }
6003
6039
  // src/protocol/carried-init-request.ts
@@ -7707,6 +7743,26 @@ var CopyFromFormatInfoSchema = schema2([
7707
7743
  field2("description", utf82(), false),
7708
7744
  field2("ordered", bool2(), false)
7709
7745
  ]);
7746
+ var FieldPathSchema = schema2([
7747
+ field2("components", list2(field2("item", utf82(), true)), false)
7748
+ ]);
7749
+ var TransformSpecSchema = schema2([
7750
+ field2("id", utf82(), false),
7751
+ field2("inputs", list2(field2("item", binary2(), true)), false),
7752
+ field2("parameters", binary2(), true)
7753
+ ]);
7754
+ var KeyGroupingSchema = schema2([
7755
+ field2("keys", list2(field2("item", binary2(), true)), false)
7756
+ ]);
7757
+ var RangeKeySchema = schema2([
7758
+ field2("transform", binary2(), false),
7759
+ field2("direction", dictionary2(utf82(), int162()), false),
7760
+ field2("null_order", dictionary2(utf82(), int162()), false)
7761
+ ]);
7762
+ var RangePartitioningSchema = schema2([
7763
+ field2("keys", list2(field2("item", binary2(), true)), false),
7764
+ field2("split_points", binary2(), false)
7765
+ ]);
7710
7766
  var MacroParameterSchema = schema2([
7711
7767
  field2("name", utf82(), false),
7712
7768
  field2("declared_type", binary2(), true),
@@ -7937,6 +7993,9 @@ var ScanSplitSchema = schema2([
7937
7993
  field2("estimated_rows", int642(), true),
7938
7994
  field2("rows_exact", bool2(), false),
7939
7995
  field2("estimated_bytes", int642(), true),
7996
+ field2("key_value", binary2(), true),
7997
+ field2("range_index", int642(), true),
7998
+ field2("column_bounds", binary2(), true),
7940
7999
  field2("partition_bounds", binary2(), true),
7941
8000
  field2("column_statistics", binary2(), true),
7942
8001
  field2("location_ids", list2(field2("item", int642(), true)), true),
@@ -8412,6 +8471,8 @@ var TableFunctionPlanResultSchema = schema2([
8412
8471
  field2("catalog_version", int642(), true),
8413
8472
  field2("scope", utf82(), false),
8414
8473
  field2("locations", list2(field2("item", utf82(), true)), true),
8474
+ field2("key_grouping", binary2(), true),
8475
+ field2("range_partitioning", binary2(), true),
8415
8476
  field2("partitioning", list2(field2("item", binary2(), true)), true),
8416
8477
  field2("sort_order", list2(field2("item", binary2(), true)), true),
8417
8478
  field2("cache_max_age_seconds", int642(), true),
@@ -8879,6 +8940,46 @@ var TableFunctionStatisticsParamsSchema = schema2([
8879
8940
  ]);
8880
8941
 
8881
8942
  // src/generated/vgi-protocol-types.ts
8943
+ function buildFieldPath(init) {
8944
+ return {
8945
+ components: init.components
8946
+ };
8947
+ }
8948
+ var encodeFieldPath = (v) => encodeASD(FieldPathSchema, v);
8949
+ var decodeFieldPath = (b) => decodeASD(FieldPathSchema, b);
8950
+ function buildTransformSpec(init) {
8951
+ return {
8952
+ id: init.id,
8953
+ inputs: init.inputs ?? [],
8954
+ parameters: init.parameters ?? null
8955
+ };
8956
+ }
8957
+ var encodeTransformSpec = (v) => encodeASD(TransformSpecSchema, v);
8958
+ var decodeTransformSpec = (b) => decodeASD(TransformSpecSchema, b);
8959
+ function buildKeyGrouping(init) {
8960
+ return {
8961
+ keys: init.keys
8962
+ };
8963
+ }
8964
+ var encodeKeyGrouping = (v) => encodeASD(KeyGroupingSchema, v);
8965
+ var decodeKeyGrouping = (b) => decodeASD(KeyGroupingSchema, b);
8966
+ function buildRangeKey(init) {
8967
+ return {
8968
+ transform: init.transform,
8969
+ direction: init.direction,
8970
+ null_order: init.null_order
8971
+ };
8972
+ }
8973
+ var encodeRangeKey = (v) => encodeASD(RangeKeySchema, v);
8974
+ var decodeRangeKey = (b) => decodeASD(RangeKeySchema, b);
8975
+ function buildRangePartitioning(init) {
8976
+ return {
8977
+ keys: init.keys,
8978
+ split_points: init.split_points
8979
+ };
8980
+ }
8981
+ var encodeRangePartitioning = (v) => encodeASD(RangePartitioningSchema, v);
8982
+ var decodeRangePartitioning = (b) => decodeASD(RangePartitioningSchema, b);
8882
8983
  function buildMacroOverload(init) {
8883
8984
  return {
8884
8985
  parameters: init.parameters,
@@ -11399,12 +11500,13 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
11399
11500
  if (typeof part !== "string" || !part || part.includes("\x00"))
11400
11501
  throw new Error("invalid requiredFilters component");
11401
11502
  const matches = fields.filter((f) => f.name === part);
11402
- if (matches.length !== 1)
11503
+ const match = matches.length === 1 ? matches[0] : undefined;
11504
+ if (!match)
11403
11505
  throw new Error(`unknown or ambiguous requiredFilters component: ${part}`);
11404
11506
  if (i + 1 < path.length) {
11405
- if (!isStruct(matches[0].type))
11507
+ if (!isStruct(match.type))
11406
11508
  throw new Error(`non-struct requiredFilters parent: ${part}`);
11407
- fields = matches[0].type.children;
11509
+ fields = match.type.children;
11408
11510
  }
11409
11511
  }
11410
11512
  }
@@ -12749,7 +12851,7 @@ class CompositeCatalogInterface extends CatalogInterface {
12749
12851
  }
12750
12852
  _route(attachOpaqueData) {
12751
12853
  const idx = attachOpaqueData[ROUTE_BYTE];
12752
- const route = this._backends[idx];
12854
+ const route = idx === undefined ? undefined : this._backends[idx];
12753
12855
  if (!route) {
12754
12856
  throw new OpaqueDataRejectedError("attach_opaque_data");
12755
12857
  }
@@ -13439,7 +13541,7 @@ import {
13439
13541
  Protocol
13440
13542
  } from "@query-farm/vgi-rpc";
13441
13543
  var VGI_PROTOCOL_NAME = "vgi.v3";
13442
- var VGI_PROTOCOL_VERSION = "3.0.0";
13544
+ var VGI_PROTOCOL_VERSION = "3.1.0";
13443
13545
  function exchangeStream(callbacks) {
13444
13546
  return { kind: "exchange", ...callbacks };
13445
13547
  }
@@ -14888,9 +14990,9 @@ function registerVgiService(protocol, service) {
14888
14990
  const common = {
14889
14991
  params: m.params,
14890
14992
  outputSchema: stream.outputSchema,
14891
- headerSchema: m.header ?? undefined,
14892
- headerInit: stream.headerInit,
14893
- onCancel: stream.onCancel,
14993
+ ...m.header ? { headerSchema: m.header } : {},
14994
+ ...stream.headerInit ? { headerInit: stream.headerInit } : {},
14995
+ ...stream.onCancel ? { onCancel: stream.onCancel } : {},
14894
14996
  doc: m.doc
14895
14997
  };
14896
14998
  if (stream.kind === "exchange") {
@@ -15179,14 +15281,40 @@ function deserializePlanRequest(params) {
15179
15281
  projectionIds = [...raw].map(Number);
15180
15282
  }
15181
15283
  const asBigInt = (v) => v == null ? null : typeof v === "bigint" ? v : BigInt(Number(v));
15284
+ const asBytes = (v) => v == null ? null : toUint8Array2(v);
15285
+ const asBytesList = (v) => {
15286
+ if (v == null)
15287
+ return null;
15288
+ const values = Array.isArray(v) ? v : v && typeof v[Symbol.iterator] === "function" ? [...v] : [];
15289
+ return values.filter((entry) => entry != null).map(toUint8Array2);
15290
+ };
15291
+ const enumValue = (v, values) => {
15292
+ if (v == null)
15293
+ return null;
15294
+ const text = String(v);
15295
+ return values.includes(text) ? text : null;
15296
+ };
15182
15297
  return {
15183
15298
  bind_call: bindCall,
15184
- bind_opaque_data: params.bind_opaque_data ? toUint8Array2(params.bind_opaque_data) : null,
15299
+ bind_opaque_data: asBytes(params.bind_opaque_data),
15185
15300
  projection_ids: projectionIds,
15186
- pushdown_filters: params.pushdown_filters ? toUint8Array2(params.pushdown_filters) : null,
15301
+ pushdown_filters: asBytes(params.pushdown_filters),
15302
+ join_keys: asBytesList(params.join_keys),
15303
+ row_limit: asBigInt(params.row_limit),
15187
15304
  target_split_bytes: asBigInt(params.target_split_bytes),
15188
15305
  min_splits: asBigInt(params.min_splits),
15189
- cursor: params.cursor ? toUint8Array2(params.cursor) : null
15306
+ max_splits_per_response: asBigInt(params.max_splits_per_response),
15307
+ cursor: asBytes(params.cursor),
15308
+ refined_filters: asBytes(params.refined_filters),
15309
+ filters_complete: params.filters_complete == null ? true : Boolean(params.filters_complete),
15310
+ start_position: asBytes(params.start_position),
15311
+ end_position: asBytes(params.end_position),
15312
+ order_by_column_name: params.order_by_column_name == null ? null : String(params.order_by_column_name),
15313
+ order_by_direction: enumValue(params.order_by_direction, Object.values(OrderByDirection)),
15314
+ order_by_null_order: enumValue(params.order_by_null_order, Object.values(OrderByNullOrder)),
15315
+ order_by_limit: asBigInt(params.order_by_limit),
15316
+ tablesample_percentage: params.tablesample_percentage == null ? null : Number(params.tablesample_percentage),
15317
+ tablesample_seed: asBigInt(params.tablesample_seed)
15190
15318
  };
15191
15319
  }
15192
15320
  function fingerprintInputs(bindCallBytes) {
@@ -15206,6 +15334,9 @@ function scanSplitRow(split, token) {
15206
15334
  estimated_rows: asBigInt(split.estimatedRows),
15207
15335
  rows_exact: split.rowsExact === true,
15208
15336
  estimated_bytes: asBigInt(split.estimatedBytes),
15337
+ key_value: split.keyValue ?? null,
15338
+ range_index: asBigInt(split.rangeIndex),
15339
+ column_bounds: split.columnBounds ?? null,
15209
15340
  partition_bounds: split.partitionBounds ?? null,
15210
15341
  column_statistics: split.columnStatistics ?? null,
15211
15342
  location_ids: split.locationIds ?? null,
@@ -15226,12 +15357,14 @@ function planResponseRow(result, splitBlobs) {
15226
15357
  estimated_total_bytes: asBigInt(result.estimatedTotalBytes),
15227
15358
  catalog_version: asBigInt(result.catalogVersion),
15228
15359
  scope: result.scope ?? "catalog",
15229
- locations: null,
15230
- partitioning: [],
15231
- sort_order: [],
15360
+ locations: result.locations ?? null,
15361
+ key_grouping: result.keyGrouping ?? null,
15362
+ range_partitioning: result.rangePartitioning ?? null,
15363
+ partitioning: result.partitioning ?? null,
15364
+ sort_order: result.sortOrder ?? null,
15232
15365
  cache_max_age_seconds: asBigInt(result.cacheMaxAgeSeconds),
15233
- start_position: new Uint8Array(0),
15234
- end_position: new Uint8Array(0)
15366
+ start_position: result.startPosition ?? null,
15367
+ end_position: result.endPosition ?? null
15235
15368
  };
15236
15369
  }
15237
15370
 
@@ -15823,6 +15956,7 @@ function extractArgMap(cfg, args) {
15823
15956
  }
15824
15957
  }
15825
15958
  for (let i = 0;i < constNames.length; i++) {
15959
+ const name = constNames[i];
15826
15960
  let v;
15827
15961
  try {
15828
15962
  v = args.get(i);
@@ -15837,16 +15971,16 @@ function extractArgMap(cfg, args) {
15837
15971
  v = Number(v);
15838
15972
  }
15839
15973
  } catch {
15840
- const def = cfg.argDefaults?.[constNames[i]];
15974
+ const def = cfg.argDefaults?.[name];
15841
15975
  if (def !== undefined)
15842
- out[constNames[i]] = def;
15976
+ out[name] = def;
15843
15977
  continue;
15844
15978
  }
15845
- const constraints = cfg.argConstraints?.[constNames[i]];
15979
+ const constraints = cfg.argConstraints?.[name];
15846
15980
  if (constraints !== undefined) {
15847
- validateConstConstraints(constNames[i], constraints, v);
15981
+ validateConstConstraints(name, constraints, v);
15848
15982
  }
15849
- out[constNames[i]] = v;
15983
+ out[name] = v;
15850
15984
  }
15851
15985
  if (cfg.argDefaults) {
15852
15986
  for (const [name, def] of Object.entries(cfg.argDefaults)) {
@@ -16391,15 +16525,16 @@ class CatalogSnapshotManager {
16391
16525
  validateCatalogPublicationEnvelope(bytes);
16392
16526
  }
16393
16527
  });
16394
- if (resolved.numRows !== 1 || resolved.schema.fields.length !== 1 || resolved.schema.fields[0].name !== "result" || typeSignature(resolved.schema.fields[0].type) !== typeSignature(binary2()) || resolved.schema.fields[0].nullable)
16528
+ const resultField = resolved.schema.fields.length === 1 ? resolved.schema.fields[0] : undefined;
16529
+ if (resolved.numRows !== 1 || !resultField || resultField.name !== "result" || typeSignature(resultField.type) !== typeSignature(binary2()) || resultField.nullable)
16395
16530
  throw new Error("invalid published RPC envelope");
16396
16531
  const bytes = resolved.getChild("result")?.get(0);
16397
16532
  if (!(bytes instanceof Uint8Array))
16398
16533
  throw new Error("published catalog has no result bytes");
16399
16534
  const decoded = decodeASDCollection(CatalogContentsResultSchema, bytes);
16400
- if (decoded.length !== 1)
16535
+ const response = decoded.length === 1 ? decoded[0] : undefined;
16536
+ if (!response)
16401
16537
  throw new Error("published catalog must contain exactly one response row");
16402
- const response = decoded[0];
16403
16538
  if (response.not_modified || Number(response.catalog_version) !== identity.catalogVersion || response.etag !== m.etag)
16404
16539
  throw new Error("published catalog version or ETag mismatch");
16405
16540
  decodeCatalogStreams(response);
@@ -17851,6 +17986,26 @@ function toAsyncIterator(input) {
17851
17986
  }
17852
17987
 
17853
17988
  // src/client/client.ts
17989
+ function int64ColumnNames(s) {
17990
+ if (!s)
17991
+ return [];
17992
+ return s.fields.filter((f) => isInt(f.type) && f.type.bitWidth === 64).map((f) => f.name);
17993
+ }
17994
+ var MIN_SAFE_BIGINT = BigInt(Number.MIN_SAFE_INTEGER);
17995
+ var MAX_SAFE_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
17996
+ function applyInt64Mode(rows, columns, mode) {
17997
+ for (const row of rows) {
17998
+ for (const name of columns) {
17999
+ const v = row[name];
18000
+ if (mode === "bigint") {
18001
+ if (typeof v === "number" && Number.isInteger(v))
18002
+ row[name] = BigInt(v);
18003
+ } else if (typeof v === "bigint" && v >= MIN_SAFE_BIGINT && v <= MAX_SAFE_BIGINT) {
18004
+ row[name] = Number(v);
18005
+ }
18006
+ }
18007
+ }
18008
+ }
17854
18009
  function onConflictName(onConflict) {
17855
18010
  return String(onConflict).toUpperCase();
17856
18011
  }
@@ -18142,10 +18297,14 @@ class VgiClient {
18142
18297
  tablesample: opts.tablesample,
18143
18298
  joinKeys: opts.joinKeys
18144
18299
  });
18300
+ const int64Columns = opts.int64 === undefined ? [] : int64ColumnNames(bindResp.output_schema);
18145
18301
  try {
18146
18302
  for await (const rows of session) {
18147
- if (rows.length > 0)
18148
- yield rows;
18303
+ if (rows.length === 0)
18304
+ continue;
18305
+ if (int64Columns.length > 0)
18306
+ applyInt64Mode(rows, int64Columns, opts.int64);
18307
+ yield rows;
18149
18308
  }
18150
18309
  } finally {
18151
18310
  session.close();
@@ -18387,7 +18546,7 @@ class VgiClient {
18387
18546
  return null;
18388
18547
  const inner = unwrapResult(result);
18389
18548
  const items = deserializeInfoList(inner.items, decodeSchemaInfo);
18390
- return items.length > 0 ? items[0] : null;
18549
+ return items[0] ?? null;
18391
18550
  }
18392
18551
  async schemaCreate(attachOpaqueData, path, opts) {
18393
18552
  const tagsMap = opts?.tags ? new Map(Object.entries(opts.tags)) : null;
@@ -18465,7 +18624,7 @@ class VgiClient {
18465
18624
  return null;
18466
18625
  const inner = unwrapResult(result);
18467
18626
  const items = deserializeInfoList(inner.items, decodeTableInfo);
18468
- return items.length > 0 ? items[0] : null;
18627
+ return items[0] ?? null;
18469
18628
  }
18470
18629
  async tableCreate(attachOpaqueData, schemaPath, name, columns, onConflict, constraintDefinitions = [], transactionOpaqueData) {
18471
18630
  await this.rpc.call("catalog_table_create", {
@@ -18633,7 +18792,7 @@ class VgiClient {
18633
18792
  return null;
18634
18793
  const inner = unwrapResult(result);
18635
18794
  const items = deserializeInfoList(inner.items, decodeViewInfo);
18636
- return items.length > 0 ? items[0] : null;
18795
+ return items[0] ?? null;
18637
18796
  }
18638
18797
  async viewCreate(attachOpaqueData, schemaPath, name, definition, onConflict, transactionOpaqueData, aliases, security = "regular", comment, tags, columnComments) {
18639
18798
  await this.rpc.call("catalog_view_create", {
@@ -18702,7 +18861,7 @@ class VgiClient {
18702
18861
  return null;
18703
18862
  const inner = unwrapResult(result);
18704
18863
  const items = deserializeInfoList(inner.items, decodeMacroInfo);
18705
- return items.length > 0 ? items[0] : null;
18864
+ return items[0] ?? null;
18706
18865
  }
18707
18866
  async schemaContentsMacros(attachOpaqueData, path, type, transactionOpaqueData) {
18708
18867
  const result = await this.rpc.call("catalog_schema_contents_macros", {
@@ -18752,6 +18911,18 @@ import {
18752
18911
  IdentityImpl,
18753
18912
  VgiRpcServer
18754
18913
  } from "@query-farm/vgi-rpc";
18914
+
18915
+ // src/util/defined.ts
18916
+ function omitUndefined(obj) {
18917
+ const out = {};
18918
+ for (const [k, v] of Object.entries(obj)) {
18919
+ if (v !== undefined)
18920
+ out[k] = v;
18921
+ }
18922
+ return out;
18923
+ }
18924
+
18925
+ // src/rpc-server.ts
18755
18926
  var TRANSPORTS = new Set(["pipe", "unix", "tcp", "iroh", "stream", "http"]);
18756
18927
  var IDENTITY_TRANSPORTS = new Set(["http"]);
18757
18928
  var RESERVED_PREFIX = "vgi_rpc.";
@@ -18770,12 +18941,12 @@ function buildRpcServer(primary, hosting, options) {
18770
18941
  if (tickets)
18771
18942
  protocols.push(tickets);
18772
18943
  }
18773
- return new VgiRpcServer(primary, {
18944
+ return new VgiRpcServer(primary, omitUndefined({
18774
18945
  serverId: options.serverId,
18775
18946
  protocols,
18776
18947
  identity,
18777
18948
  grantKeys: null
18778
- });
18949
+ }));
18779
18950
  }
18780
18951
  function validatedHostedProtocols(hosting, primary) {
18781
18952
  if (hosting.hostedProtocols === undefined)
@@ -18819,13 +18990,13 @@ function buildIdentity(hosting, grantKeys, env) {
18819
18990
  const { resolveToken, mintGrant } = hosting;
18820
18991
  if (!resolveToken && !mintGrant && !grantKeys)
18821
18992
  return;
18822
- return new IdentityImpl({
18993
+ return new IdentityImpl(omitUndefined({
18823
18994
  resolveToken,
18824
18995
  mintGrant,
18825
18996
  grantKeys: grantKeys ?? undefined,
18826
18997
  introspectPrincipals: resolveToken ? resolveIntrospectPrincipals(hosting.introspectPrincipals, env) : undefined,
18827
18998
  maxAuthAge: hosting.maxAuthAge
18828
- });
18999
+ }));
18829
19000
  }
18830
19001
  function buildAttachTickets(hosting, grantKeys, config, env) {
18831
19002
  if (!config || !config.signingKeyConfigured || !config.signingKey)
@@ -19007,10 +19178,10 @@ class Worker {
19007
19178
  const envOverride = process.env.VGI_WORKER_IDLE_TIMEOUT;
19008
19179
  const idleTimeout = envOverride !== undefined && envOverride !== "" ? Number(envOverride) : launcher.idleTimeout;
19009
19180
  debug(() => `[worker] AF_UNIX mode: ${launcher.unixPath} idle=${idleTimeout ?? 300}s${envOverride !== undefined && envOverride !== "" ? " (env override)" : ""}`);
19010
- serveUnix(this.buildServer(protocol, "unix"), {
19181
+ serveUnix(this.buildServer(protocol, "unix"), omitUndefined({
19011
19182
  unixPath: launcher.unixPath,
19012
19183
  idleTimeout
19013
- }).then((handle) => handle.done).then(() => {
19184
+ })).then((handle) => handle.done).then(() => {
19014
19185
  debug(() => `[worker] serveUnix done (idle shutdown)`);
19015
19186
  }).catch((err) => {
19016
19187
  process.stderr.write(`Worker error: ${err.message}
@@ -19024,7 +19195,7 @@ ${err.stack}
19024
19195
  const envOverride = process.env.VGI_WORKER_IDLE_TIMEOUT;
19025
19196
  const idleTimeout = envOverride !== undefined && envOverride !== "" ? Number(envOverride) : launcher.idleTimeout;
19026
19197
  debug(() => `[worker] TCP mode: ${launcher.tcpHost}:${launcher.tcpPort} idle=${idleTimeout ?? 300}s${envOverride !== undefined && envOverride !== "" ? " (env override)" : ""}`);
19027
- serveTcp(this.buildServer(protocol, launcher.irohRawUpstream ? "iroh" : "tcp"), {
19198
+ serveTcp(this.buildServer(protocol, launcher.irohRawUpstream ? "iroh" : "tcp"), omitUndefined({
19028
19199
  host: launcher.tcpHost,
19029
19200
  port: launcher.tcpPort,
19030
19201
  idleTimeout,
@@ -19034,7 +19205,7 @@ ${err.stack}
19034
19205
  irohProxyIssuer: launcher.irohIssuer,
19035
19206
  peerAuthenticationPolicy: launcher.irohAuthenticate ? peerIdentityPrimary("iroh") : observePeerIdentity
19036
19207
  } : {}
19037
- }).then((handle) => handle.done).then(() => {
19208
+ })).then((handle) => handle.done).then(() => {
19038
19209
  debug(() => `[worker] serveTcp done (idle shutdown)`);
19039
19210
  }).catch((err) => {
19040
19211
  process.stderr.write(`Worker error: ${err.message}
@@ -19072,7 +19243,7 @@ ${err.stack}
19072
19243
  });
19073
19244
  }
19074
19245
  async serveStream(readable, writable) {
19075
- await serveStreamRpc(this.buildServer(this.buildProtocol(), "stream"), { readable, writable });
19246
+ await serveStreamRpc(this.buildServer(this.buildProtocol(), "stream"), omitUndefined({ readable, writable }));
19076
19247
  }
19077
19248
  }
19078
19249
  // src/catalog/s3-publication.ts
@@ -19311,10 +19482,15 @@ export {
19311
19482
  buildCatalogCapabilities,
19312
19483
  buildConstraintChange,
19313
19484
  buildConstraintDefinition,
19485
+ buildFieldPath,
19314
19486
  buildJoinKeysLookup,
19487
+ buildKeyGrouping,
19315
19488
  buildMacroOverload,
19489
+ buildRangeKey,
19490
+ buildRangePartitioning,
19316
19491
  buildRpcServer,
19317
19492
  buildScanBranchesResult,
19493
+ buildTransformSpec,
19318
19494
  buildVgiProtocol,
19319
19495
  bytes,
19320
19496
  cacheControlMetadata,
@@ -19341,14 +19517,19 @@ export {
19341
19517
  decodeConstraintSnapshot,
19342
19518
  decodeConstraintsApplyRequest,
19343
19519
  decodeDictValue,
19520
+ decodeFieldPath,
19344
19521
  decodeForeignKeyDefinition,
19345
19522
  decodeFunctionInfo,
19346
19523
  decodeIndexDefinition,
19524
+ decodeKeyGrouping,
19347
19525
  decodeMacroInfo,
19348
19526
  decodeMacroOverload,
19527
+ decodeRangeKey,
19528
+ decodeRangePartitioning,
19349
19529
  decodeSchemaInfo,
19350
19530
  decodeSqlExpression,
19351
19531
  decodeTableInfo,
19532
+ decodeTransformSpec,
19352
19533
  decodeViewInfo,
19353
19534
  defaultClientCapabilities,
19354
19535
  defaultExpressionMetadata,
@@ -19385,15 +19566,20 @@ export {
19385
19566
  encodeConstraintSnapshot,
19386
19567
  encodeConstraintsApplyRequest,
19387
19568
  encodeCopyFromFormatInfo,
19569
+ encodeFieldPath,
19388
19570
  encodeForeignKeyDefinition,
19389
19571
  encodeFormatOptions,
19390
19572
  encodeFunctionInfo,
19391
19573
  encodeIndexDefinition,
19574
+ encodeKeyGrouping,
19392
19575
  encodeMacroInfo,
19393
19576
  encodeMacroOverload,
19577
+ encodeRangeKey,
19578
+ encodeRangePartitioning,
19394
19579
  encodeSchemaInfo,
19395
19580
  encodeSqlExpression,
19396
19581
  encodeTableInfo,
19582
+ encodeTransformSpec,
19397
19583
  encodeViewInfo,
19398
19584
  field2 as field,
19399
19585
  filterBatch,
@@ -19514,4 +19700,4 @@ export {
19514
19700
  validateTableConstraints
19515
19701
  };
19516
19702
 
19517
- //# debugId=89F18E0425AB222A64756E2164756E21
19703
+ //# debugId=9CC3A9354AA50B4D64756E2164756E21