@query-farm/vgi 0.7.0 → 0.9.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.
package/dist/types.d.ts CHANGED
@@ -45,6 +45,10 @@ export declare const VGI_VARARGS_TRUE = "true";
45
45
  export declare const VGI_CONST_KEY = "vgi_const";
46
46
  export declare const VGI_CONST_TRUE = "true";
47
47
  export declare const VGI_DOC_KEY = "vgi_doc";
48
+ export declare const VGI_DEFAULT_KEY = "vgi_default";
49
+ export declare const VGI_CHOICES_KEY = "vgi_choices";
50
+ export declare const VGI_RANGE_KEY = "vgi_range";
51
+ export declare const VGI_PATTERN_KEY = "vgi_pattern";
48
52
  export interface TableCardinality {
49
53
  estimate: number | null;
50
54
  max: number | null;
@@ -2850,6 +2850,10 @@ var VGI_VARARGS_TRUE = "true";
2850
2850
  var VGI_CONST_KEY = "vgi_const";
2851
2851
  var VGI_CONST_TRUE = "true";
2852
2852
  var VGI_DOC_KEY = "vgi_doc";
2853
+ var VGI_DEFAULT_KEY = "vgi_default";
2854
+ var VGI_CHOICES_KEY = "vgi_choices";
2855
+ var VGI_RANGE_KEY = "vgi_range";
2856
+ var VGI_PATTERN_KEY = "vgi_pattern";
2853
2857
  var DEFAULT_MAX_WORKERS = 99999;
2854
2858
 
2855
2859
  // src/util/arrow/index.ts
@@ -3259,7 +3263,19 @@ var ScanBranchSchema = schema2([
3259
3263
  field2("function_name", utf82(), false),
3260
3264
  field2("arguments", binary2(), false),
3261
3265
  field2("branch_filter", utf82(), true),
3262
- field2("writable", bool2(), false)
3266
+ field2("writable", bool2(), false),
3267
+ field2("source_catalog", utf82(), true),
3268
+ field2("source_schema", utf82(), true),
3269
+ field2("source_table", utf82(), true)
3270
+ ]);
3271
+ var AttachCatalogInfoSchema = schema2([
3272
+ field2("alias", utf82(), false),
3273
+ field2("target", utf82(), false),
3274
+ field2("db_type", utf82(), false),
3275
+ field2("options", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
3276
+ field2("hidden", bool2(), false),
3277
+ field2("required", bool2(), false),
3278
+ field2("secret_ref", utf82(), false)
3263
3279
  ]);
3264
3280
  var AggregateBindResultSchema = schema2([
3265
3281
  field2("output_schema", binary2(), false),
@@ -3303,6 +3319,7 @@ var CatalogAttachResultSchema = schema2([
3303
3319
  field2("default_schema", utf82(), false),
3304
3320
  field2("settings", list2(field2("item", binary2(), true)), false),
3305
3321
  field2("secret_types", list2(field2("item", binary2(), true)), false),
3322
+ field2("attach_catalogs", list2(field2("item", binary2(), true)), false),
3306
3323
  field2("comment", utf82(), true),
3307
3324
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
3308
3325
  field2("supports_column_statistics", bool2(), false),
@@ -6199,12 +6216,24 @@ var encodeCopyFromFormatInfo = (v) => encodeASD(CopyFromFormatInfoSchema, {
6199
6216
  description: v.description ?? "",
6200
6217
  ordered: v.ordered ?? false
6201
6218
  });
6219
+ var encodeAttachCatalogInfo = (v) => encodeASD(AttachCatalogInfoSchema, {
6220
+ alias: v.alias,
6221
+ target: v.target,
6222
+ db_type: v.db_type ?? "",
6223
+ options: v.options ?? {},
6224
+ hidden: v.hidden ?? false,
6225
+ required: v.required ?? false,
6226
+ secret_ref: v.secret_ref ?? ""
6227
+ });
6202
6228
  function singleBranchResult(legacy) {
6203
6229
  const branchBatch = batchFromColumns({
6204
6230
  function_name: [legacy.function_name],
6205
6231
  arguments: [toUint8Array(legacy.arguments)],
6206
6232
  branch_filter: [null],
6207
- writable: [false]
6233
+ writable: [false],
6234
+ source_catalog: [null],
6235
+ source_schema: [null],
6236
+ source_table: [null]
6208
6237
  }, ScanBranchSchema);
6209
6238
  return {
6210
6239
  branches: [serializeBatch(branchBatch)],
@@ -6373,6 +6402,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
6373
6402
  default_schema: result.default_schema ?? "main",
6374
6403
  settings: result.settings ?? [],
6375
6404
  secret_types: result.secret_types ?? [],
6405
+ attach_catalogs: result.attach_catalogs ?? [],
6376
6406
  comment: result.comment ?? null,
6377
6407
  tags: result.tags ?? {},
6378
6408
  supports_column_statistics: result.supports_column_statistics ?? true,
@@ -6959,6 +6989,138 @@ function buildVgiProtocol(config) {
6959
6989
 
6960
6990
  // src/functions/scalar.ts
6961
6991
  init_arrow();
6992
+
6993
+ // src/arguments/argument-spec.ts
6994
+ init_arrow();
6995
+ function safeJson(value) {
6996
+ try {
6997
+ const encoded = JSON.stringify(value);
6998
+ if (encoded === undefined) {
6999
+ return JSON.stringify(String(value));
7000
+ }
7001
+ return encoded;
7002
+ } catch {
7003
+ return JSON.stringify(String(value));
7004
+ }
7005
+ }
7006
+ function formatRange(ge, le, gt, lt) {
7007
+ if (ge === undefined && le === undefined && gt === undefined && lt === undefined) {
7008
+ return;
7009
+ }
7010
+ let low;
7011
+ if (gt !== undefined) {
7012
+ low = `(${gt}`;
7013
+ } else if (ge !== undefined) {
7014
+ low = `[${ge}`;
7015
+ } else {
7016
+ low = "(-inf";
7017
+ }
7018
+ let high;
7019
+ if (lt !== undefined) {
7020
+ high = `${lt})`;
7021
+ } else if (le !== undefined) {
7022
+ high = `${le}]`;
7023
+ } else {
7024
+ high = "+inf)";
7025
+ }
7026
+ return `${low}, ${high}`;
7027
+ }
7028
+ function constraintSpecFields(constraints) {
7029
+ const fields = {};
7030
+ if (constraints === undefined)
7031
+ return fields;
7032
+ if ("default" in constraints && constraints.default !== undefined) {
7033
+ fields.defaultJson = safeJson(constraints.default);
7034
+ }
7035
+ if (constraints.choices !== undefined) {
7036
+ fields.choicesJson = safeJson([...constraints.choices]);
7037
+ }
7038
+ const range = formatRange(constraints.ge, constraints.le, constraints.gt, constraints.lt);
7039
+ if (range !== undefined) {
7040
+ fields.rangeNotation = range;
7041
+ }
7042
+ if (constraints.pattern !== undefined) {
7043
+ fields.pattern = constraints.pattern;
7044
+ }
7045
+ return fields;
7046
+ }
7047
+ function argumentSpecSortKey(spec) {
7048
+ if (typeof spec.position === "number") {
7049
+ return [0, spec.position];
7050
+ }
7051
+ return [1, spec.position];
7052
+ }
7053
+ function argumentSpecsToSchema(specs) {
7054
+ const sorted = [...specs].sort((a, b) => {
7055
+ const ka = argumentSpecSortKey(a);
7056
+ const kb = argumentSpecSortKey(b);
7057
+ if (ka[0] !== kb[0])
7058
+ return ka[0] - kb[0];
7059
+ if (typeof ka[1] === "number" && typeof kb[1] === "number") {
7060
+ return ka[1] - kb[1];
7061
+ }
7062
+ return String(ka[1]).localeCompare(String(kb[1]));
7063
+ });
7064
+ const fields = [];
7065
+ for (const spec of sorted) {
7066
+ const metadata = new Map;
7067
+ if (typeof spec.position === "string") {
7068
+ metadata.set(VGI_ARG_KEY, VGI_ARG_NAMED);
7069
+ }
7070
+ if (spec.isTableInput) {
7071
+ metadata.set(VGI_TYPE_KEY, VGI_TYPE_TABLE);
7072
+ } else if (spec.isAnyType) {
7073
+ metadata.set(VGI_TYPE_KEY, VGI_TYPE_ANY);
7074
+ }
7075
+ if (spec.isVarargs) {
7076
+ metadata.set(VGI_VARARGS_KEY, VGI_VARARGS_TRUE);
7077
+ }
7078
+ if (spec.isConst) {
7079
+ metadata.set(VGI_CONST_KEY, VGI_CONST_TRUE);
7080
+ }
7081
+ if (spec.doc) {
7082
+ metadata.set(VGI_DOC_KEY, spec.doc);
7083
+ }
7084
+ if (spec.defaultJson !== undefined) {
7085
+ metadata.set(VGI_DEFAULT_KEY, spec.defaultJson);
7086
+ }
7087
+ if (spec.choicesJson !== undefined) {
7088
+ metadata.set(VGI_CHOICES_KEY, spec.choicesJson);
7089
+ }
7090
+ if (spec.rangeNotation !== undefined) {
7091
+ metadata.set(VGI_RANGE_KEY, spec.rangeNotation);
7092
+ }
7093
+ if (spec.pattern !== undefined) {
7094
+ metadata.set(VGI_PATTERN_KEY, spec.pattern);
7095
+ }
7096
+ const field3 = field2(spec.name, spec.arrowType, true, metadata.size > 0 ? metadata : undefined);
7097
+ fields.push(field3);
7098
+ }
7099
+ return schema2(fields);
7100
+ }
7101
+ function macroArgumentsSchema(parameters, parameterDefaultValues, parameterDocs) {
7102
+ const docs = parameterDocs ?? {};
7103
+ const defaultTypes = new Map;
7104
+ if (parameterDefaultValues && parameterDefaultValues.length > 0) {
7105
+ const batch = deserializeBatch(parameterDefaultValues);
7106
+ for (const f of batch.schema.fields) {
7107
+ defaultTypes.set(f.name, f.type);
7108
+ }
7109
+ }
7110
+ const fields = [];
7111
+ for (const name of parameters) {
7112
+ const metadata = new Map;
7113
+ const doc = docs[name];
7114
+ if (doc) {
7115
+ metadata.set(VGI_DOC_KEY, doc);
7116
+ }
7117
+ const fieldType = defaultTypes.get(name) ?? nullType2();
7118
+ fields.push(field2(name, fieldType, true, metadata.size > 0 ? metadata : undefined));
7119
+ }
7120
+ return schema2(fields);
7121
+ }
7122
+
7123
+ // src/functions/scalar.ts
6962
7124
  function defineScalarFunction(config) {
6963
7125
  const repr = config.repr ?? "rich";
6964
7126
  const specs = [];
@@ -6972,7 +7134,8 @@ function defineScalarFunction(config) {
6972
7134
  isAnyType: isAny,
6973
7135
  isConst: p.const,
6974
7136
  isVarargs: p.varargs,
6975
- doc: p.doc
7137
+ doc: p.doc,
7138
+ ...constraintSpecFields(p)
6976
7139
  });
6977
7140
  }
6978
7141
  } else {
@@ -7541,72 +7704,6 @@ function defineTableInOutFunction(config) {
7541
7704
  // src/catalog/read-only.ts
7542
7705
  init_arrow();
7543
7706
 
7544
- // src/arguments/argument-spec.ts
7545
- init_arrow();
7546
- function argumentSpecSortKey(spec) {
7547
- if (typeof spec.position === "number") {
7548
- return [0, spec.position];
7549
- }
7550
- return [1, spec.position];
7551
- }
7552
- function argumentSpecsToSchema(specs) {
7553
- const sorted = [...specs].sort((a, b) => {
7554
- const ka = argumentSpecSortKey(a);
7555
- const kb = argumentSpecSortKey(b);
7556
- if (ka[0] !== kb[0])
7557
- return ka[0] - kb[0];
7558
- if (typeof ka[1] === "number" && typeof kb[1] === "number") {
7559
- return ka[1] - kb[1];
7560
- }
7561
- return String(ka[1]).localeCompare(String(kb[1]));
7562
- });
7563
- const fields = [];
7564
- for (const spec of sorted) {
7565
- const metadata = new Map;
7566
- if (typeof spec.position === "string") {
7567
- metadata.set(VGI_ARG_KEY, VGI_ARG_NAMED);
7568
- }
7569
- if (spec.isTableInput) {
7570
- metadata.set(VGI_TYPE_KEY, VGI_TYPE_TABLE);
7571
- } else if (spec.isAnyType) {
7572
- metadata.set(VGI_TYPE_KEY, VGI_TYPE_ANY);
7573
- }
7574
- if (spec.isVarargs) {
7575
- metadata.set(VGI_VARARGS_KEY, VGI_VARARGS_TRUE);
7576
- }
7577
- if (spec.isConst) {
7578
- metadata.set(VGI_CONST_KEY, VGI_CONST_TRUE);
7579
- }
7580
- if (spec.doc) {
7581
- metadata.set(VGI_DOC_KEY, spec.doc);
7582
- }
7583
- const field3 = field2(spec.name, spec.arrowType, true, metadata.size > 0 ? metadata : undefined);
7584
- fields.push(field3);
7585
- }
7586
- return schema2(fields);
7587
- }
7588
- function macroArgumentsSchema(parameters, parameterDefaultValues, parameterDocs) {
7589
- const docs = parameterDocs ?? {};
7590
- const defaultTypes = new Map;
7591
- if (parameterDefaultValues && parameterDefaultValues.length > 0) {
7592
- const batch = deserializeBatch(parameterDefaultValues);
7593
- for (const f of batch.schema.fields) {
7594
- defaultTypes.set(f.name, f.type);
7595
- }
7596
- }
7597
- const fields = [];
7598
- for (const name of parameters) {
7599
- const metadata = new Map;
7600
- const doc = docs[name];
7601
- if (doc) {
7602
- metadata.set(VGI_DOC_KEY, doc);
7603
- }
7604
- const fieldType = defaultTypes.get(name) ?? nullType2();
7605
- fields.push(field2(name, fieldType, true, metadata.size > 0 ? metadata : undefined));
7606
- }
7607
- return schema2(fields);
7608
- }
7609
-
7610
7707
  // src/metadata/resolve.ts
7611
7708
  init_arrow();
7612
7709
  function arrowTypeToName(type) {
@@ -7727,6 +7824,7 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
7727
7824
  this._attachments.set(name, attachOpaqueData);
7728
7825
  const settings = (this._descriptor.settings ?? []).map((s) => serializeSetting(s));
7729
7826
  const secretTypes = (this._descriptor.secretTypes ?? []).map((s) => serializeSecretType(s));
7827
+ const attachCatalogs = (this._descriptor.attachCatalogs ?? []).map((c) => encodeAttachCatalogInfo(c));
7730
7828
  const hasTimeTravel = this._descriptor.schemas.some((s) => s.tables?.some((t) => t.supportsTimeTravel) ?? false);
7731
7829
  return {
7732
7830
  attach_opaque_data: attachOpaqueData,
@@ -7738,6 +7836,7 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
7738
7836
  default_schema: this._descriptor.defaultSchema ?? "main",
7739
7837
  settings,
7740
7838
  secret_types: secretTypes,
7839
+ attach_catalogs: attachCatalogs,
7741
7840
  comment: this._descriptor.comment ?? null,
7742
7841
  tags: this._descriptor.tags ?? {},
7743
7842
  supports_column_statistics: true,
@@ -8764,4 +8863,4 @@ export {
8764
8863
  Arguments
8765
8864
  };
8766
8865
 
8767
- //# debugId=6A376318AEA9632964756E2164756E21
8866
+ //# debugId=5A27AF075D6D5AD464756E2164756E21