@uwdata/mosaic-core 0.12.0 → 0.12.2

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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # mosaic-core
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@uwdata/mosaic-core.svg)](https://www.npmjs.com/package/@uwdata/mosaic-core)
4
+
3
5
  The core Mosaic components: a central coordinator, parameters (`Param`) and selections (`Selection`) for linking scalar values or query predicates (respectively) across Mosaic clients, and filter groups with materialized views of pre-aggregated data. The Mosaic coordinator can send queries either over the network to a backing server (`socket` and `rest` clients) or to a client-side [DuckDB-WASM](https://github.com/duckdb/duckdb-wasm) instance (`wasm` client).
4
6
 
5
7
  The `mosaic-core` facilities are included as part of the [vgplot](https://github.com/uwdata/mosaic/tree/main/packages/vgplot) API.
@@ -83,14 +83,15 @@ var MosaicClient = class {
83
83
  }
84
84
  /**
85
85
  * Return an array of fields queried by this client.
86
- * @returns {object[]|null} The fields to retrieve info for.
86
+ * @returns {import('./types.js').FieldInfoRequest[] | null}
87
+ * The fields to retrieve info for.
87
88
  */
88
89
  fields() {
89
90
  return null;
90
91
  }
91
92
  /**
92
93
  * Called by the coordinator to set the field info for this client.
93
- * @param {*} info The field info result.
94
+ * @param {import('./types.js').FieldInfo[]} info The field info result.
94
95
  * @returns {this}
95
96
  */
96
97
  fieldInfo(info) {
@@ -4211,7 +4212,7 @@ function collectAggregates(root) {
4211
4212
  function collectColumns(root) {
4212
4213
  const cols = {};
4213
4214
  walk(root, (node) => {
4214
- if (node.type === COLUMN_REF) {
4215
+ if (node.type === COLUMN_REF || node.type === COLUMN_PARAM) {
4215
4216
  cols[node] = node;
4216
4217
  }
4217
4218
  });
@@ -4874,7 +4875,7 @@ var statMap = {
4874
4875
  [Min]: min,
4875
4876
  [Nulls]: (column2) => count().where(isNull(column2))
4876
4877
  };
4877
- function summarize(table, column2, stats) {
4878
+ function summarize({ table, column: column2, stats }) {
4878
4879
  return Query.from(table).select(Array.from(stats, (s) => ({ [s]: statMap[s](column2) })));
4879
4880
  }
4880
4881
  async function queryFieldInfo(mc, fields) {
@@ -4885,7 +4886,7 @@ async function queryFieldInfo(mc, fields) {
4885
4886
  }
4886
4887
  }
4887
4888
  async function getFieldInfo(mc, { table, column: column2, stats }) {
4888
- const q2 = Query.from({ source: table }).select({ column: column2 }).groupby(column2.aggregate ? sql`ALL` : []);
4889
+ const q2 = Query.from({ source: table }).select({ column: column2 }).groupby(isNode(column2) && isAggregateExpression(column2) ? sql`ALL` : []);
4889
4890
  const [desc2] = Array.from(await mc.query(Query.describe(q2)));
4890
4891
  const info = {
4891
4892
  table,
@@ -4894,16 +4895,16 @@ async function getFieldInfo(mc, { table, column: column2, stats }) {
4894
4895
  type: jsType(desc2.column_type),
4895
4896
  nullable: desc2.null === "YES"
4896
4897
  };
4897
- if (!(stats?.length || stats?.size)) return info;
4898
+ if (!stats?.length) return info;
4898
4899
  const [result] = await mc.query(
4899
- summarize(table, column2, stats),
4900
+ summarize({ table, column: column2, stats }),
4900
4901
  { persist: true }
4901
4902
  );
4902
4903
  return Object.assign(info, result);
4903
4904
  }
4904
4905
  async function getTableInfo(mc, table) {
4905
- const result = await mc.query(`DESCRIBE ${asTableRef(table)}`);
4906
- return Array.from(result).map((desc2) => ({
4906
+ const result = Array.from(await mc.query(`DESCRIBE ${asTableRef(table)}`));
4907
+ return result.map((desc2) => ({
4907
4908
  table,
4908
4909
  column: desc2.column_name,
4909
4910
  sqlType: desc2.column_type,
@@ -5519,7 +5520,10 @@ var Coordinator = class {
5519
5520
  * or a SQL string.
5520
5521
  * @param {object} [options] An options object.
5521
5522
  * @param {'arrow' | 'json'} [options.type] The query result format type.
5522
- * @param {boolean} [options.cache=true] If true, cache the query result.
5523
+ * @param {boolean} [options.cache=true] If true, cache the query result
5524
+ * client-side within the QueryManager.
5525
+ * @param {boolean} [options.persist] If true, request the database
5526
+ * server to persist a cached query server-side.
5523
5527
  * @param {number} [options.priority] The query priority, defaults to
5524
5528
  * `Priority.Normal`.
5525
5529
  * @returns {QueryResult} A query result promise.
@@ -18624,7 +18628,7 @@ function clausePoint(field2, value, {
18624
18628
  source,
18625
18629
  clients = source ? /* @__PURE__ */ new Set([source]) : void 0
18626
18630
  }) {
18627
- const predicate = value !== void 0 ? isNotDistinct(field2, literal(value)) : null;
18631
+ const predicate = value !== void 0 ? isIn(field2, [literal(value)]) : null;
18628
18632
  return {
18629
18633
  meta: { type: "point" },
18630
18634
  source,
@@ -18773,6 +18777,8 @@ export {
18773
18777
  isArrowTable,
18774
18778
  isParam,
18775
18779
  isSelection,
18780
+ jsType,
18781
+ queryFieldInfo,
18776
18782
  restConnector,
18777
18783
  socketConnector,
18778
18784
  synchronizer,