@query-farm/vgi 0.24.2 → 0.25.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.
@@ -41,6 +41,16 @@ export declare function serializeAttachOptionSpec(spec: AttachOptionSpec): Uint8
41
41
  * Convenience: serialize many specs at once for CatalogInfo.attach_option_specs.
42
42
  */
43
43
  export declare function serializeAttachOptionSpecs(specs: Iterable<AttachOptionSpec>): Uint8Array[];
44
+ /**
45
+ * Deserialize one AttachOptionSpec from the wire format above.
46
+ *
47
+ * Reads by column name, so a spec written by a peer that predates the
48
+ * `required` column deserializes with `required: false` rather than failing —
49
+ * the same tolerance the Python and C++ readers have.
50
+ */
51
+ export declare function deserializeAttachOptionSpec(bytes: Uint8Array): AttachOptionSpec;
52
+ /** Deserialize many specs — the shape `CatalogInfo.attach_option_specs` holds. */
53
+ export declare function deserializeAttachOptionSpecs(specs: Iterable<Uint8Array>): AttachOptionSpec[];
44
54
  /**
45
55
  * Raised when `attach` omits options declared `required`.
46
56
  *
@@ -7,5 +7,7 @@ export type { BindRequest, BindResponse, InitRequest, GlobalInitResponse, TableC
7
7
  export { type SchemaInfo, encodeSchemaInfo, decodeSchemaInfo, type TableInfo, encodeTableInfo, decodeTableInfo, type ViewInfo, encodeViewInfo, decodeViewInfo, type FunctionInfo, encodeFunctionInfo, decodeFunctionInfo, type MacroInfo, encodeMacroInfo, decodeMacroInfo, type CatalogAttachResult, type AttachOpaqueData, type TransactionOpaqueData, } from "./catalog/interface.js";
8
8
  export { VgiError, RowCountMismatchError, FunctionNotFoundError, CatalogReadOnlyError, CatalogNotFoundError, CatalogAlreadyExistsError, ArgumentValidationError, NoCatalogError, } from "./errors.js";
9
9
  export { iterRows, batchFromRows, batchFromColumns, emptyBatch, filterBatch, projectSchema, projectBatch, batchToScalarDict, safeNumber, serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, } from "./util/arrow/index.js";
10
+ export { TypeId, typeSignature } from "./arrow/predicates.js";
11
+ export { type AttachOptionSpec, deserializeAttachOptionSpec, deserializeAttachOptionSpecs, } from "./catalog/attach-option.js";
10
12
  export { toUint8Array } from "./util/bytes.js";
11
13
  export type { RpcClient, StreamSession, LogMessage } from "@query-farm/vgi-rpc";
@@ -58,6 +58,42 @@ function isMap(t) {
58
58
  function isDictionary(t) {
59
59
  return t.typeId === TypeId.Dictionary;
60
60
  }
61
+ function typeSignature(t) {
62
+ if (t == null)
63
+ return "null";
64
+ const a = t;
65
+ const kids = () => Array.isArray(a.children) ? a.children.map((c) => `${c?.name ?? ""}:${typeSignature(c?.type ?? c)}`).join(",") : "";
66
+ switch (t.typeId) {
67
+ case TypeId.Int:
68
+ return `int${a.bitWidth}${a.isSigned ?? a.signed ?? true ? "" : "u"}`;
69
+ case TypeId.Float:
70
+ return `float${a.precision}`;
71
+ case TypeId.Decimal:
72
+ return `decimal${a.bitWidth ?? 128}(${a.precision},${a.scale})`;
73
+ case TypeId.Date:
74
+ case TypeId.Time:
75
+ case TypeId.Duration:
76
+ return `${t.typeId}[${a.unit}]`;
77
+ case TypeId.Timestamp:
78
+ return `ts[${a.unit},${a.timezone ?? ""}]`;
79
+ case TypeId.Interval:
80
+ return `iv[${a.unit}]`;
81
+ case TypeId.FixedSizeBinary:
82
+ return `fsb(${a.byteWidth ?? a.stride})`;
83
+ case TypeId.FixedSizeList:
84
+ return `fsl(${a.listSize ?? a.stride},${kids()})`;
85
+ case TypeId.List:
86
+ case TypeId.Struct:
87
+ case TypeId.Map:
88
+ return `${t.typeId}<${kids()}>`;
89
+ case TypeId.Union:
90
+ return `union(${a.mode},${kids()})`;
91
+ case TypeId.Dictionary:
92
+ return `dict(${typeSignature(a.dictionary)},${typeSignature(a.indices)},${a.ordered ?? a.isOrdered ?? false})`;
93
+ default:
94
+ return Array.isArray(a.children) ? `${t.typeId}<${kids()}>` : String(t.typeId);
95
+ }
96
+ }
61
97
  // src/arrow/impl-arrowjs/index.ts
62
98
  var exports_impl_arrowjs = {};
63
99
  __export(exports_impl_arrowjs, {
@@ -3880,7 +3916,43 @@ function schemaToArgumentSpecs(schema3) {
3880
3916
  }
3881
3917
  return specs;
3882
3918
  }
3919
+ // src/catalog/attach-option.ts
3920
+ var SPEC_SCHEMA = schema2([
3921
+ field2("name", utf82(), false),
3922
+ field2("description", utf82(), false),
3923
+ field2("type", binary2(), false),
3924
+ field2("default_value", binary2(), true),
3925
+ field2("required", bool2(), true)
3926
+ ]);
3927
+ function deserializeAttachOptionSpec(bytes) {
3928
+ const row = [...iterRows(deserializeBatch(bytes))][0];
3929
+ if (row === undefined) {
3930
+ throw new Error("Cannot deserialize AttachOptionSpec from an empty batch");
3931
+ }
3932
+ const typeSchema = deserializeSchema(toUint8Array(row.type));
3933
+ const type = typeSchema.fields[0].type;
3934
+ let value;
3935
+ const defaultBytes = row.default_value;
3936
+ if (defaultBytes != null) {
3937
+ const asBytes = toUint8Array(defaultBytes);
3938
+ if (asBytes.length > 0) {
3939
+ const defaultRow = [...iterRows(deserializeBatch(asBytes))][0];
3940
+ value = defaultRow?.value;
3941
+ }
3942
+ }
3943
+ return {
3944
+ name: String(row.name),
3945
+ description: String(row.description ?? ""),
3946
+ type,
3947
+ ...value === undefined || value === null ? {} : { default: value },
3948
+ required: row.required === true
3949
+ };
3950
+ }
3951
+ function deserializeAttachOptionSpecs(specs) {
3952
+ return Array.from(specs, deserializeAttachOptionSpec);
3953
+ }
3883
3954
  export {
3955
+ typeSignature,
3884
3956
  toUint8Array,
3885
3957
  serializeSchema,
3886
3958
  serializeBatch,
@@ -3898,6 +3970,8 @@ export {
3898
3970
  emptyBatch,
3899
3971
  deserializeSchema,
3900
3972
  deserializeBatch,
3973
+ deserializeAttachOptionSpecs,
3974
+ deserializeAttachOptionSpec,
3901
3975
  decodeViewInfo,
3902
3976
  decodeTableInfo,
3903
3977
  decodeSchemaInfo,
@@ -3910,6 +3984,7 @@ export {
3910
3984
  VgiError,
3911
3985
  VgiClientError,
3912
3986
  VgiClient,
3987
+ TypeId,
3913
3988
  TableInOutPhase,
3914
3989
  RowCountMismatchError,
3915
3990
  OrderPreservation,
@@ -3927,4 +4002,4 @@ export {
3927
4002
  ArgumentValidationError
3928
4003
  };
3929
4004
 
3930
- //# debugId=34D58DEB536066C064756E2164756E21
4005
+ //# debugId=B61D9AABA0B3DE2E64756E2164756E21