@nshiab/simple-data-analysis-core 2.0.5 → 2.0.7

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 (244) hide show
  1. package/README.md +118 -12
  2. package/esm/class/Simple.d.ts +8 -2
  3. package/esm/class/Simple.d.ts.map +1 -1
  4. package/esm/class/Simple.js +9 -3
  5. package/esm/class/SimpleDB.d.ts +72 -1
  6. package/esm/class/SimpleDB.d.ts.map +1 -1
  7. package/esm/class/SimpleDB.js +81 -1
  8. package/esm/class/SimpleTable.d.ts +271 -288
  9. package/esm/class/SimpleTable.d.ts.map +1 -1
  10. package/esm/class/SimpleTable.js +269 -340
  11. package/esm/helpers/LogValue.d.ts +8 -0
  12. package/esm/helpers/LogValue.d.ts.map +1 -0
  13. package/esm/helpers/LogValue.js +23 -0
  14. package/esm/helpers/cacheTableDependencies.d.ts +9 -0
  15. package/esm/helpers/cacheTableDependencies.d.ts.map +1 -1
  16. package/esm/helpers/cacheTableDependencies.js +131 -21
  17. package/esm/helpers/cleanSQL.d.ts +1 -1
  18. package/esm/helpers/cleanSQL.d.ts.map +1 -1
  19. package/esm/helpers/cleanSQL.js +268 -23
  20. package/esm/helpers/flushAllTables.d.ts.map +1 -1
  21. package/esm/helpers/flushAllTables.js +23 -28
  22. package/esm/helpers/foldIdentifier.d.ts +3 -0
  23. package/esm/helpers/foldIdentifier.d.ts.map +1 -0
  24. package/esm/helpers/foldIdentifier.js +4 -0
  25. package/esm/helpers/geometryFromJSON.d.ts +3 -0
  26. package/esm/helpers/geometryFromJSON.d.ts.map +1 -0
  27. package/esm/helpers/geometryFromJSON.js +4 -0
  28. package/esm/helpers/index.d.ts +1 -0
  29. package/esm/helpers/index.d.ts.map +1 -1
  30. package/esm/helpers/index.js +1 -0
  31. package/esm/helpers/logData.d.ts.map +1 -1
  32. package/esm/helpers/logData.js +45 -44
  33. package/esm/helpers/makeLogConverter.d.ts +5 -0
  34. package/esm/helpers/makeLogConverter.d.ts.map +1 -0
  35. package/esm/helpers/makeLogConverter.js +64 -0
  36. package/esm/helpers/osmFiles.d.ts.map +1 -1
  37. package/esm/helpers/parseTypes.d.ts +1 -1
  38. package/esm/helpers/parseTypes.d.ts.map +1 -1
  39. package/esm/helpers/parseTypes.js +4 -0
  40. package/esm/helpers/pendingOps.d.ts +4 -2
  41. package/esm/helpers/pendingOps.d.ts.map +1 -1
  42. package/esm/helpers/prepareGeometry.d.ts +3 -0
  43. package/esm/helpers/prepareGeometry.d.ts.map +1 -0
  44. package/esm/helpers/prepareGeometry.js +99 -0
  45. package/esm/helpers/prepareJSON.d.ts +3 -0
  46. package/esm/helpers/prepareJSON.d.ts.map +1 -0
  47. package/esm/helpers/prepareJSON.js +50 -0
  48. package/esm/helpers/printTable.d.ts +5 -4
  49. package/esm/helpers/printTable.d.ts.map +1 -1
  50. package/esm/helpers/printTable.js +32 -36
  51. package/esm/helpers/queryDB.js +1 -1
  52. package/esm/helpers/queueAsyncBarrier.d.ts +4 -0
  53. package/esm/helpers/queueAsyncBarrier.d.ts.map +1 -1
  54. package/esm/helpers/queueAsyncBarrier.js +4 -0
  55. package/esm/helpers/queueOp.d.ts.map +1 -1
  56. package/esm/helpers/queueOp.js +5 -3
  57. package/esm/helpers/readMutationRows.d.ts +9 -0
  58. package/esm/helpers/readMutationRows.d.ts.map +1 -0
  59. package/esm/helpers/readMutationRows.js +94 -0
  60. package/esm/helpers/referencedTables.d.ts +9 -0
  61. package/esm/helpers/referencedTables.d.ts.map +1 -0
  62. package/esm/helpers/referencedTables.js +22 -0
  63. package/esm/helpers/runQuery.d.ts.map +1 -1
  64. package/esm/helpers/runQuery.js +11 -13
  65. package/esm/helpers/scanSQL.d.ts +7 -0
  66. package/esm/helpers/scanSQL.d.ts.map +1 -0
  67. package/esm/helpers/scanSQL.js +71 -0
  68. package/esm/helpers/tableRegistry.d.ts +2 -0
  69. package/esm/helpers/tableRegistry.d.ts.map +1 -1
  70. package/esm/helpers/tableRegistry.js +12 -4
  71. package/esm/helpers/updateColumnsWithJS.d.ts +52 -0
  72. package/esm/helpers/updateColumnsWithJS.d.ts.map +1 -0
  73. package/esm/helpers/updateColumnsWithJS.js +139 -0
  74. package/esm/methods/addColumn.d.ts +1 -1
  75. package/esm/methods/addColumn.d.ts.map +1 -1
  76. package/esm/methods/bins.d.ts +1 -1
  77. package/esm/methods/bins.d.ts.map +1 -1
  78. package/esm/methods/bins.js +45 -29
  79. package/esm/methods/bm25.d.ts.map +1 -1
  80. package/esm/methods/bm25.js +1 -2
  81. package/esm/methods/cache.d.ts.map +1 -1
  82. package/esm/methods/cache.js +4 -6
  83. package/esm/methods/convert.d.ts +2 -2
  84. package/esm/methods/convert.d.ts.map +1 -1
  85. package/esm/methods/convert.js +5 -0
  86. package/esm/methods/getBottom.d.ts +1 -1
  87. package/esm/methods/getBottom.d.ts.map +1 -1
  88. package/esm/methods/getBottom.js +2 -2
  89. package/esm/methods/getData.d.ts +1 -1
  90. package/esm/methods/getData.d.ts.map +1 -1
  91. package/esm/methods/getData.js +2 -2
  92. package/esm/methods/join.d.ts.map +1 -1
  93. package/esm/methods/join.js +8 -16
  94. package/esm/methods/joinGeo.d.ts.map +1 -1
  95. package/esm/methods/joinGeo.js +10 -19
  96. package/esm/methods/loadArray.d.ts +1 -1
  97. package/esm/methods/loadArray.d.ts.map +1 -1
  98. package/esm/methods/loadArray.js +74 -19
  99. package/esm/methods/loadData.js +3 -0
  100. package/esm/methods/log.d.ts +7 -0
  101. package/esm/methods/log.d.ts.map +1 -0
  102. package/esm/methods/log.js +63 -0
  103. package/esm/methods/logBottom.d.ts +5 -0
  104. package/esm/methods/logBottom.d.ts.map +1 -0
  105. package/esm/methods/logBottom.js +9 -0
  106. package/esm/methods/removeTable.d.ts.map +1 -1
  107. package/esm/methods/removeTable.js +2 -0
  108. package/esm/methods/removeTables.d.ts.map +1 -1
  109. package/esm/methods/removeTables.js +7 -0
  110. package/esm/methods/renameTable.d.ts.map +1 -1
  111. package/esm/methods/renameTable.js +4 -0
  112. package/esm/methods/rowToText.js +2 -2
  113. package/esm/methods/selectTables.d.ts.map +1 -1
  114. package/esm/methods/selectTables.js +6 -0
  115. package/esm/methods/setTypes.d.ts +1 -1
  116. package/esm/methods/setTypes.d.ts.map +1 -1
  117. package/esm/methods/stream.d.ts.map +1 -1
  118. package/esm/methods/stream.js +2 -1
  119. package/esm/methods/updateWithJS.d.ts +1 -3
  120. package/esm/methods/updateWithJS.d.ts.map +1 -1
  121. package/esm/methods/updateWithJS.js +123 -37
  122. package/llm.md +365 -461
  123. package/llms.txt +1 -1
  124. package/package.json +1 -1
  125. package/script/class/Simple.d.ts +8 -2
  126. package/script/class/Simple.d.ts.map +1 -1
  127. package/script/class/Simple.js +9 -3
  128. package/script/class/SimpleDB.d.ts +72 -1
  129. package/script/class/SimpleDB.d.ts.map +1 -1
  130. package/script/class/SimpleDB.js +81 -1
  131. package/script/class/SimpleTable.d.ts +271 -288
  132. package/script/class/SimpleTable.d.ts.map +1 -1
  133. package/script/class/SimpleTable.js +269 -340
  134. package/script/helpers/LogValue.d.ts +8 -0
  135. package/script/helpers/LogValue.d.ts.map +1 -0
  136. package/script/helpers/LogValue.js +26 -0
  137. package/script/helpers/cacheTableDependencies.d.ts +9 -0
  138. package/script/helpers/cacheTableDependencies.d.ts.map +1 -1
  139. package/script/helpers/cacheTableDependencies.js +170 -20
  140. package/script/helpers/cleanSQL.d.ts +1 -1
  141. package/script/helpers/cleanSQL.d.ts.map +1 -1
  142. package/script/helpers/cleanSQL.js +271 -23
  143. package/script/helpers/flushAllTables.d.ts.map +1 -1
  144. package/script/helpers/flushAllTables.js +24 -29
  145. package/script/helpers/foldIdentifier.d.ts +3 -0
  146. package/script/helpers/foldIdentifier.d.ts.map +1 -0
  147. package/script/helpers/foldIdentifier.js +7 -0
  148. package/script/helpers/geometryFromJSON.d.ts +3 -0
  149. package/script/helpers/geometryFromJSON.d.ts.map +1 -0
  150. package/script/helpers/geometryFromJSON.js +7 -0
  151. package/script/helpers/index.d.ts +1 -0
  152. package/script/helpers/index.d.ts.map +1 -1
  153. package/script/helpers/index.js +3 -1
  154. package/script/helpers/logData.d.ts.map +1 -1
  155. package/script/helpers/logData.js +45 -44
  156. package/script/helpers/makeLogConverter.d.ts +5 -0
  157. package/script/helpers/makeLogConverter.d.ts.map +1 -0
  158. package/script/helpers/makeLogConverter.js +70 -0
  159. package/script/helpers/osmFiles.d.ts.map +1 -1
  160. package/script/helpers/parseTypes.d.ts +1 -1
  161. package/script/helpers/parseTypes.d.ts.map +1 -1
  162. package/script/helpers/parseTypes.js +4 -0
  163. package/script/helpers/pendingOps.d.ts +4 -2
  164. package/script/helpers/pendingOps.d.ts.map +1 -1
  165. package/script/helpers/prepareGeometry.d.ts +3 -0
  166. package/script/helpers/prepareGeometry.d.ts.map +1 -0
  167. package/script/helpers/prepareGeometry.js +102 -0
  168. package/script/helpers/prepareJSON.d.ts +3 -0
  169. package/script/helpers/prepareJSON.d.ts.map +1 -0
  170. package/script/helpers/prepareJSON.js +53 -0
  171. package/script/helpers/printTable.d.ts +5 -4
  172. package/script/helpers/printTable.d.ts.map +1 -1
  173. package/script/helpers/printTable.js +32 -36
  174. package/script/helpers/queryDB.js +1 -1
  175. package/script/helpers/queueAsyncBarrier.d.ts +4 -0
  176. package/script/helpers/queueAsyncBarrier.d.ts.map +1 -1
  177. package/script/helpers/queueAsyncBarrier.js +4 -0
  178. package/script/helpers/queueOp.d.ts.map +1 -1
  179. package/script/helpers/queueOp.js +4 -2
  180. package/script/helpers/readMutationRows.d.ts +9 -0
  181. package/script/helpers/readMutationRows.d.ts.map +1 -0
  182. package/script/helpers/readMutationRows.js +97 -0
  183. package/script/helpers/referencedTables.d.ts +9 -0
  184. package/script/helpers/referencedTables.d.ts.map +1 -0
  185. package/script/helpers/referencedTables.js +28 -0
  186. package/script/helpers/runQuery.d.ts.map +1 -1
  187. package/script/helpers/runQuery.js +11 -13
  188. package/script/helpers/scanSQL.d.ts +7 -0
  189. package/script/helpers/scanSQL.d.ts.map +1 -0
  190. package/script/helpers/scanSQL.js +74 -0
  191. package/script/helpers/tableRegistry.d.ts +2 -0
  192. package/script/helpers/tableRegistry.d.ts.map +1 -1
  193. package/script/helpers/tableRegistry.js +16 -4
  194. package/script/helpers/updateColumnsWithJS.d.ts +52 -0
  195. package/script/helpers/updateColumnsWithJS.d.ts.map +1 -0
  196. package/script/helpers/updateColumnsWithJS.js +145 -0
  197. package/script/methods/addColumn.d.ts +1 -1
  198. package/script/methods/addColumn.d.ts.map +1 -1
  199. package/script/methods/bins.d.ts +1 -1
  200. package/script/methods/bins.d.ts.map +1 -1
  201. package/script/methods/bins.js +45 -29
  202. package/script/methods/bm25.d.ts.map +1 -1
  203. package/script/methods/bm25.js +1 -2
  204. package/script/methods/cache.d.ts.map +1 -1
  205. package/script/methods/cache.js +3 -5
  206. package/script/methods/convert.d.ts +2 -2
  207. package/script/methods/convert.d.ts.map +1 -1
  208. package/script/methods/convert.js +5 -0
  209. package/script/methods/getBottom.d.ts +1 -1
  210. package/script/methods/getBottom.d.ts.map +1 -1
  211. package/script/methods/getBottom.js +2 -2
  212. package/script/methods/getData.d.ts +1 -1
  213. package/script/methods/getData.d.ts.map +1 -1
  214. package/script/methods/getData.js +2 -2
  215. package/script/methods/join.d.ts.map +1 -1
  216. package/script/methods/join.js +8 -16
  217. package/script/methods/joinGeo.d.ts.map +1 -1
  218. package/script/methods/joinGeo.js +10 -19
  219. package/script/methods/loadArray.d.ts +1 -1
  220. package/script/methods/loadArray.d.ts.map +1 -1
  221. package/script/methods/loadArray.js +74 -19
  222. package/script/methods/loadData.js +3 -0
  223. package/script/methods/log.d.ts +7 -0
  224. package/script/methods/log.d.ts.map +1 -0
  225. package/script/methods/log.js +69 -0
  226. package/script/methods/logBottom.d.ts +5 -0
  227. package/script/methods/logBottom.d.ts.map +1 -0
  228. package/script/methods/logBottom.js +15 -0
  229. package/script/methods/removeTable.d.ts.map +1 -1
  230. package/script/methods/removeTable.js +2 -0
  231. package/script/methods/removeTables.d.ts.map +1 -1
  232. package/script/methods/removeTables.js +7 -0
  233. package/script/methods/renameTable.d.ts.map +1 -1
  234. package/script/methods/renameTable.js +4 -0
  235. package/script/methods/rowToText.js +2 -2
  236. package/script/methods/selectTables.d.ts.map +1 -1
  237. package/script/methods/selectTables.js +6 -0
  238. package/script/methods/setTypes.d.ts +1 -1
  239. package/script/methods/setTypes.d.ts.map +1 -1
  240. package/script/methods/stream.d.ts.map +1 -1
  241. package/script/methods/stream.js +2 -1
  242. package/script/methods/updateWithJS.d.ts +1 -3
  243. package/script/methods/updateWithJS.d.ts.map +1 -1
  244. package/script/methods/updateWithJS.js +122 -36
@@ -15,6 +15,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  var _SimpleTable_name;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const logBottom_js_1 = __importDefault(require("../methods/logBottom.js"));
19
+ const log_js_1 = __importDefault(require("../methods/log.js"));
18
20
  const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier.js"));
19
21
  const csvFormat_js_1 = __importDefault(require("../helpers/csvFormat.js"));
20
22
  const getDescription_js_1 = __importDefault(require("../methods/getDescription.js"));
@@ -228,7 +230,7 @@ class SimpleTable extends Simple_js_1.default {
228
230
  * @param simpleDB - The SimpleDB instance that this table belongs to.
229
231
  * @param options - An optional object with configuration options:
230
232
  * @param options.rowsToLog - The number of rows to log when displaying table data.
231
- * @param options.charsToLog - The maximum number of characters to log for strings. Useful to avoid logging large text content.
233
+ * @param options.charsToLog - The maximum characters to display for text and stringified nested cells, including truncation markers (default: 75). Independent of column width. Use Infinity for unlimited text.
232
234
  * @param options.typesToLog - A boolean indicating whether to include data types when logging a table.
233
235
  * @category Constructor
234
236
  */
@@ -304,6 +306,7 @@ class SimpleTable extends Simple_js_1.default {
304
306
  }
305
307
  /**
306
308
  * Renames the current table.
309
+ * The new name must not belong to another registered table, ignoring ASCII letter case.
307
310
  *
308
311
  * @param name - The new name for the table.
309
312
  * @returns A promise that resolves to the renamed table.
@@ -325,9 +328,7 @@ class SimpleTable extends Simple_js_1.default {
325
328
  * Sets the data types for columns in a new table. If the table already exists, it will be replaced.
326
329
  * To convert the types of an existing table, use the `.convert()` method instead.
327
330
  *
328
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
329
- *
330
- * @param types - An object specifying the column names and their target data types (JavaScript or SQL types).
331
+ * @param types - An object specifying the column names and their target data types (JavaScript or SQL types), including JSON, FLOAT[n] vectors, and GEOMETRY with a CRS.
331
332
  * @returns The table, so methods can be chained.
332
333
  * @category Table Management
333
334
  *
@@ -340,28 +341,43 @@ class SimpleTable extends Simple_js_1.default {
340
341
  * raise: "float",
341
342
  * }).log();
342
343
  * ```
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * // Create an empty table with JSON, embedding, and geometry columns.
348
+ * await table.setTypes({
349
+ * details: "JSON",
350
+ * embedding: "FLOAT[3]",
351
+ * geom: "GEOMETRY('EPSG:4326')",
352
+ * }).log();
353
+ * ```
343
354
  */
344
355
  setTypes(types) {
345
356
  (0, setTypes_js_1.default)(this, types);
346
357
  return this;
347
358
  }
348
359
  /**
349
- * Loads an array of JavaScript objects into the table. Types can also be specified for individual columns instead of inferred from their values. This method queues the load; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
360
+ * Loads an array of JavaScript objects into the table. Types are inferred for
361
+ * numbers, bigints, strings, booleans, and Date values. Array and object cells
362
+ * require an explicit supported type in columnTypes. Types can also be
363
+ * specified for scalar columns instead of inferred from their values.
350
364
  *
351
365
  * JavaScript `Date` values are inferred as DuckDB `TIMESTAMP` values. Their
352
366
  * instant is preserved, but JavaScript `Date` does not retain the timezone or
353
- * offset originally used to construct it. String values remain `VARCHAR`;
354
- * use `convert()` to parse them as temporal values.
367
+ * offset originally used to construct it.
368
+ *
369
+ * Declare `JSON` for general nested data, `FLOAT[n]` for a fixed-size float
370
+ * vector, or `GEOMETRY('EPSG:4326')` for GeoJSON geometries in WGS84.
355
371
  *
356
372
  * @param rows - An array of objects, where each object represents a row and its properties represent columns.
357
373
  * @param options - Options for loading the array, captured when called.
358
- * @param options.columnTypes - Types for specific columns; omitted columns are inferred. Values must be compatible with the selected type without losing information.
374
+ * @param options.columnTypes - Types for specific columns. Required for array and object cells; omitted scalar columns are inferred, and all-null columns default to VARCHAR. Values must be compatible with the selected type without losing information.
359
375
  * @returns The table, so methods can be chained.
360
376
  * @category Importing Data
361
377
  *
362
378
  * @example
363
379
  * ```ts
364
- * // Load data from an array of objects
380
+ * // Load scalar columns without columnTypes; strings and numbers are inferred.
365
381
  * const data = [
366
382
  * { letter: "a", number: 1 },
367
383
  * { letter: "b", number: 2 }
@@ -371,7 +387,7 @@ class SimpleTable extends Simple_js_1.default {
371
387
  *
372
388
  * @example
373
389
  * ```ts
374
- * // Specify a numeric type for an all-null column
390
+ * // Choose a numeric type when all-null values provide nothing to infer.
375
391
  * await table.loadArray(
376
392
  * [{ name: "A", value: null }, { name: "B", value: null }],
377
393
  * { columnTypes: { value: "DOUBLE" } },
@@ -380,12 +396,39 @@ class SimpleTable extends Simple_js_1.default {
380
396
  *
381
397
  * @example
382
398
  * ```ts
383
- * // The offset determines the instant; the loaded TIMESTAMP is returned as
384
- * // the equivalent UTC JavaScript Date.
399
+ * // Store the Date as a UTC timestamp with JavaScript's millisecond precision.
400
+ * // The original -04:00 offset is not retained.
385
401
  * await table.loadArray([{
386
402
  * observedAt: new Date("2024-04-07T13:00:00-04:00"),
387
403
  * }]).log();
388
404
  * ```
405
+ *
406
+ * @example
407
+ * ```ts
408
+ * // Declare JSON to load nested objects and variable-length arrays directly.
409
+ * await table.loadArray([{
410
+ * name: "Station",
411
+ * metadata: { active: true, tags: ["weather", "urban"] },
412
+ * measurements: [1, 2.5, null],
413
+ * }], { columnTypes: { metadata: "JSON", measurements: "JSON" } }).log();
414
+ * ```
415
+ *
416
+ * @example
417
+ * ```ts
418
+ * // Declare FLOAT[3] to store each three-element array as a fixed-size vector.
419
+ * await table.loadArray([{ vector: [1, 2, 3] }], {
420
+ * columnTypes: { vector: "FLOAT[3]" },
421
+ * }).log();
422
+ * ```
423
+ *
424
+ * @example
425
+ * ```ts
426
+ * // Declare a geometry type to store WGS84 GeoJSON as a spatial column.
427
+ * await table.loadArray([{
428
+ * name: "Montreal",
429
+ * geom: { type: "Point", coordinates: [-73.57, 45.50] },
430
+ * }], { columnTypes: { geom: "GEOMETRY('EPSG:4326')" } }).log();
431
+ * ```
389
432
  */
390
433
  loadArray(rows, options = {}) {
391
434
  (0, loadArray_js_1.default)(this, rows, options);
@@ -394,17 +437,18 @@ class SimpleTable extends Simple_js_1.default {
394
437
  /**
395
438
  * Loads data from one or more local or remote files into the table.
396
439
  * Supported file formats include CSV, JSON, Parquet, and Excel.
397
- * This method queues the load; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
440
+ *
441
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
398
442
  *
399
443
  * @param files - The path(s) or URL(s) of the file(s) containing the data to be loaded.
400
444
  * @param options - An optional object with configuration options:
401
445
  * @param options.fileType - The type of file to load ("csv", "dsv", "json", "parquet", "excel"). Defaults to being inferred from the file extension.
402
446
  * @param options.autoDetect - A boolean indicating whether to automatically detect the data format. Defaults to `true`.
403
- * @param options.conditions - A SQL `WHERE` clause expression, without the `WHERE` keyword, to filter source rows before applying `limit`. Uses the same syntax as `filter()`, including JavaScript operators. Can reference source columns excluded from `columns`. Defaults to no filtering; an empty string behaves the same as omitting this option.
447
+ * @param options.conditions - A SQL `WHERE` clause expression, without the `WHERE` keyword, to filter source rows before applying `limit`. Can reference source columns excluded from `columns`.
404
448
  * @param options.limit - A number indicating the maximum number of matching rows to load, after applying `conditions` if provided. Defaults to all matching rows.
405
449
  * @param options.includeFilename - A boolean indicating whether to include the filename as a new column in the loaded data. Defaults to `false`.
406
450
  * @param options.unifyColumns - A boolean indicating whether to unify columns across multiple files when their structures differ. Missing columns will be filled with `NULL` values. Defaults to `false`.
407
- * @param options.columnTypes - An object mapping column names to their expected data types. By default, types are inferred.
451
+ * @param options.columnTypes - An object mapping column names to their expected data types. By default, types are inferred. Geometry types are not supported; use loadGeoData() instead.
408
452
  * @param options.columns - An array of column names to load. When provided, only the specified columns are loaded, reducing memory usage and improving load times. Not supported for Excel files — combining `columns` with Excel files throws an error. If an invalid column name is provided, DuckDB will throw its native error. An empty array behaves the same as omitting the option (loads all columns). Defaults to loading all columns.
409
453
  * @param options.header - A boolean indicating whether the file has a header row. Applicable to CSV files. Defaults to `true`.
410
454
  * @param options.allText - A boolean indicating whether all columns should be treated as text. Applicable to CSV files. Defaults to `false`.
@@ -481,8 +525,6 @@ class SimpleTable extends Simple_js_1.default {
481
525
  }
482
526
  /**
483
527
  * Downloads a complete Statistics Canada table and loads it into this table.
484
- * The method queues the download and load; they run when an async observer
485
- * method (like `getData()` or `log()`) is awaited, or when `run()` is called.
486
528
  *
487
529
  * Results are cached as Parquet files in `.sda-cache/statcan` by default.
488
530
  * Cached data does not expire unless a TTL is provided.
@@ -536,9 +578,6 @@ class SimpleTable extends Simple_js_1.default {
536
578
  * research, and journalistic purposes. Before using it, review Yahoo's terms
537
579
  * and any applicable data-provider restrictions.
538
580
  *
539
- * The method queues the download and load; they run when an async observer
540
- * method (like `getData()` or `log()`) is awaited, or when `run()` is called.
541
- *
542
581
  * @param symbol - The stock or index symbol, such as `"AAPL"` or `"^GSPTSE"`.
543
582
  * @param startDate - The inclusive UTC start of the requested range.
544
583
  * @param endDate - The inclusive UTC end of the requested range. The UTC day,
@@ -585,14 +624,13 @@ class SimpleTable extends Simple_js_1.default {
585
624
  }
586
625
  /**
587
626
  * Loads geospatial data from an external file or URL into the table.
588
- *
589
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
627
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
590
628
  *
591
629
  * @param file - The path or URL of the external file containing the geospatial data.
592
630
  * @param options - An optional object with configuration options:
593
631
  * @param options.toEPSG4326 - If `true`, the method will attempt to reproject the data to EPSG:4326 (WGS84).
594
632
  * @param options.columns - The columns to load. Include the geometry column that should remain in the resulting table, usually `"geom"`. By default, all columns are loaded.
595
- * @param options.conditions - A SQL `WHERE` clause expression, without the `WHERE` keyword, to filter source rows before materialization and reprojection. Uses the same syntax as `filter()`, including JavaScript operators. Can reference source columns excluded from `columns`. Geometry conditions use the source coordinate system. Defaults to no filtering; an empty string behaves the same as omitting this option.
633
+ * @param options.conditions - A SQL `WHERE` clause expression, without the `WHERE` keyword, to filter source rows before materialization and reprojection. Can reference source columns excluded from `columns`. Geometry conditions use the source coordinate system.
596
634
  * @returns The table, so methods can be chained.
597
635
  * @category Geospatial
598
636
  *
@@ -646,7 +684,7 @@ class SimpleTable extends Simple_js_1.default {
646
684
  return this;
647
685
  }
648
686
  /**
649
- * Loads OpenStreetMap data into the table from a local `.osm` or `.osm.pbf` file, a remote file URL, or an Overpass bounding-box query. Pass a path or URL string to load an existing file, or pass a bounding box with `filters` to download matching features. The method queues the load; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
687
+ * Loads OpenStreetMap data into the table from a local `.osm` or `.osm.pbf` file, a remote file URL, or an Overpass bounding-box query. Pass a path or URL string to load an existing file, or pass a bounding box with `filters` to download matching features.
650
688
  *
651
689
  * DuckDB's [Osmium community extension](https://duckdb.org/community_extensions/extensions/osmium) materializes the complete result and reconstructs `geom` as EPSG:4326. By default, that canonical result is cached as GeoParquet in `.sda-cache/osm`. Distinct paths, local file fingerprints, normalized URLs, endpoints, queries, and bounding boxes retain independent entries. The cache has no expiration unless `ttl` is set and can be cleared by removing `.sda-cache/osm`. Immutable URLs can safely use the default indefinite cache; mutable URLs should set a TTL.
652
690
  *
@@ -733,8 +771,6 @@ class SimpleTable extends Simple_js_1.default {
733
771
  * DuckDB FTS indexes do not update automatically when the table changes; use
734
772
  * `overwrite: true` to rebuild the index after modifying the table.
735
773
  *
736
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
737
- *
738
774
  * @param idColumn - The column containing the document identifiers.
739
775
  * @param textColumn - The column containing the text to search.
740
776
  * @param options - An optional object with configuration options:
@@ -793,8 +829,6 @@ class SimpleTable extends Simple_js_1.default {
793
829
  * If a VSS index already exists on the table, this method will skip creation and log a message (when verbose is enabled), unless the `overwrite` option is set to `true`.
794
830
  * The index definition is recorded in {@link indexes}.
795
831
  *
796
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
797
- *
798
832
  * @param column - The name of the column containing vector embeddings (must be FLOAT array type).
799
833
  * @param options - An optional object with configuration options:
800
834
  * @param options.overwrite - If `true`, drops and recreates the index even if it already exists. Defaults to `false`.
@@ -855,8 +889,6 @@ class SimpleTable extends Simple_js_1.default {
855
889
  * changes; use `overwriteIndex: true` to rebuild the index after modifying
856
890
  * the table.
857
891
  *
858
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
859
- *
860
892
  * @param text - The search query text to match against the text column.
861
893
  * @param idColumn - The name of the column containing unique identifiers for each row.
862
894
  * @param textColumn - The name of the column containing the text to search.
@@ -958,8 +990,6 @@ class SimpleTable extends Simple_js_1.default {
958
990
  /**
959
991
  * Inserts rows, provided as an array of JavaScript objects, into the table.
960
992
  *
961
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
962
- *
963
993
  * @param rows - An array of objects, where each object represents a row to be inserted and its properties correspond to column names.
964
994
  * @returns The table, so methods can be chained.
965
995
  * @category Importing Data
@@ -979,7 +1009,7 @@ class SimpleTable extends Simple_js_1.default {
979
1009
  return this;
980
1010
  }
981
1011
  /**
982
- * Inserts all rows from one or more other tables into this table. If tables do not have the same columns, an error will be thrown unless the `unifyColumns` option is set to `true`. This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1012
+ * Inserts all rows from one or more other tables into this table. If tables do not have the same columns, an error will be thrown unless the `unifyColumns` option is set to `true`.
983
1013
  *
984
1014
  * @param tables - The name(s) of the table(s) or SimpleTable instance(s) from which rows will be inserted.
985
1015
  * @param options - An optional object with configuration options:
@@ -1012,8 +1042,6 @@ class SimpleTable extends Simple_js_1.default {
1012
1042
  /**
1013
1043
  * Fetches sample data from the simple-data-analysis-core GitHub repository.
1014
1044
  *
1015
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1016
- *
1017
1045
  * @param sample - The name of the sample to load.
1018
1046
  *
1019
1047
  * Tabular data:
@@ -1039,13 +1067,12 @@ class SimpleTable extends Simple_js_1.default {
1039
1067
  }
1040
1068
  /**
1041
1069
  * Returns a new table with the same structure and data as this table. The data can be optionally filtered, limited to a specific number of rows, and offset.
1070
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
1042
1071
  *
1043
1072
  * If `conditions`, `limit`, and `offset` are all used, they are applied in this order: `conditions` (WHERE clause) first, then `offset`, and finally `limit` (LIMIT).
1044
1073
  *
1045
1074
  * Note that cloning large tables can be a slow operation.
1046
1075
  *
1047
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1048
- *
1049
1076
  * @param nameOrOptions - Either a string specifying the name of the new table, or an optional object with configuration options. If not provided, a default name (e.g., "table1", "table2") will be generated.
1050
1077
  * @param nameOrOptions.name - The name of the new table to be created in the database. If not provided, a default name (e.g., "table1", "table2") will be generated.
1051
1078
  * @param nameOrOptions.conditions - A SQL `WHERE` clause condition to filter the data during cloning. Defaults to no condition (clones all rows).
@@ -1114,8 +1141,6 @@ class SimpleTable extends Simple_js_1.default {
1114
1141
  /**
1115
1142
  * Clones an existing column in this table, creating a new column with identical values.
1116
1143
  *
1117
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1118
- *
1119
1144
  * @param column - The name of the original column to clone.
1120
1145
  * @param newColumn - The name of the new column to be created.
1121
1146
  * @returns The table, so methods can be chained.
@@ -1137,8 +1162,6 @@ class SimpleTable extends Simple_js_1.default {
1137
1162
  *
1138
1163
  * **Important:** The offset is applied based on the current row order in the table. For meaningful results, ensure your data is sorted appropriately (e.g., by date/time for time-series analysis) before calling this method.
1139
1164
  *
1140
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1141
- *
1142
1165
  * @param column - The name of the original column.
1143
1166
  * @param newColumn - The name of the new column to be created with offset values.
1144
1167
  * @param options - An optional object with configuration options:
@@ -1184,8 +1207,6 @@ class SimpleTable extends Simple_js_1.default {
1184
1207
  /**
1185
1208
  * Fills `NULL` values in specified columns. By default, each `NULL` is replaced with the last non-`NULL` value from the preceding row. When `interpolate` is `true`, `NULL` values are replaced using linear interpolation (or extrapolation at the ends). Pass `interpolateBy` with a real numeric or date column name to use it as the X-axis, so that interpolated values are proportional to the actual distances between X-axis values rather than treating every row as equidistant. When `interpolateBy` is set, `interpolate` is automatically assumed `true`.
1186
1209
  *
1187
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1188
- *
1189
1210
  * @param columns - The column(s) for which to fill `NULL` values.
1190
1211
  * @param options - An optional object with configuration options:
1191
1212
  * @param options.by - A column name or an array of column names to partition by. The fill is applied independently within each group.
@@ -1244,7 +1265,7 @@ class SimpleTable extends Simple_js_1.default {
1244
1265
  * Sorts the rows of the table based on specified column(s) and order(s).
1245
1266
  * If no columns are specified, all columns are sorted from left to right in ascending order.
1246
1267
  *
1247
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called. Order-preserving transformations queued after a sort retain that order. Operations such as joins, grouping, aggregation, and sampling do not guarantee input order; chain `sort()` after them when deterministic output order matters.
1268
+ * Order-preserving transformations after a sort retain that order. Operations such as joins, grouping, aggregation, and sampling do not guarantee input order; chain `sort()` after them when deterministic output order matters.
1248
1269
  *
1249
1270
  * @param order - An object mapping column names to their sorting order: `"asc"` for ascending or `"desc"` for descending. If `null`, all columns are sorted ascendingly.
1250
1271
  * @param options - An optional object with configuration options:
@@ -1281,7 +1302,7 @@ class SimpleTable extends Simple_js_1.default {
1281
1302
  return this;
1282
1303
  }
1283
1304
  /**
1284
- * Selects specific columns in the table, removing all others. This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1305
+ * Selects specific columns in the table, removing all others.
1285
1306
  *
1286
1307
  * @param columns - The name or an array of names of the columns to be selected.
1287
1308
  * @returns The table, so methods can be chained.
@@ -1306,8 +1327,6 @@ class SimpleTable extends Simple_js_1.default {
1306
1327
  /**
1307
1328
  * Skips the first `n` rows of the table, effectively removing them.
1308
1329
  *
1309
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1310
- *
1311
1330
  * @param count - The number of rows to skip from the beginning of the table.
1312
1331
  * @returns The table, so methods can be chained.
1313
1332
  * @category Selecting or Filtering Data
@@ -1343,8 +1362,6 @@ class SimpleTable extends Simple_js_1.default {
1343
1362
  /**
1344
1363
  * Selects random rows from the table, removing all others. You can optionally specify a seed to ensure repeatable sampling.
1345
1364
  *
1346
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1347
- *
1348
1365
  * @param count - The number of rows to select (e.g., `100`) or a percentage string (e.g., `"10%"`) specifying the sampling size.
1349
1366
  * @param options - An optional object with configuration options:
1350
1367
  * @param options.seed - A number specifying the seed for repeatable sampling. Using the same seed will always yield the same random rows. Defaults to a random seed.
@@ -1376,8 +1393,6 @@ class SimpleTable extends Simple_js_1.default {
1376
1393
  /**
1377
1394
  * Selects a specified number of rows from this table. An offset can be applied to skip initial rows, and the results can be output to a new table.
1378
1395
  *
1379
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1380
- *
1381
1396
  * @param count - The number of rows to select.
1382
1397
  * @param options - An optional object with configuration options:
1383
1398
  * @param options.offset - The number of rows to skip from the beginning of the table before selecting. Defaults to `0`.
@@ -1416,8 +1431,6 @@ class SimpleTable extends Simple_js_1.default {
1416
1431
  * Removes duplicate rows from this table, keeping only unique rows.
1417
1432
  * Note that the resulting data order might differ from the original.
1418
1433
  *
1419
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1420
- *
1421
1434
  * @param options - An optional object with configuration options:
1422
1435
  * @param options.on - A column name or an array of column names to consider when identifying duplicates. If specified, duplicates are determined based only on the values in these columns. If omitted, all columns are considered.
1423
1436
  * @returns The table, so methods can be chained.
@@ -1448,7 +1461,6 @@ class SimpleTable extends Simple_js_1.default {
1448
1461
  /**
1449
1462
  * Removes rows with missing values from this table.
1450
1463
  * By default, missing values include SQL `NULL`, as well as string representations like `"NULL"`, `"null"`, `"NaN"`, `"undefined"`, and empty strings `""`.
1451
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1452
1464
  *
1453
1465
  * @param options - An optional object with configuration options:
1454
1466
  * @param options.columns - A string or an array of strings specifying the columns to consider for missing values. If omitted, all columns are considered.
@@ -1486,7 +1498,7 @@ class SimpleTable extends Simple_js_1.default {
1486
1498
  return this;
1487
1499
  }
1488
1500
  /**
1489
- * Trims specified characters from the beginning, end, or both sides of string values in the given columns. This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1501
+ * Trims specified characters from the beginning, end, or both sides of string values in the given columns.
1490
1502
  *
1491
1503
  * @param columns - The column name or an array of column names to trim.
1492
1504
  * @param options - An optional object with configuration options:
@@ -1519,8 +1531,7 @@ class SimpleTable extends Simple_js_1.default {
1519
1531
  }
1520
1532
  /**
1521
1533
  * Filters rows from this table based on SQL conditions. Note that it's often faster to use the `removeRows` method for simple removals.
1522
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
1523
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1534
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
1524
1535
  *
1525
1536
  * @param conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"column1 > 10 AND column2 = 'value'"`).
1526
1537
  * @returns The table, so methods can be chained.
@@ -1557,8 +1568,6 @@ class SimpleTable extends Simple_js_1.default {
1557
1568
  /**
1558
1569
  * Keeps rows in this table that have specific values in specified columns, removing all other rows.
1559
1570
  *
1560
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1561
- *
1562
1571
  * @param columnsAndValues - An object where keys are column names and values are the specific values (or an array of values) to keep in those columns. Use `null` to keep rows where a column is `NULL`.
1563
1572
  * @returns The table, so methods can be chained.
1564
1573
  * @category Selecting or Filtering Data
@@ -1588,8 +1597,6 @@ class SimpleTable extends Simple_js_1.default {
1588
1597
  /**
1589
1598
  * Removes rows from this table that have specific values in specified columns.
1590
1599
  *
1591
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1592
- *
1593
1600
  * @param columnsAndValues - An object where keys are column names and values are the specific values (or an array of values) to remove from those columns. Use `null` to remove rows where a column is `NULL`; otherwise, `NULL` rows are retained.
1594
1601
  * @returns The table, so methods can be chained.
1595
1602
  * @category Selecting or Filtering Data
@@ -1618,9 +1625,7 @@ class SimpleTable extends Simple_js_1.default {
1618
1625
  }
1619
1626
  /**
1620
1627
  * Removes rows from this table based on SQL conditions. This method is similar to `filter()`, but removes rows instead of keeping them.
1621
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
1622
- *
1623
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1628
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
1624
1629
  *
1625
1630
  * @param conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"fruit = 'apple'"`).
1626
1631
  * @returns The table, so methods can be chained.
@@ -1658,8 +1663,6 @@ class SimpleTable extends Simple_js_1.default {
1658
1663
  * Renames one or more columns in the table. Throws if a source column does
1659
1664
  * not exist, so a typo fails loudly instead of being silently ignored.
1660
1665
  *
1661
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1662
- *
1663
1666
  * @param names - An object mapping old column names to their new column names (e.g., `{ "oldName": "newName", "anotherOld": "anotherNew" }`).
1664
1667
  * @param options - Configuration options.
1665
1668
  * @param options.strict - Whether to verify the source columns exist before renaming. Defaults to `true`. Set to `false` to skip the check and its schema lookup when you know the columns exist and are renaming across many tables where the extra round-trip adds up.
@@ -1691,8 +1694,6 @@ class SimpleTable extends Simple_js_1.default {
1691
1694
  /**
1692
1695
  * Cleans column names by removing non-alphanumeric characters and formatting them to camel case.
1693
1696
  *
1694
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1695
- *
1696
1697
  * @returns The table, so methods can be chained.
1697
1698
  * @category Column Operations
1698
1699
  *
@@ -1745,8 +1746,6 @@ class SimpleTable extends Simple_js_1.default {
1745
1746
  * | Sales | 2022 | 75 |
1746
1747
  * | Sales | 2023 | 98 |
1747
1748
  *
1748
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1749
- *
1750
1749
  * @param columns - An array of strings representing the names of the columns to be stacked (unpivoted).
1751
1750
  * @param namesTo - The name of the new column that will contain the original column names (e.g., "Year").
1752
1751
  * @param valuesTo - The name of the new column that will contain the values from the stacked columns (e.g., "Employees").
@@ -1788,8 +1787,6 @@ class SimpleTable extends Simple_js_1.default {
1788
1787
  *
1789
1788
  * When multiple rows share the same `namesFrom`/grouping combination, their `valuesFrom` values are combined with the `options.stat` function (`"sum"` by default).
1790
1789
  *
1791
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1792
- *
1793
1790
  * @param namesFrom - The name of the column containing the values that will be transformed into new column headers (e.g., "Year").
1794
1791
  * @param valuesFrom - The name of the column containing the values to be spread across the new columns (e.g., "Employees").
1795
1792
  * @param options - An optional object with configuration options:
@@ -1814,9 +1811,7 @@ class SimpleTable extends Simple_js_1.default {
1814
1811
  *
1815
1812
  * When converting strings to numbers, commas (often used as thousand separators) will be automatically removed before conversion.
1816
1813
  *
1817
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called. If a column doesn't exist, the error is thrown at that point too.
1818
- *
1819
- * @param types - An object mapping column names to their target data types for conversion.
1814
+ * @param types - An object mapping column names to their target data types for conversion, including JSON, FLOAT[n] vectors, and GEOMETRY with a CRS.
1820
1815
  * @param options - An optional object with configuration options:
1821
1816
  * @param options.strict - If `false`, values that cannot be converted will be replaced by `NULL` instead of throwing an error. Defaults to `true`.
1822
1817
  * @param options.datetimeFormat - A string specifying the format for date and time conversions. Uses `strftime` and `strptime` functions from DuckDB. For format specifiers, see [DuckDB's documentation](https://duckdb.org/docs/sql/functions/dateformat).
@@ -1863,6 +1858,18 @@ class SimpleTable extends Simple_js_1.default {
1863
1858
  * // Convert 'amount' to float, replacing unconvertible values with NULL
1864
1859
  * await table.convert({ amount: "float" }, { strict: false }).log();
1865
1860
  * ```
1861
+ *
1862
+ * @example
1863
+ * ```ts
1864
+ * // Parse JSON, a fixed-size float vector, and WKT geometry from text.
1865
+ * await table.loadArray([{
1866
+ * details: '{"count":3}',
1867
+ * embedding: "[0.25,0.5,0.75]",
1868
+ * geom: "POINT (-73 45)",
1869
+ * }])
1870
+ * .convert({ details: "JSON", embedding: "FLOAT[3]", geom: "GEOMETRY('EPSG:4326')" })
1871
+ * .log();
1872
+ * ```
1866
1873
  */
1867
1874
  convert(types, options = {}) {
1868
1875
  (0, convert_js_1.default)(this, types, options);
@@ -1885,7 +1892,7 @@ class SimpleTable extends Simple_js_1.default {
1885
1892
  return this;
1886
1893
  }
1887
1894
  /**
1888
- * Removes one or more columns from this table. This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1895
+ * Removes one or more columns from this table.
1889
1896
  *
1890
1897
  * @param columns - The name or an array of names of the columns to be removed.
1891
1898
  * @returns The table, so methods can be chained.
@@ -1908,10 +1915,11 @@ class SimpleTable extends Simple_js_1.default {
1908
1915
  return this;
1909
1916
  }
1910
1917
  /**
1911
- * Adds a new column to the table based on a specified data type (JavaScript or SQL types) and a SQL definition. This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1918
+ * Adds a new column to the table based on a specified data type (JavaScript or SQL types) and a SQL definition.
1919
+ * With the default `SimpleDB.expressionSyntax: "js"`, expressions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
1912
1920
  *
1913
1921
  * @param newColumn - The name of the new column to be added.
1914
- * @param type - The data type for the new column. Can be a JavaScript type (e.g., `"number"`, `"string"`) or a SQL type (e.g., `"integer"`, `"varchar"`).
1922
+ * @param type - The data type for the new column. Can be a JavaScript type (e.g., `"number"`, `"string"`) or a SQL type (e.g., `"integer"`, `"varchar"`, `"JSON"`, `"FLOAT[3]"`, `"GEOMETRY('EPSG:4326')"`).
1915
1923
  * @param definition - A SQL expression defining how the values for the new column should be computed (e.g., `"column1 + column2"`, `"ST_Centroid(geom_column)"`).
1916
1924
  * @returns The table, so methods can be chained.
1917
1925
  * @category Column Operations
@@ -1927,6 +1935,25 @@ class SimpleTable extends Simple_js_1.default {
1927
1935
  * // Add a new geometry column 'centroid' using the centroid of an existing 'country' geometry column
1928
1936
  * await table.addColumn("centroid", "geometry('EPSG:4326')", `ST_Centroid("country")`).log();
1929
1937
  * ```
1938
+ *
1939
+ * @example
1940
+ * ```ts
1941
+ * // Read a number from a JSON object into a new column using dot notation.
1942
+ * await table.loadArray([{ details: { count: 3 } }], {
1943
+ * columnTypes: { details: "JSON" },
1944
+ * })
1945
+ * .addColumn("count", "integer", "details.count")
1946
+ * .log();
1947
+ * ```
1948
+ *
1949
+ * @example
1950
+ * ```ts
1951
+ * // Create JSON and fixed-size vector columns with DuckDB expressions.
1952
+ * await table.loadArray([{ count: 3 }])
1953
+ * .addColumn("details", "JSON", "json_object('count', count)")
1954
+ * .addColumn("embedding", "FLOAT[3]", "[0.25, 0.5, 0.75]")
1955
+ * .log();
1956
+ * ```
1930
1957
  */
1931
1958
  addColumn(newColumn, type, definition) {
1932
1959
  (0, addColumn_js_1.default)(this, newColumn, type, definition);
@@ -1946,9 +1973,6 @@ class SimpleTable extends Simple_js_1.default {
1946
1973
  * values produce `NULL` extracted values. Parts extracted from
1947
1974
  * `TIMESTAMP WITH TIME ZONE` values use UTC.
1948
1975
  *
1949
- * This method queues the operation; it runs when an async observer method
1950
- * (like `getData()` or `log()`) is awaited, or when `run()` is called.
1951
- *
1952
1976
  * @param column - The temporal column from which to extract components.
1953
1977
  * @param parts - A part to extract using its name as the new column, or an object mapping each custom new-column name to the part it should contain.
1954
1978
  * @returns The table, so methods can be chained.
@@ -1976,8 +2000,6 @@ class SimpleTable extends Simple_js_1.default {
1976
2000
  /**
1977
2001
  * Adds a new column to the table containing the row number, starting at 0 (like an index).
1978
2002
  *
1979
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1980
- *
1981
2003
  * @param newColumn - The name of the new column that will store the row number.
1982
2004
  * @param options - An optional object with configuration options:
1983
2005
  * @param options.by - A column name or an array of column names to partition by. The row number restarts at 0 within each group.
@@ -2004,8 +2026,6 @@ class SimpleTable extends Simple_js_1.default {
2004
2026
  * Performs a cross join operation with another table. A cross join returns the Cartesian product of the rows from both tables, meaning all possible pairs of rows will be in the resulting table.
2005
2027
  * This means that if the left table has `n` rows and the right table has `m` rows, the result will have `n * m` rows.
2006
2028
  *
2007
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2008
- *
2009
2029
  * @param rightTable - The SimpleTable instance to cross join with.
2010
2030
  * @param options - An optional object with configuration options:
2011
2031
  * @param options.outputTable - If `true`, the results will be stored in a new table with a generated name. If a string, it will be used as the name for the new table. If `false` or omitted, the current table will be overwritten. Defaults to `false`.
@@ -2037,7 +2057,6 @@ class SimpleTable extends Simple_js_1.default {
2037
2057
  * Merges the data of this table (considered the left table) with another table (the right table) based on a common column or multiple columns.
2038
2058
  * Note that the order of rows in the returned data is not guaranteed to be the same as in the original tables.
2039
2059
  * This operation might create temporary files in a `.tmp` folder; consider adding `.tmp` to your `.gitignore`.
2040
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called. The join uses the other table's state as of this call: operations queued on it afterwards run after the join.
2041
2060
  *
2042
2061
  * @param rightTable - The SimpleTable instance to be joined with this table.
2043
2062
  * @param options - An optional object with configuration options:
@@ -2085,8 +2104,6 @@ class SimpleTable extends Simple_js_1.default {
2085
2104
  *
2086
2105
  * This operation might create temporary files in a `.tmp` folder; consider adding `.tmp` to your `.gitignore`.
2087
2106
  *
2088
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called. The join uses the other table's state as of this call: operations queued on it afterwards run after the join.
2089
- *
2090
2107
  * @param rightTable - The SimpleTable instance to be joined with this table.
2091
2108
  * @param leftColumn - The name of the column in this (left) table containing the text to compare.
2092
2109
  * @param rightColumn - The name of the column in the right table containing the text to compare.
@@ -2153,8 +2170,6 @@ class SimpleTable extends Simple_js_1.default {
2153
2170
  * Similarity is computed using the [rapidfuzz](https://query.farm/duckdb_extension_rapidfuzz) DuckDB community extension,
2154
2171
  * which is installed and loaded automatically.
2155
2172
  *
2156
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2157
- *
2158
2173
  * @param column - The name of the column containing the strings to normalize.
2159
2174
  * @param newColumn - The name of the column to write the normalized values to. Use the same name as `column` to normalize in-place.
2160
2175
  * @param threshold - The minimum similarity score (0–100) for two strings to be considered duplicates. For `method: "ratio"`, a length-based pre-filter is automatically applied based on the threshold to improve performance without losing accuracy.
@@ -2208,8 +2223,6 @@ class SimpleTable extends Simple_js_1.default {
2208
2223
  /**
2209
2224
  * Replaces specified strings in the selected columns.
2210
2225
  *
2211
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2212
- *
2213
2226
  * @param columns - The column name, an array of column names, or `"all"` to apply the replacement to every column in the table.
2214
2227
  * @param replacements - An object mapping old strings to new strings (e.g., `{ "oldValue": "newValue" }`).
2215
2228
  * @param options - An optional object with configuration options:
@@ -2253,7 +2266,7 @@ class SimpleTable extends Simple_js_1.default {
2253
2266
  return this;
2254
2267
  }
2255
2268
  /**
2256
- * Converts string values in the specified columns to lowercase. This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2269
+ * Converts string values in the specified columns to lowercase.
2257
2270
  *
2258
2271
  * @param columns - The column name or an array of column names to be converted to lowercase.
2259
2272
  * @returns The table, so methods can be chained.
@@ -2276,7 +2289,7 @@ class SimpleTable extends Simple_js_1.default {
2276
2289
  return this;
2277
2290
  }
2278
2291
  /**
2279
- * Converts string values in the specified columns to uppercase. This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2292
+ * Converts string values in the specified columns to uppercase.
2280
2293
  *
2281
2294
  * @param columns - The column name or an array of column names to be converted to uppercase.
2282
2295
  * @returns The table, so methods can be chained.
@@ -2299,7 +2312,7 @@ class SimpleTable extends Simple_js_1.default {
2299
2312
  return this;
2300
2313
  }
2301
2314
  /**
2302
- * Capitalizes the first letter of each string in the specified columns and converts the rest of the string to lowercase. This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2315
+ * Capitalizes the first letter of each string in the specified columns and converts the rest of the string to lowercase.
2303
2316
  *
2304
2317
  * @param columns - The column name or an array of column names to be capitalized.
2305
2318
  * @returns The table, so methods can be chained.
@@ -2324,8 +2337,6 @@ class SimpleTable extends Simple_js_1.default {
2324
2337
  /**
2325
2338
  * Truncates string values in a specified column to a maximum number of characters.
2326
2339
  *
2327
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2328
- *
2329
2340
  * @param column - The column name containing strings to be truncated.
2330
2341
  * @param length - The maximum number of characters to keep.
2331
2342
  * @returns The table, so methods can be chained.
@@ -2354,8 +2365,6 @@ class SimpleTable extends Simple_js_1.default {
2354
2365
  * column is of a different type. `null` values remain `null`. If any string
2355
2366
  * already exceeds the target length, an error is thrown (no silent truncation).
2356
2367
  *
2357
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2358
- *
2359
2368
  * @param columns - The column name(s) containing strings to be padded.
2360
2369
  * @param length - The target length of the padded strings.
2361
2370
  * @param options - An optional object with configuration options:
@@ -2395,8 +2404,6 @@ class SimpleTable extends Simple_js_1.default {
2395
2404
  * Splits strings in a specified column by a separator and extracts a substring at a given index, storing the result in a new or existing column.
2396
2405
  * If the index is out of bounds, an empty string will be returned for that row.
2397
2406
  *
2398
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2399
- *
2400
2407
  * @param column - The name of the column containing the strings to be split.
2401
2408
  * @param separator - The substring to use as a delimiter for splitting the strings.
2402
2409
  * @param index - The zero-based index of the substring to extract after splitting. For example, `0` for the first part, `1` for the second, etc.
@@ -2429,8 +2436,6 @@ class SimpleTable extends Simple_js_1.default {
2429
2436
  * If a row has fewer parts than the number of new columns, a warning will be logged and the extra columns will contain empty strings (unless `strict` is set to `false`).
2430
2437
  * If a row has more parts than the number of new columns, an error will be thrown unless `strict` is set to `false`.
2431
2438
  *
2432
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2433
- *
2434
2439
  * @param column - The name of the column containing the strings to be split.
2435
2440
  * @param separator - The substring to use as a delimiter for splitting the strings.
2436
2441
  * @param newColumns - An array of column names for the extracted parts.
@@ -2466,8 +2471,6 @@ class SimpleTable extends Simple_js_1.default {
2466
2471
  /**
2467
2472
  * Extracts a specific number of characters from the beginning (left side) of string values in the specified column.
2468
2473
  *
2469
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2470
- *
2471
2474
  * @param column - The name of the column containing the strings to be modified.
2472
2475
  * @param count - The number of characters to extract from the left side of each string.
2473
2476
  * @returns The table, so methods can be chained.
@@ -2487,8 +2490,6 @@ class SimpleTable extends Simple_js_1.default {
2487
2490
  /**
2488
2491
  * Extracts a specific number of characters from the end (right side) of string values in the specified column.
2489
2492
  *
2490
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2491
- *
2492
2493
  * @param column - The name of the column containing the strings to be modified.
2493
2494
  * @param count - The number of characters to extract from the right side of each string.
2494
2495
  * @returns The table, so methods can be chained.
@@ -2508,8 +2509,6 @@ class SimpleTable extends Simple_js_1.default {
2508
2509
  /**
2509
2510
  * Replaces `NULL` values in the specified columns with a given value.
2510
2511
  *
2511
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2512
- *
2513
2512
  * @param columns - The column name, an array of column names, or `"all"` to apply the replacement to every column in the table.
2514
2513
  * @param value - The value to replace `NULL` occurrences with.
2515
2514
  * @returns The table, so methods can be chained.
@@ -2546,8 +2545,6 @@ class SimpleTable extends Simple_js_1.default {
2546
2545
  /**
2547
2546
  * Concatenates values from specified columns into a new column.
2548
2547
  *
2549
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2550
- *
2551
2548
  * @param columns - An array of column names whose values will be concatenated.
2552
2549
  * @param newColumn - The name of the new column to store the concatenated values.
2553
2550
  * @param options - An optional object with configuration options:
@@ -2582,8 +2579,6 @@ class SimpleTable extends Simple_js_1.default {
2582
2579
  *
2583
2580
  * If a column value is `NULL`, it will be replaced by `'Unknown'` in the concatenated result.
2584
2581
  *
2585
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2586
- *
2587
2582
  * @param columns - An array of column names whose values will be concatenated with labels.
2588
2583
  * @param newColumn - The name of the new column to create with the concatenated values.
2589
2584
  * @returns The table, so methods can be chained.
@@ -2631,8 +2626,6 @@ class SimpleTable extends Simple_js_1.default {
2631
2626
  *
2632
2627
  * Each value in the specified column is split using the provided separator, and a new row is created for each resulting substring. All other column values are duplicated across the newly created rows.
2633
2628
  *
2634
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2635
- *
2636
2629
  * @param column - The name of the column containing string values to be split and unnested.
2637
2630
  * @param separator - The delimiter string used to split the column values.
2638
2631
  * @returns The table, so methods can be chained.
@@ -2665,8 +2658,6 @@ class SimpleTable extends Simple_js_1.default {
2665
2658
  *
2666
2659
  * If a row has a value of 3 in the specified column, it will be repeated 3 times. If the value is 0 or negative, the row will be removed.
2667
2660
  *
2668
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2669
- *
2670
2661
  * @param column - The name of the column containing the number of times each row should be repeated.
2671
2662
  * @param options - An optional object with configuration options:
2672
2663
  * @param options.index - The name of a new column to store the index of the repeated row (starting at 0).
@@ -2698,8 +2689,6 @@ class SimpleTable extends Simple_js_1.default {
2698
2689
  *
2699
2690
  * This is the inverse operation of `unnest()`. Multiple rows are combined into fewer rows by grouping on specified category columns and concatenating the target column values with a separator.
2700
2691
  *
2701
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2702
- *
2703
2692
  * @param column - The name of the column whose values will be aggregated and concatenated.
2704
2693
  * @param separator - The delimiter string used to join the column values.
2705
2694
  * @param by - The column name or an array of column names to group by.
@@ -2732,8 +2721,6 @@ class SimpleTable extends Simple_js_1.default {
2732
2721
  /**
2733
2722
  * Rounds numeric values in specified columns.
2734
2723
  *
2735
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2736
- *
2737
2724
  * @param columns - The column name or an array of column names containing numeric values to be rounded.
2738
2725
  * @param options - An optional integer specifying the number of decimal places, or an object with configuration options:
2739
2726
  * @param options.decimals - The number of decimal places to round to. Defaults to `0` (rounds to the nearest integer).
@@ -2779,8 +2766,6 @@ class SimpleTable extends Simple_js_1.default {
2779
2766
  * Adds independently generated uniform random noise to numeric values in one or more columns.
2780
2767
  * Each changed value receives an offset between `-max` and `max`. Selected integer and decimal columns become `DOUBLE` columns so fractional noise is retained. This method adds random jitter; it does not provide anonymization or differential privacy guarantees.
2781
2768
  *
2782
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2783
- *
2784
2769
  * @param columns - The numeric column name or array of numeric column names to which noise will be added. When multiple columns are provided, each value receives an independent random offset.
2785
2770
  * @param max - The maximum absolute offset, expressed in each column's units. Must be a finite number greater than or equal to `0`.
2786
2771
  * @param options - An optional object with configuration options:
@@ -2808,8 +2793,7 @@ class SimpleTable extends Simple_js_1.default {
2808
2793
  }
2809
2794
  /**
2810
2795
  * Updates values in a specified column using a SQL expression.
2811
- *
2812
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2796
+ * With the default `SimpleDB.expressionSyntax: "js"`, expressions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
2813
2797
  *
2814
2798
  * @param column - The name of the column to be updated.
2815
2799
  * @param definition - The SQL expression used to set the new values in the column (e.g., `"column1 * 2"`, `"UPPER(column_name)"`).
@@ -2833,6 +2817,16 @@ class SimpleTable extends Simple_js_1.default {
2833
2817
  * // Set 'status' to 'active' where 'isActive' is true
2834
2818
  * await table.updateColumn("status", `CASE WHEN isActive THEN 'active' ELSE 'inactive' END`).log();
2835
2819
  * ```
2820
+ *
2821
+ * @example
2822
+ * ```ts
2823
+ * // Update an existing column with a value from a JSON object using dot notation.
2824
+ * await table.loadArray([{ count: 0, details: { count: 3 } }], {
2825
+ * columnTypes: { details: "JSON" },
2826
+ * })
2827
+ * .updateColumn("count", "details.count")
2828
+ * .log();
2829
+ * ```
2836
2830
  */
2837
2831
  updateColumn(column, definition) {
2838
2832
  (0, updateColumn_js_1.default)(this, column, definition);
@@ -2841,8 +2835,6 @@ class SimpleTable extends Simple_js_1.default {
2841
2835
  /**
2842
2836
  * Assigns ranks to rows in a new column based on the values of a specified column.
2843
2837
  *
2844
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2845
- *
2846
2838
  * @param column - The column containing the values to be used for ranking.
2847
2839
  * @param newColumn - The name of the new column where the ranks will be stored.
2848
2840
  * @param options - An optional object with configuration options:
@@ -2883,8 +2875,6 @@ class SimpleTable extends Simple_js_1.default {
2883
2875
  /**
2884
2876
  * Assigns quantiles to rows in a new column based on specified column values.
2885
2877
  *
2886
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2887
- *
2888
2878
  * @param column - The column containing values from which quantiles will be assigned.
2889
2879
  * @param count - The number of quantiles to divide the data into (e.g., `4` for quartiles, `10` for deciles).
2890
2880
  * @param newColumn - The name of the new column where the assigned quantiles will be stored.
@@ -2916,34 +2906,36 @@ class SimpleTable extends Simple_js_1.default {
2916
2906
  return this;
2917
2907
  }
2918
2908
  /**
2919
- * Assigns bins for specified column values based on an interval size.
2920
- *
2921
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2909
+ * Adds numeric start and end columns for bins of the specified interval size.
2910
+ * Each bin includes its start and excludes its end: `start <= value < end`.
2911
+ * A value exactly on an end boundary belongs to the next bin. Null source
2912
+ * values produce null in both output columns.
2922
2913
  *
2923
- * @param column - The column containing values from which bins will be computed.
2924
- * @param interval - The interval size for binning the values.
2925
- * @param newColumn - The name of the new column where the bins will be stored.
2914
+ * @param column - The numeric column containing values from which bins will be computed.
2915
+ * @param interval - The finite, positive interval size for binning the values.
2916
+ * @param startColumn - The required name of the new numeric column containing inclusive bin starts.
2917
+ * @param endColumn - The required name of the new numeric column containing exclusive bin ends. Must differ from startColumn.
2926
2918
  * @param options - An optional object with configuration options:
2927
- * @param options.startValue - The starting value for binning. Defaults to the minimum value in the specified column.
2919
+ * @param options.startValue - The finite starting value for binning, no greater than the minimum source value. Defaults to the minimum value in the specified column.
2928
2920
  * @returns The table, so methods can be chained.
2929
2921
  * @category Analyzing Data
2930
2922
  *
2931
2923
  * @example
2932
2924
  * ```ts
2933
- * // Assigns a bin for each row in a new 'bins' column based on 'column1' values, with an interval of 10.
2934
- * // If the minimum value in 'column1' is 5, the bins will follow this pattern: "[5-14]", "[15-24]", etc.
2935
- * await table.bins("column1", 10, "bins").log();
2925
+ * // If the minimum is 5, bins have boundaries 5 and 15, 15 and 25, etc.
2926
+ * await table.bins("column1", 10, "binStart", "binEnd").log();
2936
2927
  * ```
2937
2928
  *
2938
2929
  * @example
2939
2930
  * ```ts
2940
- * // Assigns bins starting at a specific value (0) with an interval of 10.
2941
- * // The bins will follow this pattern: "[0-9]", "[10-19]", "[20-29]", etc.
2942
- * await table.bins("column1", 10, "bins", { startValue: 0 }).log();
2931
+ * // Bins start at 0: a value of 10 has binStart 10 and binEnd 20.
2932
+ * await table
2933
+ * .bins("column1", 10, "binStart", "binEnd", { startValue: 0 })
2934
+ * .log();
2943
2935
  * ```
2944
2936
  */
2945
- bins(column, interval, newColumn, options = {}) {
2946
- (0, bins_js_1.default)(this, column, interval, newColumn, options);
2937
+ bins(column, interval, startColumn, endColumn, options = {}) {
2938
+ (0, bins_js_1.default)(this, column, interval, startColumn, endColumn, options);
2947
2939
  return this;
2948
2940
  }
2949
2941
  /**
@@ -2995,8 +2987,6 @@ class SimpleTable extends Simple_js_1.default {
2995
2987
  * await table.rowProportions(["Men", "Women", "NonBinary"], { base: 100, decimals: 1 }).log();
2996
2988
  * ```
2997
2989
  *
2998
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2999
- *
3000
2990
  * @param columns - An array of column names for which proportions will be computed on each row.
3001
2991
  * @param options - An optional object with configuration options:
3002
2992
  * @param options.suffix - A string suffix to append to the names of the new columns storing the computed proportions. Defaults to `"Perc"`.
@@ -3020,9 +3010,6 @@ class SimpleTable extends Simple_js_1.default {
3020
3010
  * option can therefore increase the table's row count. If null values leave
3021
3011
  * a row without the requested rank, the new columns contain null.
3022
3012
  *
3023
- * This method queues the operation; it runs when an async observer method
3024
- * (like `getData()` or `log()`) is awaited, or when `run()` is called.
3025
- *
3026
3013
  * @param columns - The numeric columns to rank within each row.
3027
3014
  * @param options - The output columns and ranking configuration. At least one of `nameColumn` or `valueColumn` is required.
3028
3015
  * @param options.nameColumn - The name of a new column containing the selected source column's name.
@@ -3059,8 +3046,6 @@ class SimpleTable extends Simple_js_1.default {
3059
3046
  /**
3060
3047
  * Computes proportions vertically over a column's values, relative to the sum of all values in that column or group.
3061
3048
  *
3062
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3063
- *
3064
3049
  * @param column - The column containing values for which proportions will be computed. The proportions are calculated based on the sum of values in the specified column.
3065
3050
  * @param newColumn - The name of the new column where the proportions will be stored.
3066
3051
  * @param options - An optional object with configuration options:
@@ -3102,8 +3087,6 @@ class SimpleTable extends Simple_js_1.default {
3102
3087
  * Creates a summary table from selected columns, optionally grouped by other columns.
3103
3088
  * This method allows you to aggregate data, calculate statistics (e.g., count, mean, sum), and group results by categorical columns.
3104
3089
  *
3105
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3106
- *
3107
3090
  * @param options - An object with configuration options for summarization:
3108
3091
  * @param options.columns - The column name or an array of column names to summarize. If omitted, only the row count is returned.
3109
3092
  * @param options.by - The column name or an array of column names to group by.
@@ -3202,9 +3185,6 @@ class SimpleTable extends Simple_js_1.default {
3202
3185
  * string is also used as its row label; pass an object to customize that
3203
3186
  * label. If `options.stats` is omitted, every supported stat is added.
3204
3187
  *
3205
- * This method queues the operation; it runs when an async observer method
3206
- * (like `getData()` or `log()`) is awaited, or when `run()` is called.
3207
- *
3208
3188
  * @param columns - The numeric column name, an array of numeric column names, or `"all"` to summarize every numeric column.
3209
3189
  * @param labelColumn - The existing string column in which stat row labels will be written.
3210
3190
  * @param options - An optional object with configuration options:
@@ -3246,8 +3226,6 @@ class SimpleTable extends Simple_js_1.default {
3246
3226
  /**
3247
3227
  * Computes the cumulative sum of values in a column. For this method to work properly, ensure your data is sorted first.
3248
3228
  *
3249
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3250
- *
3251
3229
  * @param column - The name of the column storing the values to be accumulated.
3252
3230
  * @param newColumn - The name of the new column in which the computed cumulative values will be stored.
3253
3231
  * @param options - An optional object with configuration options:
@@ -3284,8 +3262,6 @@ class SimpleTable extends Simple_js_1.default {
3284
3262
  * For rows without enough preceding or following rows to form a complete window, `NULL` will be returned.
3285
3263
  * For this method to work properly, ensure your data is sorted by the relevant column(s) first.
3286
3264
  *
3287
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3288
- *
3289
3265
  * @param column - The name of the column storing the values to be aggregated.
3290
3266
  * @param newColumn - The name of the new column in which the computed rolling values will be stored.
3291
3267
  * @param stat - The aggregation function to apply: `"min"`, `"max"`, `"mean"`, `"median"`, or `"sum"`.
@@ -3324,8 +3300,6 @@ class SimpleTable extends Simple_js_1.default {
3324
3300
  * Calculates correlations between columns. If no `x` and `y` columns are specified, the method computes the correlations for all numeric column combinations.
3325
3301
  * Note that correlation is symmetrical: the correlation of `x` with `y` is the same as `y` with `x`.
3326
3302
  *
3327
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3328
- *
3329
3303
  * @param options - An optional object with configuration options:
3330
3304
  * @param options.x - The name of the column for the x-values. If omitted, correlations will be computed for all numeric columns.
3331
3305
  * @param options.y - The name of the column for the y-values. It can be provided only when `options.x` is also set. If both are omitted, correlations will be computed for all numeric column pairs.
@@ -3373,8 +3347,6 @@ class SimpleTable extends Simple_js_1.default {
3373
3347
  * If no `x` and `y` columns are specified, the method computes linear regression analysis for all numeric column permutations.
3374
3348
  * Note that linear regression analysis is asymmetrical: the linear regression of `x` over `y` is not the same as `y` over `x`.
3375
3349
  *
3376
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3377
- *
3378
3350
  * @param options - An optional object with configuration options:
3379
3351
  * @param options.x - The name of the column for the independent variable (x-values). If omitted, linear regressions will be computed for all numeric columns as x.
3380
3352
  * @param options.y - The name of the column for the dependent variable (y-values). It can be provided only when `options.x` is also set. If both are omitted, linear regressions will be computed for all numeric column permutations.
@@ -3420,8 +3392,6 @@ class SimpleTable extends Simple_js_1.default {
3420
3392
  /**
3421
3393
  * Identifies outliers in a specified column using the Interquartile Range (IQR) method.
3422
3394
  *
3423
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3424
- *
3425
3395
  * @param column - The name of the column in which outliers will be identified.
3426
3396
  * @param newColumn - The name of the new column where the boolean results (`TRUE` for outlier, `FALSE` otherwise) will be stored.
3427
3397
  * @param options - An optional object with configuration options:
@@ -3448,8 +3418,6 @@ class SimpleTable extends Simple_js_1.default {
3448
3418
  /**
3449
3419
  * Computes the Z-score for values in a specified column.
3450
3420
  *
3451
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3452
- *
3453
3421
  * @param column - The name of the column for which Z-scores will be calculated.
3454
3422
  * @param newColumn - The name of the new column where the computed Z-scores will be stored.
3455
3423
  * @param options - An optional object with configuration options:
@@ -3483,8 +3451,6 @@ class SimpleTable extends Simple_js_1.default {
3483
3451
  /**
3484
3452
  * Normalizes the values in a column using min-max normalization.
3485
3453
  *
3486
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3487
- *
3488
3454
  * @param column - The name of the column in which values will be normalized.
3489
3455
  * @param newColumn - The name of the new column where normalized values will be stored.
3490
3456
  * @param options - An optional object with configuration options:
@@ -3529,8 +3495,6 @@ class SimpleTable extends Simple_js_1.default {
3529
3495
  *
3530
3496
  * Exact temporal references are compared at their full DuckDB precision. JavaScript `Date` objects only have millisecond precision and always represent an instant. Construct them with an explicit timezone, such as `new Date("2001-01-01T00:00:00Z")`; date-time strings without `Z` or an offset use the user's local timezone.
3531
3497
  *
3532
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3533
- *
3534
3498
  * @param column - The numeric column containing the values to index.
3535
3499
  * @param newColumn - The name of the new column where indexed values will be stored.
3536
3500
  * @param reference - A statistic calculated from `column`, a column and exact non-null `equals` value selecting a row, or a column and `at` set to `min` or `max` selecting its unique extreme row. The selected row's `column` value becomes the reference.
@@ -3588,48 +3552,84 @@ class SimpleTable extends Simple_js_1.default {
3588
3552
  /**
3589
3553
  * Updates data in the table using a JavaScript function. The function receives the existing rows as an array of objects and must return the modified rows as an array of objects.
3590
3554
  * This method offers high flexibility for data manipulation but can be slow for large tables as it involves transferring data between DuckDB and JavaScript.
3591
- * This method does not work with tables containing geometries.
3555
+ * Before writing a JavaScript callback, check for an existing SDA method that
3556
+ * performs the same operation; it will usually be faster and more efficient.
3592
3557
  *
3593
- * This method queues the update; the dataModifier function runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3558
+ * If the table has geometry columns, the callback can read and modify their
3559
+ * GeoJSON geometry objects directly. Extra properties added to these objects
3560
+ * are ignored; create new columns on the returned rows to store additional
3561
+ * attributes. All geometry columns must use EPSG:4326; use reproject() first
3562
+ * if needed.
3594
3563
  *
3595
3564
  * @param dataModifier - A synchronous or asynchronous function that takes the existing rows (as an array of objects) and returns the modified rows (as an array of objects).
3596
3565
  * @param options - An optional object with configuration options:
3597
- * @param options.batchSize - If provided, rows are processed in batches of this size instead of all at once, so large tables don't have to be materialized entirely in memory. The modifier function is called once per batch.
3566
+ * @param options.batchSize - If provided, rows are processed in batches of this size instead of all at once, so large tables don't have to be materialized entirely in memory. This limits input rows per batch, but does not eliminate conversion work or bound geometry size or callback output expansion. The modifier function is called once per batch. Tables with a column named `rowid` or `__sda_rowid` (case-insensitive) are rejected before the modifier runs; rename the column or omit batchSize.
3567
+ * @param options.columnTypes - Explicit types for newly added columns, following loadArray's columnTypes contract. Declare geometry as GEOMETRY('EPSG:4326'); geometry is never inferred from object shape. Existing columns cannot be redeclared.
3598
3568
  * @returns The table, so methods can be chained.
3599
3569
  * @category Updating Data
3600
3570
  *
3601
3571
  * @example
3602
3572
  * ```ts
3603
- * // Extract hostnames with JavaScript's URL parser.
3604
- * const table = await sdb
3605
- * .newTable()
3606
- * .loadData("websites.csv")
3607
- * .updateWithJS((rows) => {
3608
- * return rows.map((row) => ({
3609
- * ...row,
3610
- * hostname: typeof row.url === "string"
3611
- * ? new URL(row.url).hostname
3612
- * : null,
3613
- * }));
3614
- * })
3573
+ * // Double the value in each row with a JavaScript callback.
3574
+ * await table.loadArray([{ value: 1 }, { value: 2 }])
3575
+ * .updateWithJS((rows) => rows.map((row) => ({
3576
+ * value: Number(row.value) * 2,
3577
+ * })))
3615
3578
  * .log();
3616
3579
  * ```
3617
3580
  *
3618
3581
  * @example
3619
3582
  * ```ts
3620
- * // Enrich reviews with scores from an external service, 100 at a time.
3621
- * const reviews = await table
3622
- * .updateWithJS(async (rows) => {
3623
- * const response = await fetch("https://api.example.com/score", {
3624
- * method: "POST",
3625
- * headers: { "content-type": "application/json" },
3626
- * body: JSON.stringify(rows.map((row) => row.review)),
3627
- * });
3628
- * const scores = await response.json() as number[];
3629
- * return rows.map((row, index) => ({ ...row, score: scores[index] }));
3630
- * }, { batchSize: 100 })
3583
+ * // Process two rows per callback to limit how many rows are handled at once.
3584
+ * await table.loadArray([{ value: 1 }, { value: 2 }, { value: 3 }])
3585
+ * .updateWithJS((rows) => rows.map((row) => ({
3586
+ * value: Number(row.value) * 2,
3587
+ * })), { batchSize: 2 })
3631
3588
  * .log();
3632
3589
  * ```
3590
+ *
3591
+ * @example
3592
+ * ```ts
3593
+ * // Add a JSON object column to keep related attributes together.
3594
+ * await table.loadArray([{ name: "Station" }])
3595
+ * .updateWithJS((rows) => rows.map((row) => ({
3596
+ * ...row, details: { active: true, category: "weather" },
3597
+ * })), { columnTypes: { details: "JSON" } })
3598
+ * .log();
3599
+ * ```
3600
+ *
3601
+ * @example
3602
+ * ```ts
3603
+ * // Add a three-element float vector, such as an embedding.
3604
+ * await table.loadArray([{ name: "Station" }])
3605
+ * .updateWithJS((rows) => rows.map((row) => ({
3606
+ * ...row, embedding: [0.25, 0.5, 0.75],
3607
+ * })), { columnTypes: { embedding: "FLOAT[3]" } })
3608
+ * .log();
3609
+ * ```
3610
+ *
3611
+ * @example
3612
+ * ```ts
3613
+ * // Move each point slightly east by editing its longitude.
3614
+ * await sdb.newTable().loadArray([{
3615
+ * geom: { type: "Point", coordinates: [-73, 45] },
3616
+ * }], { columnTypes: { geom: "GEOMETRY('EPSG:4326')" } })
3617
+ * .updateWithJS((rows) => rows.map((row) => {
3618
+ * // This example loads only Points. Narrow the type for coordinate access.
3619
+ * const geom = row.geom as { type: "Point"; coordinates: number[] } | null;
3620
+ * if (geom !== null) geom.coordinates[0] += 0.01;
3621
+ * return row;
3622
+ * })).log();
3623
+ * ```
3624
+ *
3625
+ * @example
3626
+ * ```ts
3627
+ * // Create a geometry column from longitude and latitude values.
3628
+ * await sdb.newTable().loadArray([{ longitude: -73, latitude: 45 }])
3629
+ * .updateWithJS((rows) => rows.map((row) => ({
3630
+ * ...row, geom: { type: "Point", coordinates: [row.longitude, row.latitude] },
3631
+ * })), { columnTypes: { geom: "GEOMETRY('EPSG:4326')" } }).log();
3632
+ * ```
3633
3633
  */
3634
3634
  updateWithJS(dataModifier, options = {}) {
3635
3635
  (0, updateWithJS_js_1.default)(this, dataModifier, options);
@@ -3710,8 +3710,6 @@ class SimpleTable extends Simple_js_1.default {
3710
3710
  * Produces identical output to `journalism-format`'s `normalizeString()` function
3711
3711
  * for all common cases including accented Latin characters.
3712
3712
  *
3713
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3714
- *
3715
3713
  * @param column The column containing the text to normalize
3716
3714
  * @param newColumn The column to store the normalized results
3717
3715
  * @param options Configuration options
@@ -3762,8 +3760,6 @@ class SimpleTable extends Simple_js_1.default {
3762
3760
  * Counts are based on Unicode code points, not grapheme clusters. A user-perceived character composed of multiple code points, such as some emoji or decomposed accented letters, counts as multiple characters.
3763
3761
  * `NULL` input values produce `NULL` counts.
3764
3762
  *
3765
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3766
- *
3767
3763
  * @param column - The name of the column containing the strings to count.
3768
3764
  * @param newColumn - The name of the new column where the character counts will be stored.
3769
3765
  * @returns The table, so methods can be chained.
@@ -3783,8 +3779,6 @@ class SimpleTable extends Simple_js_1.default {
3783
3779
  * Adds a new column containing the word count for each string in the specified column.
3784
3780
  * A word is any contiguous sequence of non-whitespace characters. Spaces, tabs, and line breaks separate words. Punctuation is not removed, so a standalone punctuation sequence counts as a word. Text without whitespace counts as one word, regardless of language. Empty or whitespace-only strings produce `0`, and `NULL` input values produce `NULL` counts.
3785
3781
  *
3786
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3787
- *
3788
3782
  * @param column - The name of the column containing the strings to count.
3789
3783
  * @param newColumn - The name of the new column where the word counts will be stored.
3790
3784
  * @returns The table, so methods can be chained.
@@ -3820,6 +3814,7 @@ class SimpleTable extends Simple_js_1.default {
3820
3814
  }
3821
3815
  /**
3822
3816
  * Returns the number of rows in the table.
3817
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
3823
3818
  *
3824
3819
  * @param options - An optional object with configuration options:
3825
3820
  * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Book'"`).
@@ -4160,7 +4155,7 @@ class SimpleTable extends Simple_js_1.default {
4160
4155
  }
4161
4156
  /**
4162
4157
  * Returns the first row of the table, optionally filtered by SQL conditions.
4163
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4158
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4164
4159
  * Temporal values use the same JavaScript representations as `getData()`.
4165
4160
  *
4166
4161
  * @param options - An optional object with configuration options:
@@ -4187,7 +4182,7 @@ class SimpleTable extends Simple_js_1.default {
4187
4182
  }
4188
4183
  /**
4189
4184
  * Returns the last row of the table, optionally filtered by SQL conditions.
4190
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4185
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4191
4186
  * Temporal values use the same JavaScript representations as `getData()`.
4192
4187
  *
4193
4188
  * @param options - An optional object with configuration options:
@@ -4214,7 +4209,7 @@ class SimpleTable extends Simple_js_1.default {
4214
4209
  }
4215
4210
  /**
4216
4211
  * Returns the top `n` rows of the table, optionally filtered by SQL conditions.
4217
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4212
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4218
4213
  * Temporal values use the same JavaScript representations as `getData()`.
4219
4214
  *
4220
4215
  * @param count - The number of rows to return from the top of the table.
@@ -4243,7 +4238,7 @@ class SimpleTable extends Simple_js_1.default {
4243
4238
  /**
4244
4239
  * Returns the bottom `n` rows of the table, optionally filtered by SQL conditions.
4245
4240
  * By default, the last row will be returned first. To preserve the original order, use the `originalOrder` option.
4246
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4241
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4247
4242
  * Temporal values use the same JavaScript representations as `getData()`.
4248
4243
  *
4249
4244
  * @param count - The number of rows to return from the bottom of the table.
@@ -4279,7 +4274,7 @@ class SimpleTable extends Simple_js_1.default {
4279
4274
  }
4280
4275
  /**
4281
4276
  * Returns a single row that matches the specified conditions. If no row matches or if more than one row matches, an error is thrown by default.
4282
- * You can also use JavaScript syntax for conditions (e.g., `AND`, `||`, `===`, `!==`).
4277
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4283
4278
  * Temporal values use the same JavaScript representations as `getData()`.
4284
4279
  *
4285
4280
  * @param conditions - The conditions to match, specified as a SQL `WHERE` clause.
@@ -4324,13 +4319,26 @@ class SimpleTable extends Simple_js_1.default {
4324
4319
  }
4325
4320
  /**
4326
4321
  * Returns the data from the table as an array of objects, optionally filtered by SQL conditions.
4327
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4322
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4328
4323
  *
4329
4324
  * Top-level DuckDB `DATE` and `TIMESTAMP` columns are returned as JavaScript
4330
4325
  * `Date` objects interpreted in UTC. `TIMESTAMP WITH TIME ZONE` values are
4331
4326
  * returned as UTC strings, preserving DuckDB's microsecond precision;
4332
4327
  * JavaScript `Date` supports only milliseconds.
4333
4328
  *
4329
+ * Top-level `BIGINT`, `UBIGINT`, `HUGEINT`, and `UHUGEINT` columns are
4330
+ * returned as JavaScript numbers. Values outside `Number.MIN_SAFE_INTEGER`
4331
+ * through `Number.MAX_SAFE_INTEGER` throw instead of losing precision.
4332
+ * Use `convert({ columnName: "string" })` before `getData()` to retrieve
4333
+ * their exact digits as strings.
4334
+ *
4335
+ * SQL arrays and lists, including float vectors, return their actual elements
4336
+ * as JavaScript arrays. Null cells and null elements remain null.
4337
+ *
4338
+ * Nested SQL lists and structs become JavaScript arrays and objects. Within
4339
+ * them, `BIGINT`, `UBIGINT`, `HUGEINT`, `UHUGEINT`, and `DECIMAL` values remain
4340
+ * strings to preserve precision, even for small integers.
4341
+ *
4334
4342
  * @param options - An optional object with configuration options:
4335
4343
  * @param options.columns - An array of column names to include in the result. If omitted, all columns will be included.
4336
4344
  * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Book'"`).
@@ -4364,6 +4372,18 @@ class SimpleTable extends Simple_js_1.default {
4364
4372
  * // Return at most two rows.
4365
4373
  * const preview = await table.getData({ limit: 2 });
4366
4374
  * ```
4375
+ *
4376
+ * @example
4377
+ * ```ts
4378
+ * // Read nested integers without losing digits. SQL creates the nested types.
4379
+ * await sdb.customQuery(`CREATE TABLE nested_example AS SELECT
4380
+ * [42::BIGINT, 9007199254740993::BIGINT] AS ids,
4381
+ * {'count': 2::INTEGER, 'amount': 123.450::DECIMAL(6,3)} AS details`);
4382
+ * const nested = sdb.newTable("nested_example");
4383
+ * const rows = await nested.getData();
4384
+ * // [{ ids: ["42", "9007199254740993"], details: { count: 2, amount: "123.450" } }]
4385
+ * await nested.log();
4386
+ * ```
4367
4387
  */
4368
4388
  async getData(options = {}) {
4369
4389
  return await (0, getData_js_1.default)(this, options);
@@ -4372,6 +4392,7 @@ class SimpleTable extends Simple_js_1.default {
4372
4392
  * Streams the table rows one by one as an async iterator, without
4373
4393
  * materializing the whole table in memory. Values are converted to
4374
4394
  * JavaScript types the same way as `getData()`.
4395
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4375
4396
  *
4376
4397
  * The underlying DuckDB result is streamed chunk by chunk, so tables
4377
4398
  * larger than the available memory can be iterated. Avoid running other
@@ -4404,7 +4425,7 @@ class SimpleTable extends Simple_js_1.default {
4404
4425
  }
4405
4426
  /**
4406
4427
  * Returns the data from the table as a CSV string, optionally filtered by SQL conditions.
4407
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4428
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4408
4429
  * Temporal values are first converted as they are in `getData()`, then
4409
4430
  * serialized using UTC date and timestamp text.
4410
4431
  *
@@ -4443,8 +4464,6 @@ class SimpleTable extends Simple_js_1.default {
4443
4464
  /**
4444
4465
  * Creates point geometries from latitude (y) and longitude (x) columns.
4445
4466
  *
4446
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4447
- *
4448
4467
  * @param latColumn - The name of the column storing the latitude (y-coordinate) values.
4449
4468
  * @param lonColumn - The name of the column storing the longitude (x-coordinate) values.
4450
4469
  * @param newColumn - The name of the new column where the point geometries will be stored.
@@ -4474,8 +4493,6 @@ class SimpleTable extends Simple_js_1.default {
4474
4493
  /**
4475
4494
  * Adds a column with boolean values indicating the validity of geometries.
4476
4495
  *
4477
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4478
- *
4479
4496
  * @param newColumn - The name of the new column where the boolean results (`TRUE` for valid, `FALSE` for invalid) will be stored.
4480
4497
  * @param options - An optional object with configuration options:
4481
4498
  * @param options.column - The name of the column storing the geometries to be checked. If omitted, the method will automatically attempt to find a geometry column.
@@ -4502,8 +4519,6 @@ class SimpleTable extends Simple_js_1.default {
4502
4519
  /**
4503
4520
  * Adds a column with the number of vertices (points) in each geometry.
4504
4521
  *
4505
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4506
- *
4507
4522
  * @param newColumn - The name of the new column where the vertex counts will be stored.
4508
4523
  * @param options - An optional object with configuration options:
4509
4524
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4530,8 +4545,6 @@ class SimpleTable extends Simple_js_1.default {
4530
4545
  /**
4531
4546
  * Attempts to make invalid geometries valid without removing any vertices.
4532
4547
  *
4533
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4534
- *
4535
4548
  * @param column - The name of the column storing the geometries to be fixed. If omitted, the method will automatically attempt to find a geometry column.
4536
4549
  * @returns The table, so methods can be chained.
4537
4550
  * @category Geospatial
@@ -4555,8 +4568,6 @@ class SimpleTable extends Simple_js_1.default {
4555
4568
  /**
4556
4569
  * Adds a column with boolean values indicating whether geometries are closed (e.g., polygons) or open (e.g., linestrings).
4557
4570
  *
4558
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4559
- *
4560
4571
  * @param newColumn - The name of the new column where the boolean results (`TRUE` for closed, `FALSE` for open) will be stored.
4561
4572
  * @param options - An optional object with configuration options:
4562
4573
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4582,8 +4593,6 @@ class SimpleTable extends Simple_js_1.default {
4582
4593
  /**
4583
4594
  * Adds a column with the geometry type (e.g., `"POINT"`, `"LINESTRING"`, `"POLYGON"`) for each geometry.
4584
4595
  *
4585
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4586
- *
4587
4596
  * @param newColumn - The name of the new column where the geometry types will be stored.
4588
4597
  * @param options - An optional object with configuration options:
4589
4598
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4610,8 +4619,6 @@ class SimpleTable extends Simple_js_1.default {
4610
4619
  * Flips the coordinate order of geometries in a specified column (e.g., from `[longitude (x), latitude (y)]` to `[latitude (y), longitude (x)]` or vice-versa).
4611
4620
  * **Warning:** This method should be used with caution as it directly manipulates coordinate order and can affect the accuracy of geospatial operations if not used correctly.
4612
4621
  *
4613
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4614
- *
4615
4622
  * @param column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
4616
4623
  * @returns The table, so methods can be chained.
4617
4624
  * @category Geospatial
@@ -4637,7 +4644,7 @@ class SimpleTable extends Simple_js_1.default {
4637
4644
  *
4638
4645
  * Points are sampled uniformly within the requested distance using the spherical direct geodesic (destination-point) formula and the same spherical Earth model as DuckDB's `ST_Distance_Sphere()`. This accounts for longitude scale changing with latitude. This method adds random jitter; it does not provide anonymization or differential privacy guarantees.
4639
4646
  *
4640
- * This method supports only `POINT` geometries in `EPSG:4326`. Null and empty geometries are preserved. It queues the operation; the operation runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4647
+ * This method supports only `POINT` geometries in `EPSG:4326`. Null and empty geometries are preserved.
4641
4648
  *
4642
4649
  * @param maxDistance - The maximum great-circle displacement in the selected unit. Must be a finite number greater than or equal to `0` and no greater than half Earth's circumference.
4643
4650
  * @param options - An optional object with configuration options:
@@ -4670,8 +4677,6 @@ class SimpleTable extends Simple_js_1.default {
4670
4677
  /**
4671
4678
  * Reduces the precision of geometries in a specified column to a given number of decimal places.
4672
4679
  *
4673
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4674
- *
4675
4680
  * @param decimals - The number of decimal places to keep in the coordinates of the geometries.
4676
4681
  * @param options - An optional object with configuration options:
4677
4682
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4697,8 +4702,6 @@ class SimpleTable extends Simple_js_1.default {
4697
4702
  /**
4698
4703
  * Reprojects the geometries in a specified column to another Spatial Reference System (SRS).
4699
4704
  *
4700
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4701
- *
4702
4705
  * @param crs - The target SRS (e.g., `"EPSG:3347"`, or `"EPSG:4326"` for EPSG:4326 (WGS84)).
4703
4706
  * @param options - An optional object with configuration options:
4704
4707
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4725,8 +4728,6 @@ class SimpleTable extends Simple_js_1.default {
4725
4728
  * Computes the area of geometries in square meters (`"m2"`) or optionally square kilometers (`"km2"`).
4726
4729
  * The input geometry is assumed to be in EPSG:4326 (WGS84).
4727
4730
  *
4728
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4729
- *
4730
4731
  * @param newColumn - The name of the new column where the computed areas will be stored.
4731
4732
  * @param options - An optional object with configuration options:
4732
4733
  * @param options.unit - The unit for the computed area: `"m2"` (square meters) or `"km2"` (square kilometers). Defaults to `"m2"`.
@@ -4767,8 +4768,6 @@ class SimpleTable extends Simple_js_1.default {
4767
4768
  * Computes the length of line geometries in meters (`"m"`) or optionally kilometers (`"km"`).
4768
4769
  * The input geometry is assumed to be in EPSG:4326 (WGS84).
4769
4770
  *
4770
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4771
- *
4772
4771
  * @param newColumn - The name of the new column where the computed lengths will be stored.
4773
4772
  * @param options - An optional object with configuration options:
4774
4773
  * @param options.unit - The unit for the computed length: `"m"` (meters) or `"km"` (kilometers). Defaults to `"m"`.
@@ -4809,8 +4808,6 @@ class SimpleTable extends Simple_js_1.default {
4809
4808
  * Computes the perimeter of polygon geometries in meters (`"m"`) or optionally kilometers (`"km"`).
4810
4809
  * The input geometry is assumed to be in EPSG:4326 (WGS84).
4811
4810
  *
4812
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4813
- *
4814
4811
  * @param newColumn - The name of the new column where the computed perimeters will be stored.
4815
4812
  * @param options - An optional object with configuration options:
4816
4813
  * @param options.unit - The unit for the computed perimeter: `"m"` (meters) or `"km"` (kilometers). Defaults to `"m"`.
@@ -4851,8 +4848,6 @@ class SimpleTable extends Simple_js_1.default {
4851
4848
  * Computes a buffer (a polygon representing a specified distance around a geometry) for geometries in a specified column.
4852
4849
  * The distance is in the Spatial Reference System (SRS) unit of the input geometries.
4853
4850
  *
4854
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4855
- *
4856
4851
  * @param newColumn - The name of the new column where the buffered geometries will be stored.
4857
4852
  * @param distance - The distance for the buffer. This value is in the units of the geometry's SRS.
4858
4853
  * @param options - An optional object with configuration options:
@@ -4880,7 +4875,6 @@ class SimpleTable extends Simple_js_1.default {
4880
4875
  * Merges the data of this table (considered the left table) with another table (the right table) based on a spatial relationship.
4881
4876
  * Note that the order of rows in the returned data is not guaranteed to be the same as in the original tables.
4882
4877
  * This operation might create temporary files in a `.tmp` folder; consider adding `.tmp` to your `.gitignore`.
4883
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called. The join uses the other table's state as of this call: operations queued on it afterwards run after the join.
4884
4878
  *
4885
4879
  * @param rightTable - The SimpleTable instance to be joined with this table.
4886
4880
  * @param method - The spatial join method to use: `"intersect"` (geometries overlap), `"inside"` (geometries of the left table are entirely within geometries of the right table), or `"withinDistance"` (geometries of the left table are within a specified distance of geometries in the right table).
@@ -4952,8 +4946,6 @@ class SimpleTable extends Simple_js_1.default {
4952
4946
  /**
4953
4947
  * Computes the intersection of two sets of geometries, creating new geometries where they overlap.
4954
4948
  *
4955
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4956
- *
4957
4949
  * @param column1 - The name of the first column storing geometries.
4958
4950
  * @param column2 - The name of the second column storing geometries. Both columns must have the same projection.
4959
4951
  * @param newColumn - The name of the new column where the computed intersection geometries will be stored.
@@ -4973,8 +4965,6 @@ class SimpleTable extends Simple_js_1.default {
4973
4965
  /**
4974
4966
  * Computes the geometric difference between two geometries, returning the portion of the first geometry that does not intersect the second.
4975
4967
  *
4976
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4977
- *
4978
4968
  * @param column1 - The name of the column storing the geometries from which the second geometries will be subtracted.
4979
4969
  * @param column2 - The name of the column storing the geometries to subtract. Both columns must have the same projection.
4980
4970
  * @param newColumn - The name of the new column where the geometric differences will be stored.
@@ -4994,8 +4984,6 @@ class SimpleTable extends Simple_js_1.default {
4994
4984
  /**
4995
4985
  * Fills holes in polygon geometries.
4996
4986
  *
4997
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4998
- *
4999
4987
  * @param column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
5000
4988
  * @returns The table, so methods can be chained.
5001
4989
  * @category Geospatial
@@ -5019,8 +5007,6 @@ class SimpleTable extends Simple_js_1.default {
5019
5007
  /**
5020
5008
  * Returns `TRUE` if two geometries intersect (overlap in any way), and `FALSE` otherwise.
5021
5009
  *
5022
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5023
- *
5024
5010
  * @param column1 - The name of the first column storing geometries.
5025
5011
  * @param column2 - The name of the second column storing geometries. Both columns must have the same projection.
5026
5012
  * @param newColumn - The name of the new column where the boolean results (`TRUE` for intersection, `FALSE` otherwise) will be stored.
@@ -5040,8 +5026,6 @@ class SimpleTable extends Simple_js_1.default {
5040
5026
  /**
5041
5027
  * Returns `TRUE` if every point of a geometry in `column` is covered by a geometry in `containerColumn`, including their boundaries, and `FALSE` otherwise.
5042
5028
  *
5043
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5044
- *
5045
5029
  * @param column - The name of the column storing the geometries to be tested for containment.
5046
5030
  * @param containerColumn - The name of the column storing the geometries to be tested as containers. Both columns must have the same projection.
5047
5031
  * @param newColumn - The name of the new column where the boolean results (`TRUE` when covered, `FALSE` otherwise) will be stored.
@@ -5061,8 +5045,6 @@ class SimpleTable extends Simple_js_1.default {
5061
5045
  /**
5062
5046
  * Computes the union of two geometries, creating a new geometry that represents the merged area of both.
5063
5047
  *
5064
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5065
- *
5066
5048
  * @param column1 - The name of the first column storing geometries.
5067
5049
  * @param column2 - The name of the second column storing geometries. Both columns must have the same projection.
5068
5050
  * @param newColumn - The name of the new column where the computed union geometries will be stored.
@@ -5083,8 +5065,6 @@ class SimpleTable extends Simple_js_1.default {
5083
5065
  * Extracts the latitude (y) and longitude (x) coordinates from point geometries.
5084
5066
  * The input geometry is assumed to be in EPSG:4326 (WGS84).
5085
5067
  *
5086
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5087
- *
5088
5068
  * @param column - The name of the column storing the point geometries.
5089
5069
  * @param latColumn - The name of the new column where the extracted latitude (y-coordinate) values will be stored.
5090
5070
  * @param lonColumn - The name of the new column where the extracted longitude (x-coordinate) values will be stored.
@@ -5104,8 +5084,6 @@ class SimpleTable extends Simple_js_1.default {
5104
5084
  /**
5105
5085
  * Simplifies geometries while preserving their overall coverage. A higher tolerance results in more significant simplification.
5106
5086
  *
5107
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5108
- *
5109
5087
  * @param tolerance - A numeric value representing the simplification tolerance. A higher value leads to greater simplification.
5110
5088
  * @param options - An optional object with configuration options:
5111
5089
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -5133,8 +5111,6 @@ class SimpleTable extends Simple_js_1.default {
5133
5111
  * Computes the centroid of geometries.
5134
5112
  * The values are returned in the SRS unit of the input geometries.
5135
5113
  *
5136
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5137
- *
5138
5114
  * @param newColumn - The name of the new column where the computed centroid geometries will be stored.
5139
5115
  * @param options - An optional object with configuration options:
5140
5116
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -5160,8 +5136,6 @@ class SimpleTable extends Simple_js_1.default {
5160
5136
  /**
5161
5137
  * Generates a random point within the geometries of a specified column.
5162
5138
  *
5163
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5164
- *
5165
5139
  * @param newColumn - The name of the new column where the random points will be stored.
5166
5140
  * @param tries - The number of points to generate within the bounding box of each geometry to find one that is within the geometry itself.
5167
5141
  * @param options - An optional object with configuration options:
@@ -5196,8 +5170,6 @@ class SimpleTable extends Simple_js_1.default {
5196
5170
  * You can optionally specify `"spheroid"` or `"haversine"` methods to get results in meters or kilometers.
5197
5171
  * If using `"spheroid"` or `"haversine"`, the input geometries must be in EPSG:4326 (WGS84).
5198
5172
  *
5199
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5200
- *
5201
5173
  * @param column1 - The name of the first column storing geometries.
5202
5174
  * @param column2 - The name of the second column storing geometries.
5203
5175
  * @param newColumn - The name of the new column where the computed distances will be stored.
@@ -5242,8 +5214,6 @@ class SimpleTable extends Simple_js_1.default {
5242
5214
  /**
5243
5215
  * Unnests geometries recursively, transforming multi-part geometries (e.g., MultiPolygon) into individual single-part geometries (e.g., Polygon).
5244
5216
  *
5245
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5246
- *
5247
5217
  * @param column - The name of the column storing the geometries to be unnested. If omitted, the method will automatically attempt to find a geometry column.
5248
5218
  * @returns The table, so methods can be chained.
5249
5219
  * @category Geospatial
@@ -5267,8 +5237,6 @@ class SimpleTable extends Simple_js_1.default {
5267
5237
  /**
5268
5238
  * Adds the bounding box coordinates of geometries in a specified column as four new columns: `minLon`, `minLat`, `maxLon`, and `maxLat`.
5269
5239
  *
5270
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5271
- *
5272
5240
  * @param options - An optional object with configuration options:
5273
5241
  * @param options.column - The name of the column storing the geometries for which the bounding box will be computed. If omitted, the method will automatically attempt to find a geometry column.
5274
5242
  * @param options.decimals - The number of decimal places to round the bounding box coordinates. Defaults to `undefined` (no rounding).
@@ -5296,8 +5264,6 @@ class SimpleTable extends Simple_js_1.default {
5296
5264
  /**
5297
5265
  * Aggregates geometries in a specified column based on a chosen aggregation method.
5298
5266
  *
5299
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5300
- *
5301
5267
  * @param method - The aggregation method to apply: `"union"` (combines all geometries into a single multi-geometry) or `"intersection"` (computes the intersection of all geometries).
5302
5268
  * @param options - An optional object with configuration options:
5303
5269
  * @param options.column - The name of the column storing the geometries to be aggregated. If omitted, the method will automatically attempt to find a geometry column.
@@ -5330,8 +5296,6 @@ class SimpleTable extends Simple_js_1.default {
5330
5296
  /**
5331
5297
  * Transforms closed linestring geometries into polygon geometries.
5332
5298
  *
5333
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5334
- *
5335
5299
  * @param column - The name of the column storing the linestring geometries. If omitted, the method will automatically attempt to find a geometry column.
5336
5300
  * @returns The table, so methods can be chained.
5337
5301
  * @category Geospatial
@@ -5378,7 +5342,9 @@ class SimpleTable extends Simple_js_1.default {
5378
5342
  return await (0, getBoundingBox_js_1.default)(this, column);
5379
5343
  }
5380
5344
  /**
5381
- * Returns the table's geospatial data as a GeoJSON object.
5345
+ * Returns the table's geospatial data as a GeoJSON FeatureCollection.
5346
+ * Each row becomes a Feature: the selected geometry column becomes its geometry,
5347
+ * and the remaining columns become its properties.
5382
5348
  * If the table has multiple geometry columns, you must specify which one to use.
5383
5349
  *
5384
5350
  * @param column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -5416,12 +5382,13 @@ class SimpleTable extends Simple_js_1.default {
5416
5382
  }
5417
5383
  /**
5418
5384
  * Writes the table's data to a file in various formats (CSV, JSON, Parquet, DuckDB, SQLite).
5385
+ * Tables with geometry columns must use `writeGeoData()` instead.
5419
5386
  * If the specified path does not exist, it will be created.
5420
5387
  *
5421
5388
  * @param file - The absolute path to the output file (e.g., `"./output.csv"`, `"./output.json"`).
5422
5389
  * @param options - An optional object with configuration options:
5423
5390
  * @param options.compression - A boolean indicating whether to compress the output file. If `true`, CSV and JSON files will be compressed with GZIP, while Parquet files will use ZSTD. Defaults to `false`.
5424
- * @param options.dataAsArrays - For JSON files only. If `true`, JSON files are written as a single object with arrays for each column (e.g., `{ "col1": [v1, v2], "col2": [v3, v4] }`) instead of an array of objects. This can reduce file size for web projects. You can use the `arraysToData` function from the [journalism library](https://jsr.io/@nshiab/journalism/doc/~/arraysToData) to convert it back.
5391
+ * @param options.dataAsArrays - For JSON files only. If `true`, JSON files are written as a single object with arrays for each column (e.g., `{ "col1": [v1, v2], "col2": [v3, v4] }`) instead of an array of objects. This can reduce file size for web projects. You can use the `arraysToData` function from the [journalism-format library](https://jsr.io/@nshiab/journalism-format/doc/~/arraysToData) to convert it back.
5425
5392
  * @param options.formatDates - For CSV and JSON files only. If `true`, date and timestamp columns will be formatted as ISO 8601 strings (e.g., `"2025-01-01T01:00:00.000Z"`). Defaults to `false`.
5426
5393
  * @returns A promise that resolves to the table, so methods can be chained.
5427
5394
  * @category File Operations
@@ -5522,28 +5489,28 @@ class SimpleTable extends Simple_js_1.default {
5522
5489
  * Caches the results of computations in `./.sda-cache`.
5523
5490
  * You should add `./.sda-cache` to your `.gitignore` file.
5524
5491
  *
5525
- * Cache entries are stored as DuckDB database files. Full-text search (FTS)
5526
- * indexes are persisted in the cache file and restored directly on a cache
5527
- * hit. Vector similarity search (VSS/HNSW) indexes are not persisted in the
5528
- * cache file; their definitions are stored as metadata and used to rebuild
5529
- * the indexes on every cache hit. If loading the entry or restoring its
5530
- * indexes fails, the computation runs again and replaces the cache entry.
5531
- *
5532
5492
  * `cache()` automatically tracks whether earlier SDA operations changed the
5533
5493
  * table. It also records every other already registered `SimpleTable` read
5534
5494
  * through `SimpleTable` methods while `compute` runs and invalidates the
5535
5495
  * cached step when any of their generations change. Tables created inside
5536
5496
  * `compute` are part of the computation itself and are not dependencies.
5537
5497
  *
5498
+ * Inside `compute`, you may modify the table being cached and create or
5499
+ * modify temporary tables, provided you remove them before the callback
5500
+ * finishes. Other tables that already existed may be read but not modified,
5501
+ * renamed, or removed. `customQuery()` bypasses enforcement of these rules.
5502
+ *
5538
5503
  * `SimpleDB.customQuery()` bypasses this tracking. Reading or changing a
5539
5504
  * table with `customQuery()` can therefore return stale cached data. Include
5540
5505
  * a value that identifies the custom query's dependencies in `options.inputs`
5541
5506
  * (such as a table content hash), or use tracked `SimpleTable` methods.
5542
5507
  *
5543
- * `compute` may modify only the table being cached. Other tables that existed
5544
- * before `compute` must remain read-only. Temporary tables may be created and
5545
- * modified inside `compute`, but they must be removed before it finishes
5546
- * because a cache hit does not run `compute` again.
5508
+ * Cache entries are stored as DuckDB database files. Full-text search (FTS)
5509
+ * indexes are persisted in the cache file and restored directly on a cache
5510
+ * hit. Vector similarity search (VSS/HNSW) indexes are not persisted in the
5511
+ * cache file; their definitions are stored as metadata and used to rebuild
5512
+ * the indexes on every cache hit. If loading the entry or restoring its
5513
+ * indexes fails, the computation runs again and replaces the cache entry.
5547
5514
  *
5548
5515
  * @param compute - A function wrapping the computations to be cached. It receives the table on which `cache()` was called. This function will be executed on the first run or if the cached data is invalid/expired.
5549
5516
  * @param options - An optional object with configuration options:
@@ -5626,12 +5593,23 @@ class SimpleTable extends Simple_js_1.default {
5626
5593
  return this;
5627
5594
  }
5628
5595
  /**
5629
- * Logs a specified number of rows from the table to the console. By default, the first 10 rows are logged.
5596
+ * Logs up to a specified number of rows from the table to the console. By default, the first 10 rows are logged.
5630
5597
  * You can optionally log the column types and filter the data based on conditions.
5631
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
5598
+ * The footer reports the total number of matching rows and, only when some rows
5599
+ * are omitted, the number actually shown (for example, `100 rows in total / showing 15 rows`).
5600
+ * SQL dates and timestamps retain their native precision for display, including
5601
+ * temporal infinities. Lists and objects are stringified using the same nested
5602
+ * representations as `getData()`, then truncated according to `charsToLog`.
5603
+ * Unsafe top-level large integers throw, just as with `getData()`.
5604
+ * Type annotations describe the SQL type and the JavaScript extraction type
5605
+ * before display formatting; nulls do not determine the column's annotation.
5606
+ * Colors reflect the SQL value's meaning, so exact decimal strings use numeric
5607
+ * coloring. Column width is independent of the content truncation budget.
5608
+ *
5609
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
5632
5610
  *
5633
5611
  * @param options - Either the number of rows to log (a specific number or `"all"`) or an object with configuration options:
5634
- * @param options.count - The number of rows to log. Defaults to 10 or the value set in the SimpleDB instance. Use `"all"` to log all rows.
5612
+ * @param options.count - The maximum number of rows to log. Defaults to 10 or the value set in the SimpleDB instance. Use `"all"` to log all rows.
5635
5613
  * @param options.types - Whether to log the column types along with the data. Defaults to the value set in the SimpleDB instance.
5636
5614
  * @param options.conditions - A SQL `WHERE` clause condition to filter the data before logging. Defaults to no condition.
5637
5615
  * @returns A promise that resolves to the table, so methods can be chained.
@@ -5668,57 +5646,7 @@ class SimpleTable extends Simple_js_1.default {
5668
5646
  * ```
5669
5647
  */
5670
5648
  async log(options = {}) {
5671
- if (this.connection === undefined) {
5672
- await this.sdb.start();
5673
- this.db = this.sdb.db;
5674
- this.connection = this.sdb.connection;
5675
- }
5676
- if (this.connection === undefined) {
5677
- throw new Error("this.connection is undefined");
5678
- }
5679
- let count;
5680
- if (typeof options === "number") {
5681
- count = options;
5682
- }
5683
- else if (options === "all") {
5684
- count = await this.getRowCount();
5685
- }
5686
- else if (typeof options === "object") {
5687
- if (options.count === "all") {
5688
- count = await this.getRowCount();
5689
- }
5690
- else if (typeof options.count === "number") {
5691
- count = options.count;
5692
- }
5693
- else {
5694
- count = this.rowsToLog;
5695
- }
5696
- }
5697
- else {
5698
- count = this.rowsToLog;
5699
- }
5700
- const types = typeof options === "object"
5701
- ? options.types ?? this.typesToLog
5702
- : this.typesToLog;
5703
- const conditions = typeof options === "object"
5704
- ? options.conditions ?? undefined
5705
- : undefined;
5706
- if (this.connection === undefined ||
5707
- !(await this.sdb.hasTable(this.name))) {
5708
- console.log(`\nTable ${this.name}: no data`);
5709
- }
5710
- else {
5711
- console.log(`\nTable ${this.name}:`);
5712
- conditions && console.log(`Conditions: ${conditions}`);
5713
- const data = await this.getTop(count, { conditions });
5714
- (0, logData_js_1.default)(types ? await this.getTypes() : null, data, this.charsToLog);
5715
- const rowCount = conditions
5716
- ? parseInt((await this.sdb.customQuery(`select count(*) as count from ${(0, quoteIdentifier_js_1.default)(this.name)} where ${conditions}`, { returnData: true }))[0].count)
5717
- : await this.getRowCount();
5718
- console.log(`${(0, formatNumber_js_1.default)(rowCount)} rows in total ${`(count: ${count}${typeof this.charsToLog === "number"
5719
- ? `, charsToLog: ${this.charsToLog}`
5720
- : ""})`}`);
5721
- }
5649
+ await (0, log_js_1.default)(this, options);
5722
5650
  return this;
5723
5651
  }
5724
5652
  /**
@@ -5920,6 +5848,10 @@ class SimpleTable extends Simple_js_1.default {
5920
5848
  /**
5921
5849
  * Logs the bottom `n` rows of the table to the console. By default, the last row will be returned first. To preserve the original order, use the `originalOrder` option.
5922
5850
  *
5851
+ * Uses the same precision-preserving temporal display, nested stringification,
5852
+ * numeric coloring, and `charsToLog` truncation as `log()`. Unsafe top-level
5853
+ * large integers throw, just as with `getData()`.
5854
+ *
5923
5855
  * @param count - The number of rows to log from the bottom of the table. Defaults to the table's `rowsToLog` option if not specified.
5924
5856
  * @param options - An optional object with logging preferences.
5925
5857
  * @param options.originalOrder - If true, the rows are displayed in their original order (top to bottom). Defaults to false.
@@ -5945,10 +5877,7 @@ class SimpleTable extends Simple_js_1.default {
5945
5877
  * ```
5946
5878
  */
5947
5879
  async logBottom(count, options = {}) {
5948
- const rows = count ?? this.rowsToLog;
5949
- console.log(`\nTable ${this.name} (${rows} bottom rows):`);
5950
- const data = await this.getBottom(rows, options);
5951
- (0, logData_js_1.default)(null, data, this.charsToLog);
5880
+ await (0, logBottom_js_1.default)(this, count, options);
5952
5881
  return this;
5953
5882
  }
5954
5883
  /**