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

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 (238) 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 +251 -274
  9. package/esm/class/SimpleTable.d.ts.map +1 -1
  10. package/esm/class/SimpleTable.js +248 -325
  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/bm25.d.ts.map +1 -1
  77. package/esm/methods/bm25.js +1 -2
  78. package/esm/methods/cache.d.ts.map +1 -1
  79. package/esm/methods/cache.js +4 -6
  80. package/esm/methods/convert.d.ts +2 -2
  81. package/esm/methods/convert.d.ts.map +1 -1
  82. package/esm/methods/convert.js +5 -0
  83. package/esm/methods/getBottom.d.ts +1 -1
  84. package/esm/methods/getBottom.d.ts.map +1 -1
  85. package/esm/methods/getBottom.js +2 -2
  86. package/esm/methods/getData.d.ts +1 -1
  87. package/esm/methods/getData.d.ts.map +1 -1
  88. package/esm/methods/getData.js +2 -2
  89. package/esm/methods/join.d.ts.map +1 -1
  90. package/esm/methods/join.js +8 -16
  91. package/esm/methods/joinGeo.d.ts.map +1 -1
  92. package/esm/methods/joinGeo.js +10 -19
  93. package/esm/methods/loadArray.d.ts +1 -1
  94. package/esm/methods/loadArray.d.ts.map +1 -1
  95. package/esm/methods/loadArray.js +74 -19
  96. package/esm/methods/loadData.js +3 -0
  97. package/esm/methods/log.d.ts +7 -0
  98. package/esm/methods/log.d.ts.map +1 -0
  99. package/esm/methods/log.js +58 -0
  100. package/esm/methods/logBottom.d.ts +5 -0
  101. package/esm/methods/logBottom.d.ts.map +1 -0
  102. package/esm/methods/logBottom.js +9 -0
  103. package/esm/methods/removeTable.d.ts.map +1 -1
  104. package/esm/methods/removeTable.js +2 -0
  105. package/esm/methods/removeTables.d.ts.map +1 -1
  106. package/esm/methods/removeTables.js +7 -0
  107. package/esm/methods/renameTable.d.ts.map +1 -1
  108. package/esm/methods/renameTable.js +4 -0
  109. package/esm/methods/rowToText.js +2 -2
  110. package/esm/methods/selectTables.d.ts.map +1 -1
  111. package/esm/methods/selectTables.js +6 -0
  112. package/esm/methods/setTypes.d.ts +1 -1
  113. package/esm/methods/setTypes.d.ts.map +1 -1
  114. package/esm/methods/stream.d.ts.map +1 -1
  115. package/esm/methods/stream.js +2 -1
  116. package/esm/methods/updateWithJS.d.ts +1 -3
  117. package/esm/methods/updateWithJS.d.ts.map +1 -1
  118. package/esm/methods/updateWithJS.js +123 -37
  119. package/llm.md +337 -444
  120. package/llms.txt +1 -1
  121. package/package.json +1 -1
  122. package/script/class/Simple.d.ts +8 -2
  123. package/script/class/Simple.d.ts.map +1 -1
  124. package/script/class/Simple.js +9 -3
  125. package/script/class/SimpleDB.d.ts +72 -1
  126. package/script/class/SimpleDB.d.ts.map +1 -1
  127. package/script/class/SimpleDB.js +81 -1
  128. package/script/class/SimpleTable.d.ts +251 -274
  129. package/script/class/SimpleTable.d.ts.map +1 -1
  130. package/script/class/SimpleTable.js +248 -325
  131. package/script/helpers/LogValue.d.ts +8 -0
  132. package/script/helpers/LogValue.d.ts.map +1 -0
  133. package/script/helpers/LogValue.js +26 -0
  134. package/script/helpers/cacheTableDependencies.d.ts +9 -0
  135. package/script/helpers/cacheTableDependencies.d.ts.map +1 -1
  136. package/script/helpers/cacheTableDependencies.js +170 -20
  137. package/script/helpers/cleanSQL.d.ts +1 -1
  138. package/script/helpers/cleanSQL.d.ts.map +1 -1
  139. package/script/helpers/cleanSQL.js +271 -23
  140. package/script/helpers/flushAllTables.d.ts.map +1 -1
  141. package/script/helpers/flushAllTables.js +24 -29
  142. package/script/helpers/foldIdentifier.d.ts +3 -0
  143. package/script/helpers/foldIdentifier.d.ts.map +1 -0
  144. package/script/helpers/foldIdentifier.js +7 -0
  145. package/script/helpers/geometryFromJSON.d.ts +3 -0
  146. package/script/helpers/geometryFromJSON.d.ts.map +1 -0
  147. package/script/helpers/geometryFromJSON.js +7 -0
  148. package/script/helpers/index.d.ts +1 -0
  149. package/script/helpers/index.d.ts.map +1 -1
  150. package/script/helpers/index.js +3 -1
  151. package/script/helpers/logData.d.ts.map +1 -1
  152. package/script/helpers/logData.js +45 -44
  153. package/script/helpers/makeLogConverter.d.ts +5 -0
  154. package/script/helpers/makeLogConverter.d.ts.map +1 -0
  155. package/script/helpers/makeLogConverter.js +70 -0
  156. package/script/helpers/osmFiles.d.ts.map +1 -1
  157. package/script/helpers/parseTypes.d.ts +1 -1
  158. package/script/helpers/parseTypes.d.ts.map +1 -1
  159. package/script/helpers/parseTypes.js +4 -0
  160. package/script/helpers/pendingOps.d.ts +4 -2
  161. package/script/helpers/pendingOps.d.ts.map +1 -1
  162. package/script/helpers/prepareGeometry.d.ts +3 -0
  163. package/script/helpers/prepareGeometry.d.ts.map +1 -0
  164. package/script/helpers/prepareGeometry.js +102 -0
  165. package/script/helpers/prepareJSON.d.ts +3 -0
  166. package/script/helpers/prepareJSON.d.ts.map +1 -0
  167. package/script/helpers/prepareJSON.js +53 -0
  168. package/script/helpers/printTable.d.ts +5 -4
  169. package/script/helpers/printTable.d.ts.map +1 -1
  170. package/script/helpers/printTable.js +32 -36
  171. package/script/helpers/queryDB.js +1 -1
  172. package/script/helpers/queueAsyncBarrier.d.ts +4 -0
  173. package/script/helpers/queueAsyncBarrier.d.ts.map +1 -1
  174. package/script/helpers/queueAsyncBarrier.js +4 -0
  175. package/script/helpers/queueOp.d.ts.map +1 -1
  176. package/script/helpers/queueOp.js +4 -2
  177. package/script/helpers/readMutationRows.d.ts +9 -0
  178. package/script/helpers/readMutationRows.d.ts.map +1 -0
  179. package/script/helpers/readMutationRows.js +97 -0
  180. package/script/helpers/referencedTables.d.ts +9 -0
  181. package/script/helpers/referencedTables.d.ts.map +1 -0
  182. package/script/helpers/referencedTables.js +28 -0
  183. package/script/helpers/runQuery.d.ts.map +1 -1
  184. package/script/helpers/runQuery.js +11 -13
  185. package/script/helpers/scanSQL.d.ts +7 -0
  186. package/script/helpers/scanSQL.d.ts.map +1 -0
  187. package/script/helpers/scanSQL.js +74 -0
  188. package/script/helpers/tableRegistry.d.ts +2 -0
  189. package/script/helpers/tableRegistry.d.ts.map +1 -1
  190. package/script/helpers/tableRegistry.js +16 -4
  191. package/script/helpers/updateColumnsWithJS.d.ts +52 -0
  192. package/script/helpers/updateColumnsWithJS.d.ts.map +1 -0
  193. package/script/helpers/updateColumnsWithJS.js +145 -0
  194. package/script/methods/addColumn.d.ts +1 -1
  195. package/script/methods/addColumn.d.ts.map +1 -1
  196. package/script/methods/bm25.d.ts.map +1 -1
  197. package/script/methods/bm25.js +1 -2
  198. package/script/methods/cache.d.ts.map +1 -1
  199. package/script/methods/cache.js +3 -5
  200. package/script/methods/convert.d.ts +2 -2
  201. package/script/methods/convert.d.ts.map +1 -1
  202. package/script/methods/convert.js +5 -0
  203. package/script/methods/getBottom.d.ts +1 -1
  204. package/script/methods/getBottom.d.ts.map +1 -1
  205. package/script/methods/getBottom.js +2 -2
  206. package/script/methods/getData.d.ts +1 -1
  207. package/script/methods/getData.d.ts.map +1 -1
  208. package/script/methods/getData.js +2 -2
  209. package/script/methods/join.d.ts.map +1 -1
  210. package/script/methods/join.js +8 -16
  211. package/script/methods/joinGeo.d.ts.map +1 -1
  212. package/script/methods/joinGeo.js +10 -19
  213. package/script/methods/loadArray.d.ts +1 -1
  214. package/script/methods/loadArray.d.ts.map +1 -1
  215. package/script/methods/loadArray.js +74 -19
  216. package/script/methods/loadData.js +3 -0
  217. package/script/methods/log.d.ts +7 -0
  218. package/script/methods/log.d.ts.map +1 -0
  219. package/script/methods/log.js +64 -0
  220. package/script/methods/logBottom.d.ts +5 -0
  221. package/script/methods/logBottom.d.ts.map +1 -0
  222. package/script/methods/logBottom.js +15 -0
  223. package/script/methods/removeTable.d.ts.map +1 -1
  224. package/script/methods/removeTable.js +2 -0
  225. package/script/methods/removeTables.d.ts.map +1 -1
  226. package/script/methods/removeTables.js +7 -0
  227. package/script/methods/renameTable.d.ts.map +1 -1
  228. package/script/methods/renameTable.js +4 -0
  229. package/script/methods/rowToText.js +2 -2
  230. package/script/methods/selectTables.d.ts.map +1 -1
  231. package/script/methods/selectTables.js +6 -0
  232. package/script/methods/setTypes.d.ts +1 -1
  233. package/script/methods/setTypes.d.ts.map +1 -1
  234. package/script/methods/stream.d.ts.map +1 -1
  235. package/script/methods/stream.js +2 -1
  236. package/script/methods/updateWithJS.d.ts +1 -3
  237. package/script/methods/updateWithJS.d.ts.map +1 -1
  238. package/script/methods/updateWithJS.js +122 -36
@@ -10,6 +10,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
12
  var _SimpleTable_name;
13
+ import logBottom from "../methods/logBottom.js";
14
+ import log from "../methods/log.js";
13
15
  import quoteIdentifier from "../helpers/quoteIdentifier.js";
14
16
  import csvFormat from "../helpers/csvFormat.js";
15
17
  import getDescription from "../methods/getDescription.js";
@@ -223,7 +225,7 @@ class SimpleTable extends Simple {
223
225
  * @param simpleDB - The SimpleDB instance that this table belongs to.
224
226
  * @param options - An optional object with configuration options:
225
227
  * @param options.rowsToLog - The number of rows to log when displaying table data.
226
- * @param options.charsToLog - The maximum number of characters to log for strings. Useful to avoid logging large text content.
228
+ * @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.
227
229
  * @param options.typesToLog - A boolean indicating whether to include data types when logging a table.
228
230
  * @category Constructor
229
231
  */
@@ -299,6 +301,7 @@ class SimpleTable extends Simple {
299
301
  }
300
302
  /**
301
303
  * Renames the current table.
304
+ * The new name must not belong to another registered table, ignoring ASCII letter case.
302
305
  *
303
306
  * @param name - The new name for the table.
304
307
  * @returns A promise that resolves to the renamed table.
@@ -320,9 +323,7 @@ class SimpleTable extends Simple {
320
323
  * Sets the data types for columns in a new table. If the table already exists, it will be replaced.
321
324
  * To convert the types of an existing table, use the `.convert()` method instead.
322
325
  *
323
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
324
- *
325
- * @param types - An object specifying the column names and their target data types (JavaScript or SQL types).
326
+ * @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.
326
327
  * @returns The table, so methods can be chained.
327
328
  * @category Table Management
328
329
  *
@@ -335,28 +336,43 @@ class SimpleTable extends Simple {
335
336
  * raise: "float",
336
337
  * }).log();
337
338
  * ```
339
+ *
340
+ * @example
341
+ * ```ts
342
+ * // Create an empty table with JSON, embedding, and geometry columns.
343
+ * await table.setTypes({
344
+ * details: "JSON",
345
+ * embedding: "FLOAT[3]",
346
+ * geom: "GEOMETRY('EPSG:4326')",
347
+ * }).log();
348
+ * ```
338
349
  */
339
350
  setTypes(types) {
340
351
  setTypes(this, types);
341
352
  return this;
342
353
  }
343
354
  /**
344
- * 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.
355
+ * Loads an array of JavaScript objects into the table. Types are inferred for
356
+ * numbers, bigints, strings, booleans, and Date values. Array and object cells
357
+ * require an explicit supported type in columnTypes. Types can also be
358
+ * specified for scalar columns instead of inferred from their values.
345
359
  *
346
360
  * JavaScript `Date` values are inferred as DuckDB `TIMESTAMP` values. Their
347
361
  * instant is preserved, but JavaScript `Date` does not retain the timezone or
348
- * offset originally used to construct it. String values remain `VARCHAR`;
349
- * use `convert()` to parse them as temporal values.
362
+ * offset originally used to construct it.
363
+ *
364
+ * Declare `JSON` for general nested data, `FLOAT[n]` for a fixed-size float
365
+ * vector, or `GEOMETRY('EPSG:4326')` for GeoJSON geometries in WGS84.
350
366
  *
351
367
  * @param rows - An array of objects, where each object represents a row and its properties represent columns.
352
368
  * @param options - Options for loading the array, captured when called.
353
- * @param options.columnTypes - Types for specific columns; omitted columns are inferred. Values must be compatible with the selected type without losing information.
369
+ * @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.
354
370
  * @returns The table, so methods can be chained.
355
371
  * @category Importing Data
356
372
  *
357
373
  * @example
358
374
  * ```ts
359
- * // Load data from an array of objects
375
+ * // Load scalar columns without columnTypes; strings and numbers are inferred.
360
376
  * const data = [
361
377
  * { letter: "a", number: 1 },
362
378
  * { letter: "b", number: 2 }
@@ -366,7 +382,7 @@ class SimpleTable extends Simple {
366
382
  *
367
383
  * @example
368
384
  * ```ts
369
- * // Specify a numeric type for an all-null column
385
+ * // Choose a numeric type when all-null values provide nothing to infer.
370
386
  * await table.loadArray(
371
387
  * [{ name: "A", value: null }, { name: "B", value: null }],
372
388
  * { columnTypes: { value: "DOUBLE" } },
@@ -375,12 +391,39 @@ class SimpleTable extends Simple {
375
391
  *
376
392
  * @example
377
393
  * ```ts
378
- * // The offset determines the instant; the loaded TIMESTAMP is returned as
379
- * // the equivalent UTC JavaScript Date.
394
+ * // Store the Date as a UTC timestamp with JavaScript's millisecond precision.
395
+ * // The original -04:00 offset is not retained.
380
396
  * await table.loadArray([{
381
397
  * observedAt: new Date("2024-04-07T13:00:00-04:00"),
382
398
  * }]).log();
383
399
  * ```
400
+ *
401
+ * @example
402
+ * ```ts
403
+ * // Declare JSON to load nested objects and variable-length arrays directly.
404
+ * await table.loadArray([{
405
+ * name: "Station",
406
+ * metadata: { active: true, tags: ["weather", "urban"] },
407
+ * measurements: [1, 2.5, null],
408
+ * }], { columnTypes: { metadata: "JSON", measurements: "JSON" } }).log();
409
+ * ```
410
+ *
411
+ * @example
412
+ * ```ts
413
+ * // Declare FLOAT[3] to store each three-element array as a fixed-size vector.
414
+ * await table.loadArray([{ vector: [1, 2, 3] }], {
415
+ * columnTypes: { vector: "FLOAT[3]" },
416
+ * }).log();
417
+ * ```
418
+ *
419
+ * @example
420
+ * ```ts
421
+ * // Declare a geometry type to store WGS84 GeoJSON as a spatial column.
422
+ * await table.loadArray([{
423
+ * name: "Montreal",
424
+ * geom: { type: "Point", coordinates: [-73.57, 45.50] },
425
+ * }], { columnTypes: { geom: "GEOMETRY('EPSG:4326')" } }).log();
426
+ * ```
384
427
  */
385
428
  loadArray(rows, options = {}) {
386
429
  loadArray(this, rows, options);
@@ -389,17 +432,18 @@ class SimpleTable extends Simple {
389
432
  /**
390
433
  * Loads data from one or more local or remote files into the table.
391
434
  * Supported file formats include CSV, JSON, Parquet, and Excel.
392
- * This method queues the load; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
435
+ *
436
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
393
437
  *
394
438
  * @param files - The path(s) or URL(s) of the file(s) containing the data to be loaded.
395
439
  * @param options - An optional object with configuration options:
396
440
  * @param options.fileType - The type of file to load ("csv", "dsv", "json", "parquet", "excel"). Defaults to being inferred from the file extension.
397
441
  * @param options.autoDetect - A boolean indicating whether to automatically detect the data format. Defaults to `true`.
398
- * @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.
442
+ * @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`.
399
443
  * @param options.limit - A number indicating the maximum number of matching rows to load, after applying `conditions` if provided. Defaults to all matching rows.
400
444
  * @param options.includeFilename - A boolean indicating whether to include the filename as a new column in the loaded data. Defaults to `false`.
401
445
  * @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`.
402
- * @param options.columnTypes - An object mapping column names to their expected data types. By default, types are inferred.
446
+ * @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.
403
447
  * @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.
404
448
  * @param options.header - A boolean indicating whether the file has a header row. Applicable to CSV files. Defaults to `true`.
405
449
  * @param options.allText - A boolean indicating whether all columns should be treated as text. Applicable to CSV files. Defaults to `false`.
@@ -476,8 +520,6 @@ class SimpleTable extends Simple {
476
520
  }
477
521
  /**
478
522
  * Downloads a complete Statistics Canada table and loads it into this table.
479
- * The method queues the download and load; they run when an async observer
480
- * method (like `getData()` or `log()`) is awaited, or when `run()` is called.
481
523
  *
482
524
  * Results are cached as Parquet files in `.sda-cache/statcan` by default.
483
525
  * Cached data does not expire unless a TTL is provided.
@@ -531,9 +573,6 @@ class SimpleTable extends Simple {
531
573
  * research, and journalistic purposes. Before using it, review Yahoo's terms
532
574
  * and any applicable data-provider restrictions.
533
575
  *
534
- * The method queues the download and load; they run when an async observer
535
- * method (like `getData()` or `log()`) is awaited, or when `run()` is called.
536
- *
537
576
  * @param symbol - The stock or index symbol, such as `"AAPL"` or `"^GSPTSE"`.
538
577
  * @param startDate - The inclusive UTC start of the requested range.
539
578
  * @param endDate - The inclusive UTC end of the requested range. The UTC day,
@@ -580,14 +619,13 @@ class SimpleTable extends Simple {
580
619
  }
581
620
  /**
582
621
  * Loads geospatial data from an external file or URL into the table.
583
- *
584
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
622
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
585
623
  *
586
624
  * @param file - The path or URL of the external file containing the geospatial data.
587
625
  * @param options - An optional object with configuration options:
588
626
  * @param options.toEPSG4326 - If `true`, the method will attempt to reproject the data to EPSG:4326 (WGS84).
589
627
  * @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.
590
- * @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.
628
+ * @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.
591
629
  * @returns The table, so methods can be chained.
592
630
  * @category Geospatial
593
631
  *
@@ -641,7 +679,7 @@ class SimpleTable extends Simple {
641
679
  return this;
642
680
  }
643
681
  /**
644
- * 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.
682
+ * 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.
645
683
  *
646
684
  * 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.
647
685
  *
@@ -728,8 +766,6 @@ class SimpleTable extends Simple {
728
766
  * DuckDB FTS indexes do not update automatically when the table changes; use
729
767
  * `overwrite: true` to rebuild the index after modifying the table.
730
768
  *
731
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
732
- *
733
769
  * @param idColumn - The column containing the document identifiers.
734
770
  * @param textColumn - The column containing the text to search.
735
771
  * @param options - An optional object with configuration options:
@@ -788,8 +824,6 @@ class SimpleTable extends Simple {
788
824
  * 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`.
789
825
  * The index definition is recorded in {@link indexes}.
790
826
  *
791
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
792
- *
793
827
  * @param column - The name of the column containing vector embeddings (must be FLOAT array type).
794
828
  * @param options - An optional object with configuration options:
795
829
  * @param options.overwrite - If `true`, drops and recreates the index even if it already exists. Defaults to `false`.
@@ -850,8 +884,6 @@ class SimpleTable extends Simple {
850
884
  * changes; use `overwriteIndex: true` to rebuild the index after modifying
851
885
  * the table.
852
886
  *
853
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
854
- *
855
887
  * @param text - The search query text to match against the text column.
856
888
  * @param idColumn - The name of the column containing unique identifiers for each row.
857
889
  * @param textColumn - The name of the column containing the text to search.
@@ -953,8 +985,6 @@ class SimpleTable extends Simple {
953
985
  /**
954
986
  * Inserts rows, provided as an array of JavaScript objects, into the table.
955
987
  *
956
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
957
- *
958
988
  * @param rows - An array of objects, where each object represents a row to be inserted and its properties correspond to column names.
959
989
  * @returns The table, so methods can be chained.
960
990
  * @category Importing Data
@@ -974,7 +1004,7 @@ class SimpleTable extends Simple {
974
1004
  return this;
975
1005
  }
976
1006
  /**
977
- * 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.
1007
+ * 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`.
978
1008
  *
979
1009
  * @param tables - The name(s) of the table(s) or SimpleTable instance(s) from which rows will be inserted.
980
1010
  * @param options - An optional object with configuration options:
@@ -1007,8 +1037,6 @@ class SimpleTable extends Simple {
1007
1037
  /**
1008
1038
  * Fetches sample data from the simple-data-analysis-core GitHub repository.
1009
1039
  *
1010
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1011
- *
1012
1040
  * @param sample - The name of the sample to load.
1013
1041
  *
1014
1042
  * Tabular data:
@@ -1034,13 +1062,12 @@ class SimpleTable extends Simple {
1034
1062
  }
1035
1063
  /**
1036
1064
  * 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.
1065
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
1037
1066
  *
1038
1067
  * If `conditions`, `limit`, and `offset` are all used, they are applied in this order: `conditions` (WHERE clause) first, then `offset`, and finally `limit` (LIMIT).
1039
1068
  *
1040
1069
  * Note that cloning large tables can be a slow operation.
1041
1070
  *
1042
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1043
- *
1044
1071
  * @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.
1045
1072
  * @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.
1046
1073
  * @param nameOrOptions.conditions - A SQL `WHERE` clause condition to filter the data during cloning. Defaults to no condition (clones all rows).
@@ -1109,8 +1136,6 @@ class SimpleTable extends Simple {
1109
1136
  /**
1110
1137
  * Clones an existing column in this table, creating a new column with identical values.
1111
1138
  *
1112
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1113
- *
1114
1139
  * @param column - The name of the original column to clone.
1115
1140
  * @param newColumn - The name of the new column to be created.
1116
1141
  * @returns The table, so methods can be chained.
@@ -1132,8 +1157,6 @@ class SimpleTable extends Simple {
1132
1157
  *
1133
1158
  * **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.
1134
1159
  *
1135
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1136
- *
1137
1160
  * @param column - The name of the original column.
1138
1161
  * @param newColumn - The name of the new column to be created with offset values.
1139
1162
  * @param options - An optional object with configuration options:
@@ -1179,8 +1202,6 @@ class SimpleTable extends Simple {
1179
1202
  /**
1180
1203
  * 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`.
1181
1204
  *
1182
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1183
- *
1184
1205
  * @param columns - The column(s) for which to fill `NULL` values.
1185
1206
  * @param options - An optional object with configuration options:
1186
1207
  * @param options.by - A column name or an array of column names to partition by. The fill is applied independently within each group.
@@ -1239,7 +1260,7 @@ class SimpleTable extends Simple {
1239
1260
  * Sorts the rows of the table based on specified column(s) and order(s).
1240
1261
  * If no columns are specified, all columns are sorted from left to right in ascending order.
1241
1262
  *
1242
- * 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.
1263
+ * 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.
1243
1264
  *
1244
1265
  * @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.
1245
1266
  * @param options - An optional object with configuration options:
@@ -1276,7 +1297,7 @@ class SimpleTable extends Simple {
1276
1297
  return this;
1277
1298
  }
1278
1299
  /**
1279
- * 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.
1300
+ * Selects specific columns in the table, removing all others.
1280
1301
  *
1281
1302
  * @param columns - The name or an array of names of the columns to be selected.
1282
1303
  * @returns The table, so methods can be chained.
@@ -1301,8 +1322,6 @@ class SimpleTable extends Simple {
1301
1322
  /**
1302
1323
  * Skips the first `n` rows of the table, effectively removing them.
1303
1324
  *
1304
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1305
- *
1306
1325
  * @param count - The number of rows to skip from the beginning of the table.
1307
1326
  * @returns The table, so methods can be chained.
1308
1327
  * @category Selecting or Filtering Data
@@ -1338,8 +1357,6 @@ class SimpleTable extends Simple {
1338
1357
  /**
1339
1358
  * Selects random rows from the table, removing all others. You can optionally specify a seed to ensure repeatable sampling.
1340
1359
  *
1341
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1342
- *
1343
1360
  * @param count - The number of rows to select (e.g., `100`) or a percentage string (e.g., `"10%"`) specifying the sampling size.
1344
1361
  * @param options - An optional object with configuration options:
1345
1362
  * @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.
@@ -1371,8 +1388,6 @@ class SimpleTable extends Simple {
1371
1388
  /**
1372
1389
  * 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.
1373
1390
  *
1374
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1375
- *
1376
1391
  * @param count - The number of rows to select.
1377
1392
  * @param options - An optional object with configuration options:
1378
1393
  * @param options.offset - The number of rows to skip from the beginning of the table before selecting. Defaults to `0`.
@@ -1411,8 +1426,6 @@ class SimpleTable extends Simple {
1411
1426
  * Removes duplicate rows from this table, keeping only unique rows.
1412
1427
  * Note that the resulting data order might differ from the original.
1413
1428
  *
1414
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1415
- *
1416
1429
  * @param options - An optional object with configuration options:
1417
1430
  * @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.
1418
1431
  * @returns The table, so methods can be chained.
@@ -1443,7 +1456,6 @@ class SimpleTable extends Simple {
1443
1456
  /**
1444
1457
  * Removes rows with missing values from this table.
1445
1458
  * By default, missing values include SQL `NULL`, as well as string representations like `"NULL"`, `"null"`, `"NaN"`, `"undefined"`, and empty strings `""`.
1446
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1447
1459
  *
1448
1460
  * @param options - An optional object with configuration options:
1449
1461
  * @param options.columns - A string or an array of strings specifying the columns to consider for missing values. If omitted, all columns are considered.
@@ -1481,7 +1493,7 @@ class SimpleTable extends Simple {
1481
1493
  return this;
1482
1494
  }
1483
1495
  /**
1484
- * 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.
1496
+ * Trims specified characters from the beginning, end, or both sides of string values in the given columns.
1485
1497
  *
1486
1498
  * @param columns - The column name or an array of column names to trim.
1487
1499
  * @param options - An optional object with configuration options:
@@ -1514,8 +1526,7 @@ class SimpleTable extends Simple {
1514
1526
  }
1515
1527
  /**
1516
1528
  * Filters rows from this table based on SQL conditions. Note that it's often faster to use the `removeRows` method for simple removals.
1517
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
1518
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1529
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
1519
1530
  *
1520
1531
  * @param conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"column1 > 10 AND column2 = 'value'"`).
1521
1532
  * @returns The table, so methods can be chained.
@@ -1552,8 +1563,6 @@ class SimpleTable extends Simple {
1552
1563
  /**
1553
1564
  * Keeps rows in this table that have specific values in specified columns, removing all other rows.
1554
1565
  *
1555
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1556
- *
1557
1566
  * @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`.
1558
1567
  * @returns The table, so methods can be chained.
1559
1568
  * @category Selecting or Filtering Data
@@ -1583,8 +1592,6 @@ class SimpleTable extends Simple {
1583
1592
  /**
1584
1593
  * Removes rows from this table that have specific values in specified columns.
1585
1594
  *
1586
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1587
- *
1588
1595
  * @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.
1589
1596
  * @returns The table, so methods can be chained.
1590
1597
  * @category Selecting or Filtering Data
@@ -1613,9 +1620,7 @@ class SimpleTable extends Simple {
1613
1620
  }
1614
1621
  /**
1615
1622
  * Removes rows from this table based on SQL conditions. This method is similar to `filter()`, but removes rows instead of keeping them.
1616
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
1617
- *
1618
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1623
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
1619
1624
  *
1620
1625
  * @param conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"fruit = 'apple'"`).
1621
1626
  * @returns The table, so methods can be chained.
@@ -1653,8 +1658,6 @@ class SimpleTable extends Simple {
1653
1658
  * Renames one or more columns in the table. Throws if a source column does
1654
1659
  * not exist, so a typo fails loudly instead of being silently ignored.
1655
1660
  *
1656
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1657
- *
1658
1661
  * @param names - An object mapping old column names to their new column names (e.g., `{ "oldName": "newName", "anotherOld": "anotherNew" }`).
1659
1662
  * @param options - Configuration options.
1660
1663
  * @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.
@@ -1686,8 +1689,6 @@ class SimpleTable extends Simple {
1686
1689
  /**
1687
1690
  * Cleans column names by removing non-alphanumeric characters and formatting them to camel case.
1688
1691
  *
1689
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1690
- *
1691
1692
  * @returns The table, so methods can be chained.
1692
1693
  * @category Column Operations
1693
1694
  *
@@ -1740,8 +1741,6 @@ class SimpleTable extends Simple {
1740
1741
  * | Sales | 2022 | 75 |
1741
1742
  * | Sales | 2023 | 98 |
1742
1743
  *
1743
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1744
- *
1745
1744
  * @param columns - An array of strings representing the names of the columns to be stacked (unpivoted).
1746
1745
  * @param namesTo - The name of the new column that will contain the original column names (e.g., "Year").
1747
1746
  * @param valuesTo - The name of the new column that will contain the values from the stacked columns (e.g., "Employees").
@@ -1783,8 +1782,6 @@ class SimpleTable extends Simple {
1783
1782
  *
1784
1783
  * When multiple rows share the same `namesFrom`/grouping combination, their `valuesFrom` values are combined with the `options.stat` function (`"sum"` by default).
1785
1784
  *
1786
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1787
- *
1788
1785
  * @param namesFrom - The name of the column containing the values that will be transformed into new column headers (e.g., "Year").
1789
1786
  * @param valuesFrom - The name of the column containing the values to be spread across the new columns (e.g., "Employees").
1790
1787
  * @param options - An optional object with configuration options:
@@ -1809,9 +1806,7 @@ class SimpleTable extends Simple {
1809
1806
  *
1810
1807
  * When converting strings to numbers, commas (often used as thousand separators) will be automatically removed before conversion.
1811
1808
  *
1812
- * 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.
1813
- *
1814
- * @param types - An object mapping column names to their target data types for conversion.
1809
+ * @param types - An object mapping column names to their target data types for conversion, including JSON, FLOAT[n] vectors, and GEOMETRY with a CRS.
1815
1810
  * @param options - An optional object with configuration options:
1816
1811
  * @param options.strict - If `false`, values that cannot be converted will be replaced by `NULL` instead of throwing an error. Defaults to `true`.
1817
1812
  * @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).
@@ -1858,6 +1853,18 @@ class SimpleTable extends Simple {
1858
1853
  * // Convert 'amount' to float, replacing unconvertible values with NULL
1859
1854
  * await table.convert({ amount: "float" }, { strict: false }).log();
1860
1855
  * ```
1856
+ *
1857
+ * @example
1858
+ * ```ts
1859
+ * // Parse JSON, a fixed-size float vector, and WKT geometry from text.
1860
+ * await table.loadArray([{
1861
+ * details: '{"count":3}',
1862
+ * embedding: "[0.25,0.5,0.75]",
1863
+ * geom: "POINT (-73 45)",
1864
+ * }])
1865
+ * .convert({ details: "JSON", embedding: "FLOAT[3]", geom: "GEOMETRY('EPSG:4326')" })
1866
+ * .log();
1867
+ * ```
1861
1868
  */
1862
1869
  convert(types, options = {}) {
1863
1870
  convert(this, types, options);
@@ -1880,7 +1887,7 @@ class SimpleTable extends Simple {
1880
1887
  return this;
1881
1888
  }
1882
1889
  /**
1883
- * 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.
1890
+ * Removes one or more columns from this table.
1884
1891
  *
1885
1892
  * @param columns - The name or an array of names of the columns to be removed.
1886
1893
  * @returns The table, so methods can be chained.
@@ -1903,10 +1910,11 @@ class SimpleTable extends Simple {
1903
1910
  return this;
1904
1911
  }
1905
1912
  /**
1906
- * 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.
1913
+ * Adds a new column to the table based on a specified data type (JavaScript or SQL types) and a SQL definition.
1914
+ * With the default `SimpleDB.expressionSyntax: "js"`, expressions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
1907
1915
  *
1908
1916
  * @param newColumn - The name of the new column to be added.
1909
- * @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"`).
1917
+ * @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')"`).
1910
1918
  * @param definition - A SQL expression defining how the values for the new column should be computed (e.g., `"column1 + column2"`, `"ST_Centroid(geom_column)"`).
1911
1919
  * @returns The table, so methods can be chained.
1912
1920
  * @category Column Operations
@@ -1922,6 +1930,25 @@ class SimpleTable extends Simple {
1922
1930
  * // Add a new geometry column 'centroid' using the centroid of an existing 'country' geometry column
1923
1931
  * await table.addColumn("centroid", "geometry('EPSG:4326')", `ST_Centroid("country")`).log();
1924
1932
  * ```
1933
+ *
1934
+ * @example
1935
+ * ```ts
1936
+ * // Read a number from a JSON object into a new column using dot notation.
1937
+ * await table.loadArray([{ details: { count: 3 } }], {
1938
+ * columnTypes: { details: "JSON" },
1939
+ * })
1940
+ * .addColumn("count", "integer", "details.count")
1941
+ * .log();
1942
+ * ```
1943
+ *
1944
+ * @example
1945
+ * ```ts
1946
+ * // Create JSON and fixed-size vector columns with DuckDB expressions.
1947
+ * await table.loadArray([{ count: 3 }])
1948
+ * .addColumn("details", "JSON", "json_object('count', count)")
1949
+ * .addColumn("embedding", "FLOAT[3]", "[0.25, 0.5, 0.75]")
1950
+ * .log();
1951
+ * ```
1925
1952
  */
1926
1953
  addColumn(newColumn, type, definition) {
1927
1954
  addColumn(this, newColumn, type, definition);
@@ -1941,9 +1968,6 @@ class SimpleTable extends Simple {
1941
1968
  * values produce `NULL` extracted values. Parts extracted from
1942
1969
  * `TIMESTAMP WITH TIME ZONE` values use UTC.
1943
1970
  *
1944
- * This method queues the operation; it runs when an async observer method
1945
- * (like `getData()` or `log()`) is awaited, or when `run()` is called.
1946
- *
1947
1971
  * @param column - The temporal column from which to extract components.
1948
1972
  * @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.
1949
1973
  * @returns The table, so methods can be chained.
@@ -1971,8 +1995,6 @@ class SimpleTable extends Simple {
1971
1995
  /**
1972
1996
  * Adds a new column to the table containing the row number, starting at 0 (like an index).
1973
1997
  *
1974
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
1975
- *
1976
1998
  * @param newColumn - The name of the new column that will store the row number.
1977
1999
  * @param options - An optional object with configuration options:
1978
2000
  * @param options.by - A column name or an array of column names to partition by. The row number restarts at 0 within each group.
@@ -1999,8 +2021,6 @@ class SimpleTable extends Simple {
1999
2021
  * 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.
2000
2022
  * This means that if the left table has `n` rows and the right table has `m` rows, the result will have `n * m` rows.
2001
2023
  *
2002
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2003
- *
2004
2024
  * @param rightTable - The SimpleTable instance to cross join with.
2005
2025
  * @param options - An optional object with configuration options:
2006
2026
  * @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`.
@@ -2032,7 +2052,6 @@ class SimpleTable extends Simple {
2032
2052
  * Merges the data of this table (considered the left table) with another table (the right table) based on a common column or multiple columns.
2033
2053
  * Note that the order of rows in the returned data is not guaranteed to be the same as in the original tables.
2034
2054
  * This operation might create temporary files in a `.tmp` folder; consider adding `.tmp` to your `.gitignore`.
2035
- * 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.
2036
2055
  *
2037
2056
  * @param rightTable - The SimpleTable instance to be joined with this table.
2038
2057
  * @param options - An optional object with configuration options:
@@ -2080,8 +2099,6 @@ class SimpleTable extends Simple {
2080
2099
  *
2081
2100
  * This operation might create temporary files in a `.tmp` folder; consider adding `.tmp` to your `.gitignore`.
2082
2101
  *
2083
- * 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.
2084
- *
2085
2102
  * @param rightTable - The SimpleTable instance to be joined with this table.
2086
2103
  * @param leftColumn - The name of the column in this (left) table containing the text to compare.
2087
2104
  * @param rightColumn - The name of the column in the right table containing the text to compare.
@@ -2148,8 +2165,6 @@ class SimpleTable extends Simple {
2148
2165
  * Similarity is computed using the [rapidfuzz](https://query.farm/duckdb_extension_rapidfuzz) DuckDB community extension,
2149
2166
  * which is installed and loaded automatically.
2150
2167
  *
2151
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2152
- *
2153
2168
  * @param column - The name of the column containing the strings to normalize.
2154
2169
  * @param newColumn - The name of the column to write the normalized values to. Use the same name as `column` to normalize in-place.
2155
2170
  * @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.
@@ -2203,8 +2218,6 @@ class SimpleTable extends Simple {
2203
2218
  /**
2204
2219
  * Replaces specified strings in the selected columns.
2205
2220
  *
2206
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2207
- *
2208
2221
  * @param columns - The column name, an array of column names, or `"all"` to apply the replacement to every column in the table.
2209
2222
  * @param replacements - An object mapping old strings to new strings (e.g., `{ "oldValue": "newValue" }`).
2210
2223
  * @param options - An optional object with configuration options:
@@ -2248,7 +2261,7 @@ class SimpleTable extends Simple {
2248
2261
  return this;
2249
2262
  }
2250
2263
  /**
2251
- * 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.
2264
+ * Converts string values in the specified columns to lowercase.
2252
2265
  *
2253
2266
  * @param columns - The column name or an array of column names to be converted to lowercase.
2254
2267
  * @returns The table, so methods can be chained.
@@ -2271,7 +2284,7 @@ class SimpleTable extends Simple {
2271
2284
  return this;
2272
2285
  }
2273
2286
  /**
2274
- * 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.
2287
+ * Converts string values in the specified columns to uppercase.
2275
2288
  *
2276
2289
  * @param columns - The column name or an array of column names to be converted to uppercase.
2277
2290
  * @returns The table, so methods can be chained.
@@ -2294,7 +2307,7 @@ class SimpleTable extends Simple {
2294
2307
  return this;
2295
2308
  }
2296
2309
  /**
2297
- * 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.
2310
+ * Capitalizes the first letter of each string in the specified columns and converts the rest of the string to lowercase.
2298
2311
  *
2299
2312
  * @param columns - The column name or an array of column names to be capitalized.
2300
2313
  * @returns The table, so methods can be chained.
@@ -2319,8 +2332,6 @@ class SimpleTable extends Simple {
2319
2332
  /**
2320
2333
  * Truncates string values in a specified column to a maximum number of characters.
2321
2334
  *
2322
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2323
- *
2324
2335
  * @param column - The column name containing strings to be truncated.
2325
2336
  * @param length - The maximum number of characters to keep.
2326
2337
  * @returns The table, so methods can be chained.
@@ -2349,8 +2360,6 @@ class SimpleTable extends Simple {
2349
2360
  * column is of a different type. `null` values remain `null`. If any string
2350
2361
  * already exceeds the target length, an error is thrown (no silent truncation).
2351
2362
  *
2352
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2353
- *
2354
2363
  * @param columns - The column name(s) containing strings to be padded.
2355
2364
  * @param length - The target length of the padded strings.
2356
2365
  * @param options - An optional object with configuration options:
@@ -2390,8 +2399,6 @@ class SimpleTable extends Simple {
2390
2399
  * 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.
2391
2400
  * If the index is out of bounds, an empty string will be returned for that row.
2392
2401
  *
2393
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2394
- *
2395
2402
  * @param column - The name of the column containing the strings to be split.
2396
2403
  * @param separator - The substring to use as a delimiter for splitting the strings.
2397
2404
  * @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.
@@ -2424,8 +2431,6 @@ class SimpleTable extends Simple {
2424
2431
  * 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`).
2425
2432
  * If a row has more parts than the number of new columns, an error will be thrown unless `strict` is set to `false`.
2426
2433
  *
2427
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2428
- *
2429
2434
  * @param column - The name of the column containing the strings to be split.
2430
2435
  * @param separator - The substring to use as a delimiter for splitting the strings.
2431
2436
  * @param newColumns - An array of column names for the extracted parts.
@@ -2461,8 +2466,6 @@ class SimpleTable extends Simple {
2461
2466
  /**
2462
2467
  * Extracts a specific number of characters from the beginning (left side) of string values in the specified column.
2463
2468
  *
2464
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2465
- *
2466
2469
  * @param column - The name of the column containing the strings to be modified.
2467
2470
  * @param count - The number of characters to extract from the left side of each string.
2468
2471
  * @returns The table, so methods can be chained.
@@ -2482,8 +2485,6 @@ class SimpleTable extends Simple {
2482
2485
  /**
2483
2486
  * Extracts a specific number of characters from the end (right side) of string values in the specified column.
2484
2487
  *
2485
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2486
- *
2487
2488
  * @param column - The name of the column containing the strings to be modified.
2488
2489
  * @param count - The number of characters to extract from the right side of each string.
2489
2490
  * @returns The table, so methods can be chained.
@@ -2503,8 +2504,6 @@ class SimpleTable extends Simple {
2503
2504
  /**
2504
2505
  * Replaces `NULL` values in the specified columns with a given value.
2505
2506
  *
2506
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2507
- *
2508
2507
  * @param columns - The column name, an array of column names, or `"all"` to apply the replacement to every column in the table.
2509
2508
  * @param value - The value to replace `NULL` occurrences with.
2510
2509
  * @returns The table, so methods can be chained.
@@ -2541,8 +2540,6 @@ class SimpleTable extends Simple {
2541
2540
  /**
2542
2541
  * Concatenates values from specified columns into a new column.
2543
2542
  *
2544
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2545
- *
2546
2543
  * @param columns - An array of column names whose values will be concatenated.
2547
2544
  * @param newColumn - The name of the new column to store the concatenated values.
2548
2545
  * @param options - An optional object with configuration options:
@@ -2577,8 +2574,6 @@ class SimpleTable extends Simple {
2577
2574
  *
2578
2575
  * If a column value is `NULL`, it will be replaced by `'Unknown'` in the concatenated result.
2579
2576
  *
2580
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2581
- *
2582
2577
  * @param columns - An array of column names whose values will be concatenated with labels.
2583
2578
  * @param newColumn - The name of the new column to create with the concatenated values.
2584
2579
  * @returns The table, so methods can be chained.
@@ -2626,8 +2621,6 @@ class SimpleTable extends Simple {
2626
2621
  *
2627
2622
  * 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.
2628
2623
  *
2629
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2630
- *
2631
2624
  * @param column - The name of the column containing string values to be split and unnested.
2632
2625
  * @param separator - The delimiter string used to split the column values.
2633
2626
  * @returns The table, so methods can be chained.
@@ -2660,8 +2653,6 @@ class SimpleTable extends Simple {
2660
2653
  *
2661
2654
  * 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.
2662
2655
  *
2663
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2664
- *
2665
2656
  * @param column - The name of the column containing the number of times each row should be repeated.
2666
2657
  * @param options - An optional object with configuration options:
2667
2658
  * @param options.index - The name of a new column to store the index of the repeated row (starting at 0).
@@ -2693,8 +2684,6 @@ class SimpleTable extends Simple {
2693
2684
  *
2694
2685
  * 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.
2695
2686
  *
2696
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2697
- *
2698
2687
  * @param column - The name of the column whose values will be aggregated and concatenated.
2699
2688
  * @param separator - The delimiter string used to join the column values.
2700
2689
  * @param by - The column name or an array of column names to group by.
@@ -2727,8 +2716,6 @@ class SimpleTable extends Simple {
2727
2716
  /**
2728
2717
  * Rounds numeric values in specified columns.
2729
2718
  *
2730
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2731
- *
2732
2719
  * @param columns - The column name or an array of column names containing numeric values to be rounded.
2733
2720
  * @param options - An optional integer specifying the number of decimal places, or an object with configuration options:
2734
2721
  * @param options.decimals - The number of decimal places to round to. Defaults to `0` (rounds to the nearest integer).
@@ -2774,8 +2761,6 @@ class SimpleTable extends Simple {
2774
2761
  * Adds independently generated uniform random noise to numeric values in one or more columns.
2775
2762
  * 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.
2776
2763
  *
2777
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2778
- *
2779
2764
  * @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.
2780
2765
  * @param max - The maximum absolute offset, expressed in each column's units. Must be a finite number greater than or equal to `0`.
2781
2766
  * @param options - An optional object with configuration options:
@@ -2803,8 +2788,7 @@ class SimpleTable extends Simple {
2803
2788
  }
2804
2789
  /**
2805
2790
  * Updates values in a specified column using a SQL expression.
2806
- *
2807
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2791
+ * With the default `SimpleDB.expressionSyntax: "js"`, expressions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
2808
2792
  *
2809
2793
  * @param column - The name of the column to be updated.
2810
2794
  * @param definition - The SQL expression used to set the new values in the column (e.g., `"column1 * 2"`, `"UPPER(column_name)"`).
@@ -2828,6 +2812,16 @@ class SimpleTable extends Simple {
2828
2812
  * // Set 'status' to 'active' where 'isActive' is true
2829
2813
  * await table.updateColumn("status", `CASE WHEN isActive THEN 'active' ELSE 'inactive' END`).log();
2830
2814
  * ```
2815
+ *
2816
+ * @example
2817
+ * ```ts
2818
+ * // Update an existing column with a value from a JSON object using dot notation.
2819
+ * await table.loadArray([{ count: 0, details: { count: 3 } }], {
2820
+ * columnTypes: { details: "JSON" },
2821
+ * })
2822
+ * .updateColumn("count", "details.count")
2823
+ * .log();
2824
+ * ```
2831
2825
  */
2832
2826
  updateColumn(column, definition) {
2833
2827
  updateColumn(this, column, definition);
@@ -2836,8 +2830,6 @@ class SimpleTable extends Simple {
2836
2830
  /**
2837
2831
  * Assigns ranks to rows in a new column based on the values of a specified column.
2838
2832
  *
2839
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2840
- *
2841
2833
  * @param column - The column containing the values to be used for ranking.
2842
2834
  * @param newColumn - The name of the new column where the ranks will be stored.
2843
2835
  * @param options - An optional object with configuration options:
@@ -2878,8 +2870,6 @@ class SimpleTable extends Simple {
2878
2870
  /**
2879
2871
  * Assigns quantiles to rows in a new column based on specified column values.
2880
2872
  *
2881
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2882
- *
2883
2873
  * @param column - The column containing values from which quantiles will be assigned.
2884
2874
  * @param count - The number of quantiles to divide the data into (e.g., `4` for quartiles, `10` for deciles).
2885
2875
  * @param newColumn - The name of the new column where the assigned quantiles will be stored.
@@ -2913,8 +2903,6 @@ class SimpleTable extends Simple {
2913
2903
  /**
2914
2904
  * Assigns bins for specified column values based on an interval size.
2915
2905
  *
2916
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2917
- *
2918
2906
  * @param column - The column containing values from which bins will be computed.
2919
2907
  * @param interval - The interval size for binning the values.
2920
2908
  * @param newColumn - The name of the new column where the bins will be stored.
@@ -2990,8 +2978,6 @@ class SimpleTable extends Simple {
2990
2978
  * await table.rowProportions(["Men", "Women", "NonBinary"], { base: 100, decimals: 1 }).log();
2991
2979
  * ```
2992
2980
  *
2993
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
2994
- *
2995
2981
  * @param columns - An array of column names for which proportions will be computed on each row.
2996
2982
  * @param options - An optional object with configuration options:
2997
2983
  * @param options.suffix - A string suffix to append to the names of the new columns storing the computed proportions. Defaults to `"Perc"`.
@@ -3015,9 +3001,6 @@ class SimpleTable extends Simple {
3015
3001
  * option can therefore increase the table's row count. If null values leave
3016
3002
  * a row without the requested rank, the new columns contain null.
3017
3003
  *
3018
- * This method queues the operation; it runs when an async observer method
3019
- * (like `getData()` or `log()`) is awaited, or when `run()` is called.
3020
- *
3021
3004
  * @param columns - The numeric columns to rank within each row.
3022
3005
  * @param options - The output columns and ranking configuration. At least one of `nameColumn` or `valueColumn` is required.
3023
3006
  * @param options.nameColumn - The name of a new column containing the selected source column's name.
@@ -3054,8 +3037,6 @@ class SimpleTable extends Simple {
3054
3037
  /**
3055
3038
  * Computes proportions vertically over a column's values, relative to the sum of all values in that column or group.
3056
3039
  *
3057
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3058
- *
3059
3040
  * @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.
3060
3041
  * @param newColumn - The name of the new column where the proportions will be stored.
3061
3042
  * @param options - An optional object with configuration options:
@@ -3097,8 +3078,6 @@ class SimpleTable extends Simple {
3097
3078
  * Creates a summary table from selected columns, optionally grouped by other columns.
3098
3079
  * This method allows you to aggregate data, calculate statistics (e.g., count, mean, sum), and group results by categorical columns.
3099
3080
  *
3100
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3101
- *
3102
3081
  * @param options - An object with configuration options for summarization:
3103
3082
  * @param options.columns - The column name or an array of column names to summarize. If omitted, only the row count is returned.
3104
3083
  * @param options.by - The column name or an array of column names to group by.
@@ -3197,9 +3176,6 @@ class SimpleTable extends Simple {
3197
3176
  * string is also used as its row label; pass an object to customize that
3198
3177
  * label. If `options.stats` is omitted, every supported stat is added.
3199
3178
  *
3200
- * This method queues the operation; it runs when an async observer method
3201
- * (like `getData()` or `log()`) is awaited, or when `run()` is called.
3202
- *
3203
3179
  * @param columns - The numeric column name, an array of numeric column names, or `"all"` to summarize every numeric column.
3204
3180
  * @param labelColumn - The existing string column in which stat row labels will be written.
3205
3181
  * @param options - An optional object with configuration options:
@@ -3241,8 +3217,6 @@ class SimpleTable extends Simple {
3241
3217
  /**
3242
3218
  * Computes the cumulative sum of values in a column. For this method to work properly, ensure your data is sorted first.
3243
3219
  *
3244
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3245
- *
3246
3220
  * @param column - The name of the column storing the values to be accumulated.
3247
3221
  * @param newColumn - The name of the new column in which the computed cumulative values will be stored.
3248
3222
  * @param options - An optional object with configuration options:
@@ -3279,8 +3253,6 @@ class SimpleTable extends Simple {
3279
3253
  * For rows without enough preceding or following rows to form a complete window, `NULL` will be returned.
3280
3254
  * For this method to work properly, ensure your data is sorted by the relevant column(s) first.
3281
3255
  *
3282
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3283
- *
3284
3256
  * @param column - The name of the column storing the values to be aggregated.
3285
3257
  * @param newColumn - The name of the new column in which the computed rolling values will be stored.
3286
3258
  * @param stat - The aggregation function to apply: `"min"`, `"max"`, `"mean"`, `"median"`, or `"sum"`.
@@ -3319,8 +3291,6 @@ class SimpleTable extends Simple {
3319
3291
  * Calculates correlations between columns. If no `x` and `y` columns are specified, the method computes the correlations for all numeric column combinations.
3320
3292
  * Note that correlation is symmetrical: the correlation of `x` with `y` is the same as `y` with `x`.
3321
3293
  *
3322
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3323
- *
3324
3294
  * @param options - An optional object with configuration options:
3325
3295
  * @param options.x - The name of the column for the x-values. If omitted, correlations will be computed for all numeric columns.
3326
3296
  * @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.
@@ -3368,8 +3338,6 @@ class SimpleTable extends Simple {
3368
3338
  * If no `x` and `y` columns are specified, the method computes linear regression analysis for all numeric column permutations.
3369
3339
  * Note that linear regression analysis is asymmetrical: the linear regression of `x` over `y` is not the same as `y` over `x`.
3370
3340
  *
3371
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3372
- *
3373
3341
  * @param options - An optional object with configuration options:
3374
3342
  * @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.
3375
3343
  * @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.
@@ -3415,8 +3383,6 @@ class SimpleTable extends Simple {
3415
3383
  /**
3416
3384
  * Identifies outliers in a specified column using the Interquartile Range (IQR) method.
3417
3385
  *
3418
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3419
- *
3420
3386
  * @param column - The name of the column in which outliers will be identified.
3421
3387
  * @param newColumn - The name of the new column where the boolean results (`TRUE` for outlier, `FALSE` otherwise) will be stored.
3422
3388
  * @param options - An optional object with configuration options:
@@ -3443,8 +3409,6 @@ class SimpleTable extends Simple {
3443
3409
  /**
3444
3410
  * Computes the Z-score for values in a specified column.
3445
3411
  *
3446
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3447
- *
3448
3412
  * @param column - The name of the column for which Z-scores will be calculated.
3449
3413
  * @param newColumn - The name of the new column where the computed Z-scores will be stored.
3450
3414
  * @param options - An optional object with configuration options:
@@ -3478,8 +3442,6 @@ class SimpleTable extends Simple {
3478
3442
  /**
3479
3443
  * Normalizes the values in a column using min-max normalization.
3480
3444
  *
3481
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3482
- *
3483
3445
  * @param column - The name of the column in which values will be normalized.
3484
3446
  * @param newColumn - The name of the new column where normalized values will be stored.
3485
3447
  * @param options - An optional object with configuration options:
@@ -3524,8 +3486,6 @@ class SimpleTable extends Simple {
3524
3486
  *
3525
3487
  * 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.
3526
3488
  *
3527
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3528
- *
3529
3489
  * @param column - The numeric column containing the values to index.
3530
3490
  * @param newColumn - The name of the new column where indexed values will be stored.
3531
3491
  * @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.
@@ -3583,48 +3543,84 @@ class SimpleTable extends Simple {
3583
3543
  /**
3584
3544
  * 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.
3585
3545
  * This method offers high flexibility for data manipulation but can be slow for large tables as it involves transferring data between DuckDB and JavaScript.
3586
- * This method does not work with tables containing geometries.
3546
+ * Before writing a JavaScript callback, check for an existing SDA method that
3547
+ * performs the same operation; it will usually be faster and more efficient.
3587
3548
  *
3588
- * 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.
3549
+ * If the table has geometry columns, the callback can read and modify their
3550
+ * GeoJSON geometry objects directly. Extra properties added to these objects
3551
+ * are ignored; create new columns on the returned rows to store additional
3552
+ * attributes. All geometry columns must use EPSG:4326; use reproject() first
3553
+ * if needed.
3589
3554
  *
3590
3555
  * @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).
3591
3556
  * @param options - An optional object with configuration options:
3592
- * @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.
3557
+ * @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.
3558
+ * @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.
3593
3559
  * @returns The table, so methods can be chained.
3594
3560
  * @category Updating Data
3595
3561
  *
3596
3562
  * @example
3597
3563
  * ```ts
3598
- * // Extract hostnames with JavaScript's URL parser.
3599
- * const table = await sdb
3600
- * .newTable()
3601
- * .loadData("websites.csv")
3602
- * .updateWithJS((rows) => {
3603
- * return rows.map((row) => ({
3604
- * ...row,
3605
- * hostname: typeof row.url === "string"
3606
- * ? new URL(row.url).hostname
3607
- * : null,
3608
- * }));
3609
- * })
3564
+ * // Double the value in each row with a JavaScript callback.
3565
+ * await table.loadArray([{ value: 1 }, { value: 2 }])
3566
+ * .updateWithJS((rows) => rows.map((row) => ({
3567
+ * value: Number(row.value) * 2,
3568
+ * })))
3610
3569
  * .log();
3611
3570
  * ```
3612
3571
  *
3613
3572
  * @example
3614
3573
  * ```ts
3615
- * // Enrich reviews with scores from an external service, 100 at a time.
3616
- * const reviews = await table
3617
- * .updateWithJS(async (rows) => {
3618
- * const response = await fetch("https://api.example.com/score", {
3619
- * method: "POST",
3620
- * headers: { "content-type": "application/json" },
3621
- * body: JSON.stringify(rows.map((row) => row.review)),
3622
- * });
3623
- * const scores = await response.json() as number[];
3624
- * return rows.map((row, index) => ({ ...row, score: scores[index] }));
3625
- * }, { batchSize: 100 })
3574
+ * // Process two rows per callback to limit how many rows are handled at once.
3575
+ * await table.loadArray([{ value: 1 }, { value: 2 }, { value: 3 }])
3576
+ * .updateWithJS((rows) => rows.map((row) => ({
3577
+ * value: Number(row.value) * 2,
3578
+ * })), { batchSize: 2 })
3626
3579
  * .log();
3627
3580
  * ```
3581
+ *
3582
+ * @example
3583
+ * ```ts
3584
+ * // Add a JSON object column to keep related attributes together.
3585
+ * await table.loadArray([{ name: "Station" }])
3586
+ * .updateWithJS((rows) => rows.map((row) => ({
3587
+ * ...row, details: { active: true, category: "weather" },
3588
+ * })), { columnTypes: { details: "JSON" } })
3589
+ * .log();
3590
+ * ```
3591
+ *
3592
+ * @example
3593
+ * ```ts
3594
+ * // Add a three-element float vector, such as an embedding.
3595
+ * await table.loadArray([{ name: "Station" }])
3596
+ * .updateWithJS((rows) => rows.map((row) => ({
3597
+ * ...row, embedding: [0.25, 0.5, 0.75],
3598
+ * })), { columnTypes: { embedding: "FLOAT[3]" } })
3599
+ * .log();
3600
+ * ```
3601
+ *
3602
+ * @example
3603
+ * ```ts
3604
+ * // Move each point slightly east by editing its longitude.
3605
+ * await sdb.newTable().loadArray([{
3606
+ * geom: { type: "Point", coordinates: [-73, 45] },
3607
+ * }], { columnTypes: { geom: "GEOMETRY('EPSG:4326')" } })
3608
+ * .updateWithJS((rows) => rows.map((row) => {
3609
+ * // This example loads only Points. Narrow the type for coordinate access.
3610
+ * const geom = row.geom as { type: "Point"; coordinates: number[] } | null;
3611
+ * if (geom !== null) geom.coordinates[0] += 0.01;
3612
+ * return row;
3613
+ * })).log();
3614
+ * ```
3615
+ *
3616
+ * @example
3617
+ * ```ts
3618
+ * // Create a geometry column from longitude and latitude values.
3619
+ * await sdb.newTable().loadArray([{ longitude: -73, latitude: 45 }])
3620
+ * .updateWithJS((rows) => rows.map((row) => ({
3621
+ * ...row, geom: { type: "Point", coordinates: [row.longitude, row.latitude] },
3622
+ * })), { columnTypes: { geom: "GEOMETRY('EPSG:4326')" } }).log();
3623
+ * ```
3628
3624
  */
3629
3625
  updateWithJS(dataModifier, options = {}) {
3630
3626
  updateWithJS(this, dataModifier, options);
@@ -3705,8 +3701,6 @@ class SimpleTable extends Simple {
3705
3701
  * Produces identical output to `journalism-format`'s `normalizeString()` function
3706
3702
  * for all common cases including accented Latin characters.
3707
3703
  *
3708
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3709
- *
3710
3704
  * @param column The column containing the text to normalize
3711
3705
  * @param newColumn The column to store the normalized results
3712
3706
  * @param options Configuration options
@@ -3757,8 +3751,6 @@ class SimpleTable extends Simple {
3757
3751
  * 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.
3758
3752
  * `NULL` input values produce `NULL` counts.
3759
3753
  *
3760
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3761
- *
3762
3754
  * @param column - The name of the column containing the strings to count.
3763
3755
  * @param newColumn - The name of the new column where the character counts will be stored.
3764
3756
  * @returns The table, so methods can be chained.
@@ -3778,8 +3770,6 @@ class SimpleTable extends Simple {
3778
3770
  * Adds a new column containing the word count for each string in the specified column.
3779
3771
  * 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.
3780
3772
  *
3781
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
3782
- *
3783
3773
  * @param column - The name of the column containing the strings to count.
3784
3774
  * @param newColumn - The name of the new column where the word counts will be stored.
3785
3775
  * @returns The table, so methods can be chained.
@@ -3815,6 +3805,7 @@ class SimpleTable extends Simple {
3815
3805
  }
3816
3806
  /**
3817
3807
  * Returns the number of rows in the table.
3808
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
3818
3809
  *
3819
3810
  * @param options - An optional object with configuration options:
3820
3811
  * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Book'"`).
@@ -4155,7 +4146,7 @@ class SimpleTable extends Simple {
4155
4146
  }
4156
4147
  /**
4157
4148
  * Returns the first row of the table, optionally filtered by SQL conditions.
4158
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4149
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4159
4150
  * Temporal values use the same JavaScript representations as `getData()`.
4160
4151
  *
4161
4152
  * @param options - An optional object with configuration options:
@@ -4182,7 +4173,7 @@ class SimpleTable extends Simple {
4182
4173
  }
4183
4174
  /**
4184
4175
  * Returns the last row of the table, optionally filtered by SQL conditions.
4185
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4176
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4186
4177
  * Temporal values use the same JavaScript representations as `getData()`.
4187
4178
  *
4188
4179
  * @param options - An optional object with configuration options:
@@ -4209,7 +4200,7 @@ class SimpleTable extends Simple {
4209
4200
  }
4210
4201
  /**
4211
4202
  * Returns the top `n` rows of the table, optionally filtered by SQL conditions.
4212
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4203
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4213
4204
  * Temporal values use the same JavaScript representations as `getData()`.
4214
4205
  *
4215
4206
  * @param count - The number of rows to return from the top of the table.
@@ -4238,7 +4229,7 @@ class SimpleTable extends Simple {
4238
4229
  /**
4239
4230
  * Returns the bottom `n` rows of the table, optionally filtered by SQL conditions.
4240
4231
  * By default, the last row will be returned first. To preserve the original order, use the `originalOrder` option.
4241
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4232
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4242
4233
  * Temporal values use the same JavaScript representations as `getData()`.
4243
4234
  *
4244
4235
  * @param count - The number of rows to return from the bottom of the table.
@@ -4274,7 +4265,7 @@ class SimpleTable extends Simple {
4274
4265
  }
4275
4266
  /**
4276
4267
  * 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.
4277
- * You can also use JavaScript syntax for conditions (e.g., `AND`, `||`, `===`, `!==`).
4268
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4278
4269
  * Temporal values use the same JavaScript representations as `getData()`.
4279
4270
  *
4280
4271
  * @param conditions - The conditions to match, specified as a SQL `WHERE` clause.
@@ -4319,13 +4310,26 @@ class SimpleTable extends Simple {
4319
4310
  }
4320
4311
  /**
4321
4312
  * Returns the data from the table as an array of objects, optionally filtered by SQL conditions.
4322
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4313
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4323
4314
  *
4324
4315
  * Top-level DuckDB `DATE` and `TIMESTAMP` columns are returned as JavaScript
4325
4316
  * `Date` objects interpreted in UTC. `TIMESTAMP WITH TIME ZONE` values are
4326
4317
  * returned as UTC strings, preserving DuckDB's microsecond precision;
4327
4318
  * JavaScript `Date` supports only milliseconds.
4328
4319
  *
4320
+ * Top-level `BIGINT`, `UBIGINT`, `HUGEINT`, and `UHUGEINT` columns are
4321
+ * returned as JavaScript numbers. Values outside `Number.MIN_SAFE_INTEGER`
4322
+ * through `Number.MAX_SAFE_INTEGER` throw instead of losing precision.
4323
+ * Use `convert({ columnName: "string" })` before `getData()` to retrieve
4324
+ * their exact digits as strings.
4325
+ *
4326
+ * SQL arrays and lists, including float vectors, return their actual elements
4327
+ * as JavaScript arrays. Null cells and null elements remain null.
4328
+ *
4329
+ * Nested SQL lists and structs become JavaScript arrays and objects. Within
4330
+ * them, `BIGINT`, `UBIGINT`, `HUGEINT`, `UHUGEINT`, and `DECIMAL` values remain
4331
+ * strings to preserve precision, even for small integers.
4332
+ *
4329
4333
  * @param options - An optional object with configuration options:
4330
4334
  * @param options.columns - An array of column names to include in the result. If omitted, all columns will be included.
4331
4335
  * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Book'"`).
@@ -4359,6 +4363,18 @@ class SimpleTable extends Simple {
4359
4363
  * // Return at most two rows.
4360
4364
  * const preview = await table.getData({ limit: 2 });
4361
4365
  * ```
4366
+ *
4367
+ * @example
4368
+ * ```ts
4369
+ * // Read nested integers without losing digits. SQL creates the nested types.
4370
+ * await sdb.customQuery(`CREATE TABLE nested_example AS SELECT
4371
+ * [42::BIGINT, 9007199254740993::BIGINT] AS ids,
4372
+ * {'count': 2::INTEGER, 'amount': 123.450::DECIMAL(6,3)} AS details`);
4373
+ * const nested = sdb.newTable("nested_example");
4374
+ * const rows = await nested.getData();
4375
+ * // [{ ids: ["42", "9007199254740993"], details: { count: 2, amount: "123.450" } }]
4376
+ * await nested.log();
4377
+ * ```
4362
4378
  */
4363
4379
  async getData(options = {}) {
4364
4380
  return await getData(this, options);
@@ -4367,6 +4383,7 @@ class SimpleTable extends Simple {
4367
4383
  * Streams the table rows one by one as an async iterator, without
4368
4384
  * materializing the whole table in memory. Values are converted to
4369
4385
  * JavaScript types the same way as `getData()`.
4386
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4370
4387
  *
4371
4388
  * The underlying DuckDB result is streamed chunk by chunk, so tables
4372
4389
  * larger than the available memory can be iterated. Avoid running other
@@ -4399,7 +4416,7 @@ class SimpleTable extends Simple {
4399
4416
  }
4400
4417
  /**
4401
4418
  * Returns the data from the table as a CSV string, optionally filtered by SQL conditions.
4402
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4419
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
4403
4420
  * Temporal values are first converted as they are in `getData()`, then
4404
4421
  * serialized using UTC date and timestamp text.
4405
4422
  *
@@ -4438,8 +4455,6 @@ class SimpleTable extends Simple {
4438
4455
  /**
4439
4456
  * Creates point geometries from latitude (y) and longitude (x) columns.
4440
4457
  *
4441
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4442
- *
4443
4458
  * @param latColumn - The name of the column storing the latitude (y-coordinate) values.
4444
4459
  * @param lonColumn - The name of the column storing the longitude (x-coordinate) values.
4445
4460
  * @param newColumn - The name of the new column where the point geometries will be stored.
@@ -4469,8 +4484,6 @@ class SimpleTable extends Simple {
4469
4484
  /**
4470
4485
  * Adds a column with boolean values indicating the validity of geometries.
4471
4486
  *
4472
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4473
- *
4474
4487
  * @param newColumn - The name of the new column where the boolean results (`TRUE` for valid, `FALSE` for invalid) will be stored.
4475
4488
  * @param options - An optional object with configuration options:
4476
4489
  * @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.
@@ -4497,8 +4510,6 @@ class SimpleTable extends Simple {
4497
4510
  /**
4498
4511
  * Adds a column with the number of vertices (points) in each geometry.
4499
4512
  *
4500
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4501
- *
4502
4513
  * @param newColumn - The name of the new column where the vertex counts will be stored.
4503
4514
  * @param options - An optional object with configuration options:
4504
4515
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4525,8 +4536,6 @@ class SimpleTable extends Simple {
4525
4536
  /**
4526
4537
  * Attempts to make invalid geometries valid without removing any vertices.
4527
4538
  *
4528
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4529
- *
4530
4539
  * @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.
4531
4540
  * @returns The table, so methods can be chained.
4532
4541
  * @category Geospatial
@@ -4550,8 +4559,6 @@ class SimpleTable extends Simple {
4550
4559
  /**
4551
4560
  * Adds a column with boolean values indicating whether geometries are closed (e.g., polygons) or open (e.g., linestrings).
4552
4561
  *
4553
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4554
- *
4555
4562
  * @param newColumn - The name of the new column where the boolean results (`TRUE` for closed, `FALSE` for open) will be stored.
4556
4563
  * @param options - An optional object with configuration options:
4557
4564
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4577,8 +4584,6 @@ class SimpleTable extends Simple {
4577
4584
  /**
4578
4585
  * Adds a column with the geometry type (e.g., `"POINT"`, `"LINESTRING"`, `"POLYGON"`) for each geometry.
4579
4586
  *
4580
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4581
- *
4582
4587
  * @param newColumn - The name of the new column where the geometry types will be stored.
4583
4588
  * @param options - An optional object with configuration options:
4584
4589
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4605,8 +4610,6 @@ class SimpleTable extends Simple {
4605
4610
  * 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).
4606
4611
  * **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.
4607
4612
  *
4608
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4609
- *
4610
4613
  * @param column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
4611
4614
  * @returns The table, so methods can be chained.
4612
4615
  * @category Geospatial
@@ -4632,7 +4635,7 @@ class SimpleTable extends Simple {
4632
4635
  *
4633
4636
  * 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.
4634
4637
  *
4635
- * 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.
4638
+ * This method supports only `POINT` geometries in `EPSG:4326`. Null and empty geometries are preserved.
4636
4639
  *
4637
4640
  * @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.
4638
4641
  * @param options - An optional object with configuration options:
@@ -4665,8 +4668,6 @@ class SimpleTable extends Simple {
4665
4668
  /**
4666
4669
  * Reduces the precision of geometries in a specified column to a given number of decimal places.
4667
4670
  *
4668
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4669
- *
4670
4671
  * @param decimals - The number of decimal places to keep in the coordinates of the geometries.
4671
4672
  * @param options - An optional object with configuration options:
4672
4673
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4692,8 +4693,6 @@ class SimpleTable extends Simple {
4692
4693
  /**
4693
4694
  * Reprojects the geometries in a specified column to another Spatial Reference System (SRS).
4694
4695
  *
4695
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4696
- *
4697
4696
  * @param crs - The target SRS (e.g., `"EPSG:3347"`, or `"EPSG:4326"` for EPSG:4326 (WGS84)).
4698
4697
  * @param options - An optional object with configuration options:
4699
4698
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -4720,8 +4719,6 @@ class SimpleTable extends Simple {
4720
4719
  * Computes the area of geometries in square meters (`"m2"`) or optionally square kilometers (`"km2"`).
4721
4720
  * The input geometry is assumed to be in EPSG:4326 (WGS84).
4722
4721
  *
4723
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4724
- *
4725
4722
  * @param newColumn - The name of the new column where the computed areas will be stored.
4726
4723
  * @param options - An optional object with configuration options:
4727
4724
  * @param options.unit - The unit for the computed area: `"m2"` (square meters) or `"km2"` (square kilometers). Defaults to `"m2"`.
@@ -4762,8 +4759,6 @@ class SimpleTable extends Simple {
4762
4759
  * Computes the length of line geometries in meters (`"m"`) or optionally kilometers (`"km"`).
4763
4760
  * The input geometry is assumed to be in EPSG:4326 (WGS84).
4764
4761
  *
4765
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4766
- *
4767
4762
  * @param newColumn - The name of the new column where the computed lengths will be stored.
4768
4763
  * @param options - An optional object with configuration options:
4769
4764
  * @param options.unit - The unit for the computed length: `"m"` (meters) or `"km"` (kilometers). Defaults to `"m"`.
@@ -4804,8 +4799,6 @@ class SimpleTable extends Simple {
4804
4799
  * Computes the perimeter of polygon geometries in meters (`"m"`) or optionally kilometers (`"km"`).
4805
4800
  * The input geometry is assumed to be in EPSG:4326 (WGS84).
4806
4801
  *
4807
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4808
- *
4809
4802
  * @param newColumn - The name of the new column where the computed perimeters will be stored.
4810
4803
  * @param options - An optional object with configuration options:
4811
4804
  * @param options.unit - The unit for the computed perimeter: `"m"` (meters) or `"km"` (kilometers). Defaults to `"m"`.
@@ -4846,8 +4839,6 @@ class SimpleTable extends Simple {
4846
4839
  * Computes a buffer (a polygon representing a specified distance around a geometry) for geometries in a specified column.
4847
4840
  * The distance is in the Spatial Reference System (SRS) unit of the input geometries.
4848
4841
  *
4849
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4850
- *
4851
4842
  * @param newColumn - The name of the new column where the buffered geometries will be stored.
4852
4843
  * @param distance - The distance for the buffer. This value is in the units of the geometry's SRS.
4853
4844
  * @param options - An optional object with configuration options:
@@ -4875,7 +4866,6 @@ class SimpleTable extends Simple {
4875
4866
  * Merges the data of this table (considered the left table) with another table (the right table) based on a spatial relationship.
4876
4867
  * Note that the order of rows in the returned data is not guaranteed to be the same as in the original tables.
4877
4868
  * This operation might create temporary files in a `.tmp` folder; consider adding `.tmp` to your `.gitignore`.
4878
- * 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.
4879
4869
  *
4880
4870
  * @param rightTable - The SimpleTable instance to be joined with this table.
4881
4871
  * @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).
@@ -4947,8 +4937,6 @@ class SimpleTable extends Simple {
4947
4937
  /**
4948
4938
  * Computes the intersection of two sets of geometries, creating new geometries where they overlap.
4949
4939
  *
4950
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4951
- *
4952
4940
  * @param column1 - The name of the first column storing geometries.
4953
4941
  * @param column2 - The name of the second column storing geometries. Both columns must have the same projection.
4954
4942
  * @param newColumn - The name of the new column where the computed intersection geometries will be stored.
@@ -4968,8 +4956,6 @@ class SimpleTable extends Simple {
4968
4956
  /**
4969
4957
  * Computes the geometric difference between two geometries, returning the portion of the first geometry that does not intersect the second.
4970
4958
  *
4971
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4972
- *
4973
4959
  * @param column1 - The name of the column storing the geometries from which the second geometries will be subtracted.
4974
4960
  * @param column2 - The name of the column storing the geometries to subtract. Both columns must have the same projection.
4975
4961
  * @param newColumn - The name of the new column where the geometric differences will be stored.
@@ -4989,8 +4975,6 @@ class SimpleTable extends Simple {
4989
4975
  /**
4990
4976
  * Fills holes in polygon geometries.
4991
4977
  *
4992
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
4993
- *
4994
4978
  * @param column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
4995
4979
  * @returns The table, so methods can be chained.
4996
4980
  * @category Geospatial
@@ -5014,8 +4998,6 @@ class SimpleTable extends Simple {
5014
4998
  /**
5015
4999
  * Returns `TRUE` if two geometries intersect (overlap in any way), and `FALSE` otherwise.
5016
5000
  *
5017
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5018
- *
5019
5001
  * @param column1 - The name of the first column storing geometries.
5020
5002
  * @param column2 - The name of the second column storing geometries. Both columns must have the same projection.
5021
5003
  * @param newColumn - The name of the new column where the boolean results (`TRUE` for intersection, `FALSE` otherwise) will be stored.
@@ -5035,8 +5017,6 @@ class SimpleTable extends Simple {
5035
5017
  /**
5036
5018
  * Returns `TRUE` if every point of a geometry in `column` is covered by a geometry in `containerColumn`, including their boundaries, and `FALSE` otherwise.
5037
5019
  *
5038
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5039
- *
5040
5020
  * @param column - The name of the column storing the geometries to be tested for containment.
5041
5021
  * @param containerColumn - The name of the column storing the geometries to be tested as containers. Both columns must have the same projection.
5042
5022
  * @param newColumn - The name of the new column where the boolean results (`TRUE` when covered, `FALSE` otherwise) will be stored.
@@ -5056,8 +5036,6 @@ class SimpleTable extends Simple {
5056
5036
  /**
5057
5037
  * Computes the union of two geometries, creating a new geometry that represents the merged area of both.
5058
5038
  *
5059
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5060
- *
5061
5039
  * @param column1 - The name of the first column storing geometries.
5062
5040
  * @param column2 - The name of the second column storing geometries. Both columns must have the same projection.
5063
5041
  * @param newColumn - The name of the new column where the computed union geometries will be stored.
@@ -5078,8 +5056,6 @@ class SimpleTable extends Simple {
5078
5056
  * Extracts the latitude (y) and longitude (x) coordinates from point geometries.
5079
5057
  * The input geometry is assumed to be in EPSG:4326 (WGS84).
5080
5058
  *
5081
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5082
- *
5083
5059
  * @param column - The name of the column storing the point geometries.
5084
5060
  * @param latColumn - The name of the new column where the extracted latitude (y-coordinate) values will be stored.
5085
5061
  * @param lonColumn - The name of the new column where the extracted longitude (x-coordinate) values will be stored.
@@ -5099,8 +5075,6 @@ class SimpleTable extends Simple {
5099
5075
  /**
5100
5076
  * Simplifies geometries while preserving their overall coverage. A higher tolerance results in more significant simplification.
5101
5077
  *
5102
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5103
- *
5104
5078
  * @param tolerance - A numeric value representing the simplification tolerance. A higher value leads to greater simplification.
5105
5079
  * @param options - An optional object with configuration options:
5106
5080
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -5128,8 +5102,6 @@ class SimpleTable extends Simple {
5128
5102
  * Computes the centroid of geometries.
5129
5103
  * The values are returned in the SRS unit of the input geometries.
5130
5104
  *
5131
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5132
- *
5133
5105
  * @param newColumn - The name of the new column where the computed centroid geometries will be stored.
5134
5106
  * @param options - An optional object with configuration options:
5135
5107
  * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -5155,8 +5127,6 @@ class SimpleTable extends Simple {
5155
5127
  /**
5156
5128
  * Generates a random point within the geometries of a specified column.
5157
5129
  *
5158
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5159
- *
5160
5130
  * @param newColumn - The name of the new column where the random points will be stored.
5161
5131
  * @param tries - The number of points to generate within the bounding box of each geometry to find one that is within the geometry itself.
5162
5132
  * @param options - An optional object with configuration options:
@@ -5191,8 +5161,6 @@ class SimpleTable extends Simple {
5191
5161
  * You can optionally specify `"spheroid"` or `"haversine"` methods to get results in meters or kilometers.
5192
5162
  * If using `"spheroid"` or `"haversine"`, the input geometries must be in EPSG:4326 (WGS84).
5193
5163
  *
5194
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5195
- *
5196
5164
  * @param column1 - The name of the first column storing geometries.
5197
5165
  * @param column2 - The name of the second column storing geometries.
5198
5166
  * @param newColumn - The name of the new column where the computed distances will be stored.
@@ -5237,8 +5205,6 @@ class SimpleTable extends Simple {
5237
5205
  /**
5238
5206
  * Unnests geometries recursively, transforming multi-part geometries (e.g., MultiPolygon) into individual single-part geometries (e.g., Polygon).
5239
5207
  *
5240
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5241
- *
5242
5208
  * @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.
5243
5209
  * @returns The table, so methods can be chained.
5244
5210
  * @category Geospatial
@@ -5262,8 +5228,6 @@ class SimpleTable extends Simple {
5262
5228
  /**
5263
5229
  * Adds the bounding box coordinates of geometries in a specified column as four new columns: `minLon`, `minLat`, `maxLon`, and `maxLat`.
5264
5230
  *
5265
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5266
- *
5267
5231
  * @param options - An optional object with configuration options:
5268
5232
  * @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.
5269
5233
  * @param options.decimals - The number of decimal places to round the bounding box coordinates. Defaults to `undefined` (no rounding).
@@ -5291,8 +5255,6 @@ class SimpleTable extends Simple {
5291
5255
  /**
5292
5256
  * Aggregates geometries in a specified column based on a chosen aggregation method.
5293
5257
  *
5294
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5295
- *
5296
5258
  * @param method - The aggregation method to apply: `"union"` (combines all geometries into a single multi-geometry) or `"intersection"` (computes the intersection of all geometries).
5297
5259
  * @param options - An optional object with configuration options:
5298
5260
  * @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.
@@ -5325,8 +5287,6 @@ class SimpleTable extends Simple {
5325
5287
  /**
5326
5288
  * Transforms closed linestring geometries into polygon geometries.
5327
5289
  *
5328
- * This method queues the operation; it runs when an async observer method (like `getData()` or `log()`) is awaited, or when `run()` is called.
5329
- *
5330
5290
  * @param column - The name of the column storing the linestring geometries. If omitted, the method will automatically attempt to find a geometry column.
5331
5291
  * @returns The table, so methods can be chained.
5332
5292
  * @category Geospatial
@@ -5373,7 +5333,9 @@ class SimpleTable extends Simple {
5373
5333
  return await getBoundingBox(this, column);
5374
5334
  }
5375
5335
  /**
5376
- * Returns the table's geospatial data as a GeoJSON object.
5336
+ * Returns the table's geospatial data as a GeoJSON FeatureCollection.
5337
+ * Each row becomes a Feature: the selected geometry column becomes its geometry,
5338
+ * and the remaining columns become its properties.
5377
5339
  * If the table has multiple geometry columns, you must specify which one to use.
5378
5340
  *
5379
5341
  * @param column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
@@ -5411,12 +5373,13 @@ class SimpleTable extends Simple {
5411
5373
  }
5412
5374
  /**
5413
5375
  * Writes the table's data to a file in various formats (CSV, JSON, Parquet, DuckDB, SQLite).
5376
+ * Tables with geometry columns must use `writeGeoData()` instead.
5414
5377
  * If the specified path does not exist, it will be created.
5415
5378
  *
5416
5379
  * @param file - The absolute path to the output file (e.g., `"./output.csv"`, `"./output.json"`).
5417
5380
  * @param options - An optional object with configuration options:
5418
5381
  * @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`.
5419
- * @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.
5382
+ * @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.
5420
5383
  * @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`.
5421
5384
  * @returns A promise that resolves to the table, so methods can be chained.
5422
5385
  * @category File Operations
@@ -5517,28 +5480,28 @@ class SimpleTable extends Simple {
5517
5480
  * Caches the results of computations in `./.sda-cache`.
5518
5481
  * You should add `./.sda-cache` to your `.gitignore` file.
5519
5482
  *
5520
- * Cache entries are stored as DuckDB database files. Full-text search (FTS)
5521
- * indexes are persisted in the cache file and restored directly on a cache
5522
- * hit. Vector similarity search (VSS/HNSW) indexes are not persisted in the
5523
- * cache file; their definitions are stored as metadata and used to rebuild
5524
- * the indexes on every cache hit. If loading the entry or restoring its
5525
- * indexes fails, the computation runs again and replaces the cache entry.
5526
- *
5527
5483
  * `cache()` automatically tracks whether earlier SDA operations changed the
5528
5484
  * table. It also records every other already registered `SimpleTable` read
5529
5485
  * through `SimpleTable` methods while `compute` runs and invalidates the
5530
5486
  * cached step when any of their generations change. Tables created inside
5531
5487
  * `compute` are part of the computation itself and are not dependencies.
5532
5488
  *
5489
+ * Inside `compute`, you may modify the table being cached and create or
5490
+ * modify temporary tables, provided you remove them before the callback
5491
+ * finishes. Other tables that already existed may be read but not modified,
5492
+ * renamed, or removed. `customQuery()` bypasses enforcement of these rules.
5493
+ *
5533
5494
  * `SimpleDB.customQuery()` bypasses this tracking. Reading or changing a
5534
5495
  * table with `customQuery()` can therefore return stale cached data. Include
5535
5496
  * a value that identifies the custom query's dependencies in `options.inputs`
5536
5497
  * (such as a table content hash), or use tracked `SimpleTable` methods.
5537
5498
  *
5538
- * `compute` may modify only the table being cached. Other tables that existed
5539
- * before `compute` must remain read-only. Temporary tables may be created and
5540
- * modified inside `compute`, but they must be removed before it finishes
5541
- * because a cache hit does not run `compute` again.
5499
+ * Cache entries are stored as DuckDB database files. Full-text search (FTS)
5500
+ * indexes are persisted in the cache file and restored directly on a cache
5501
+ * hit. Vector similarity search (VSS/HNSW) indexes are not persisted in the
5502
+ * cache file; their definitions are stored as metadata and used to rebuild
5503
+ * the indexes on every cache hit. If loading the entry or restoring its
5504
+ * indexes fails, the computation runs again and replaces the cache entry.
5542
5505
  *
5543
5506
  * @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.
5544
5507
  * @param options - An optional object with configuration options:
@@ -5623,7 +5586,16 @@ class SimpleTable extends Simple {
5623
5586
  /**
5624
5587
  * Logs a specified number of rows from the table to the console. By default, the first 10 rows are logged.
5625
5588
  * You can optionally log the column types and filter the data based on conditions.
5626
- * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
5589
+ * SQL dates and timestamps retain their native precision for display, including
5590
+ * temporal infinities. Lists and objects are stringified using the same nested
5591
+ * representations as `getData()`, then truncated according to `charsToLog`.
5592
+ * Unsafe top-level large integers throw, just as with `getData()`.
5593
+ * Type annotations describe the SQL type and the JavaScript extraction type
5594
+ * before display formatting; nulls do not determine the column's annotation.
5595
+ * Colors reflect the SQL value's meaning, so exact decimal strings use numeric
5596
+ * coloring. Column width is independent of the content truncation budget.
5597
+ *
5598
+ * With the default `SimpleDB.expressionSyntax: "js"`, conditions support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
5627
5599
  *
5628
5600
  * @param options - Either the number of rows to log (a specific number or `"all"`) or an object with configuration options:
5629
5601
  * @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.
@@ -5663,57 +5635,7 @@ class SimpleTable extends Simple {
5663
5635
  * ```
5664
5636
  */
5665
5637
  async log(options = {}) {
5666
- if (this.connection === undefined) {
5667
- await this.sdb.start();
5668
- this.db = this.sdb.db;
5669
- this.connection = this.sdb.connection;
5670
- }
5671
- if (this.connection === undefined) {
5672
- throw new Error("this.connection is undefined");
5673
- }
5674
- let count;
5675
- if (typeof options === "number") {
5676
- count = options;
5677
- }
5678
- else if (options === "all") {
5679
- count = await this.getRowCount();
5680
- }
5681
- else if (typeof options === "object") {
5682
- if (options.count === "all") {
5683
- count = await this.getRowCount();
5684
- }
5685
- else if (typeof options.count === "number") {
5686
- count = options.count;
5687
- }
5688
- else {
5689
- count = this.rowsToLog;
5690
- }
5691
- }
5692
- else {
5693
- count = this.rowsToLog;
5694
- }
5695
- const types = typeof options === "object"
5696
- ? options.types ?? this.typesToLog
5697
- : this.typesToLog;
5698
- const conditions = typeof options === "object"
5699
- ? options.conditions ?? undefined
5700
- : undefined;
5701
- if (this.connection === undefined ||
5702
- !(await this.sdb.hasTable(this.name))) {
5703
- console.log(`\nTable ${this.name}: no data`);
5704
- }
5705
- else {
5706
- console.log(`\nTable ${this.name}:`);
5707
- conditions && console.log(`Conditions: ${conditions}`);
5708
- const data = await this.getTop(count, { conditions });
5709
- logData(types ? await this.getTypes() : null, data, this.charsToLog);
5710
- const rowCount = conditions
5711
- ? parseInt((await this.sdb.customQuery(`select count(*) as count from ${quoteIdentifier(this.name)} where ${conditions}`, { returnData: true }))[0].count)
5712
- : await this.getRowCount();
5713
- console.log(`${formatNumber(rowCount)} rows in total ${`(count: ${count}${typeof this.charsToLog === "number"
5714
- ? `, charsToLog: ${this.charsToLog}`
5715
- : ""})`}`);
5716
- }
5638
+ await log(this, options);
5717
5639
  return this;
5718
5640
  }
5719
5641
  /**
@@ -5915,6 +5837,10 @@ class SimpleTable extends Simple {
5915
5837
  /**
5916
5838
  * 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.
5917
5839
  *
5840
+ * Uses the same precision-preserving temporal display, nested stringification,
5841
+ * numeric coloring, and `charsToLog` truncation as `log()`. Unsafe top-level
5842
+ * large integers throw, just as with `getData()`.
5843
+ *
5918
5844
  * @param count - The number of rows to log from the bottom of the table. Defaults to the table's `rowsToLog` option if not specified.
5919
5845
  * @param options - An optional object with logging preferences.
5920
5846
  * @param options.originalOrder - If true, the rows are displayed in their original order (top to bottom). Defaults to false.
@@ -5940,10 +5866,7 @@ class SimpleTable extends Simple {
5940
5866
  * ```
5941
5867
  */
5942
5868
  async logBottom(count, options = {}) {
5943
- const rows = count ?? this.rowsToLog;
5944
- console.log(`\nTable ${this.name} (${rows} bottom rows):`);
5945
- const data = await this.getBottom(rows, options);
5946
- logData(null, data, this.charsToLog);
5869
+ await logBottom(this, count, options);
5947
5870
  return this;
5948
5871
  }
5949
5872
  /**