@nshiab/simple-data-analysis-core 0.0.12

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 (773) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +43 -0
  3. package/esm/class/Simple.d.ts +66 -0
  4. package/esm/class/Simple.d.ts.map +1 -0
  5. package/esm/class/Simple.js +94 -0
  6. package/esm/class/SimpleDB.d.ts +487 -0
  7. package/esm/class/SimpleDB.d.ts.map +1 -0
  8. package/esm/class/SimpleDB.js +807 -0
  9. package/esm/class/SimpleTable.d.ts +4408 -0
  10. package/esm/class/SimpleTable.d.ts.map +1 -0
  11. package/esm/class/SimpleTable.js +5401 -0
  12. package/esm/helpers/accumulateQuery.d.ts +4 -0
  13. package/esm/helpers/accumulateQuery.d.ts.map +1 -0
  14. package/esm/helpers/accumulateQuery.js +15 -0
  15. package/esm/helpers/camelCase.d.ts +30 -0
  16. package/esm/helpers/camelCase.d.ts.map +1 -0
  17. package/esm/helpers/camelCase.js +45 -0
  18. package/esm/helpers/capitalize.d.ts +28 -0
  19. package/esm/helpers/capitalize.d.ts.map +1 -0
  20. package/esm/helpers/capitalize.js +33 -0
  21. package/esm/helpers/checkVssIndexes.d.ts +2 -0
  22. package/esm/helpers/checkVssIndexes.d.ts.map +1 -0
  23. package/esm/helpers/checkVssIndexes.js +16 -0
  24. package/esm/helpers/cleanCache.d.ts +3 -0
  25. package/esm/helpers/cleanCache.d.ts.map +1 -0
  26. package/esm/helpers/cleanCache.js +17 -0
  27. package/esm/helpers/cleanPath.d.ts +2 -0
  28. package/esm/helpers/cleanPath.d.ts.map +1 -0
  29. package/esm/helpers/cleanPath.js +3 -0
  30. package/esm/helpers/cleanSQL.d.ts +2 -0
  31. package/esm/helpers/cleanSQL.d.ts.map +1 -0
  32. package/esm/helpers/cleanSQL.js +24 -0
  33. package/esm/helpers/concatenateRowQuery.d.ts +2 -0
  34. package/esm/helpers/concatenateRowQuery.d.ts.map +1 -0
  35. package/esm/helpers/concatenateRowQuery.js +9 -0
  36. package/esm/helpers/convertForJS.d.ts +6 -0
  37. package/esm/helpers/convertForJS.d.ts.map +1 -0
  38. package/esm/helpers/convertForJS.js +39 -0
  39. package/esm/helpers/createDirectory.d.ts +2 -0
  40. package/esm/helpers/createDirectory.d.ts.map +1 -0
  41. package/esm/helpers/createDirectory.js +10 -0
  42. package/esm/helpers/csvFormat.d.ts +3 -0
  43. package/esm/helpers/csvFormat.d.ts.map +1 -0
  44. package/esm/helpers/csvFormat.js +165 -0
  45. package/esm/helpers/dataToArrays.d.ts +51 -0
  46. package/esm/helpers/dataToArrays.d.ts.map +1 -0
  47. package/esm/helpers/dataToArrays.js +55 -0
  48. package/esm/helpers/extractTypes.d.ts +6 -0
  49. package/esm/helpers/extractTypes.d.ts.map +1 -0
  50. package/esm/helpers/extractTypes.js +11 -0
  51. package/esm/helpers/findGeoColumn.d.ts +3 -0
  52. package/esm/helpers/findGeoColumn.d.ts.map +1 -0
  53. package/esm/helpers/findGeoColumn.js +18 -0
  54. package/esm/helpers/formatDate.d.ts +34 -0
  55. package/esm/helpers/formatDate.d.ts.map +1 -0
  56. package/esm/helpers/formatDate.js +69 -0
  57. package/esm/helpers/formatNumber.d.ts +46 -0
  58. package/esm/helpers/formatNumber.d.ts.map +1 -0
  59. package/esm/helpers/formatNumber.js +122 -0
  60. package/esm/helpers/getCombinations.d.ts +3 -0
  61. package/esm/helpers/getCombinations.d.ts.map +1 -0
  62. package/esm/helpers/getCombinations.js +24 -0
  63. package/esm/helpers/getExtension.d.ts +2 -0
  64. package/esm/helpers/getExtension.d.ts.map +1 -0
  65. package/esm/helpers/getExtension.js +9 -0
  66. package/esm/helpers/getIdenticalColumns.d.ts +2 -0
  67. package/esm/helpers/getIdenticalColumns.d.ts.map +1 -0
  68. package/esm/helpers/getIdenticalColumns.js +3 -0
  69. package/esm/helpers/getName.d.ts +2 -0
  70. package/esm/helpers/getName.d.ts.map +1 -0
  71. package/esm/helpers/getName.js +14 -0
  72. package/esm/helpers/getProjection.d.ts +3 -0
  73. package/esm/helpers/getProjection.d.ts.map +1 -0
  74. package/esm/helpers/getProjection.js +22 -0
  75. package/esm/helpers/getProjectionParquet.d.ts +3 -0
  76. package/esm/helpers/getProjectionParquet.d.ts.map +1 -0
  77. package/esm/helpers/getProjectionParquet.js +24 -0
  78. package/esm/helpers/index.d.ts +20 -0
  79. package/esm/helpers/index.d.ts.map +1 -0
  80. package/esm/helpers/index.js +19 -0
  81. package/esm/helpers/keepNumericalColumns.d.ts +4 -0
  82. package/esm/helpers/keepNumericalColumns.d.ts.map +1 -0
  83. package/esm/helpers/keepNumericalColumns.js +13 -0
  84. package/esm/helpers/logData.d.ts +6 -0
  85. package/esm/helpers/logData.d.ts.map +1 -0
  86. package/esm/helpers/logData.js +48 -0
  87. package/esm/helpers/mergeOptions.d.ts +28 -0
  88. package/esm/helpers/mergeOptions.d.ts.map +1 -0
  89. package/esm/helpers/mergeOptions.js +12 -0
  90. package/esm/helpers/nestQuery.d.ts +2 -0
  91. package/esm/helpers/nestQuery.d.ts.map +1 -0
  92. package/esm/helpers/nestQuery.js +13 -0
  93. package/esm/helpers/parseDuckDBType.d.ts +2 -0
  94. package/esm/helpers/parseDuckDBType.d.ts.map +1 -0
  95. package/esm/helpers/parseDuckDBType.js +38 -0
  96. package/esm/helpers/parseTypes.d.ts +2 -0
  97. package/esm/helpers/parseTypes.d.ts.map +1 -0
  98. package/esm/helpers/parseTypes.js +35 -0
  99. package/esm/helpers/parseValue.d.ts +2 -0
  100. package/esm/helpers/parseValue.d.ts.map +1 -0
  101. package/esm/helpers/parseValue.js +20 -0
  102. package/esm/helpers/prettyDuration.d.ts +55 -0
  103. package/esm/helpers/prettyDuration.d.ts.map +1 -0
  104. package/esm/helpers/prettyDuration.js +145 -0
  105. package/esm/helpers/printTable.d.ts +47 -0
  106. package/esm/helpers/printTable.d.ts.map +1 -0
  107. package/esm/helpers/printTable.js +217 -0
  108. package/esm/helpers/queryDB.d.ts +19 -0
  109. package/esm/helpers/queryDB.d.ts.map +1 -0
  110. package/esm/helpers/queryDB.js +62 -0
  111. package/esm/helpers/rewind.d.ts +3 -0
  112. package/esm/helpers/rewind.d.ts.map +1 -0
  113. package/esm/helpers/rewind.js +1293 -0
  114. package/esm/helpers/runQuery.d.ts +14 -0
  115. package/esm/helpers/runQuery.d.ts.map +1 -0
  116. package/esm/helpers/runQuery.js +26 -0
  117. package/esm/helpers/setDbProps.d.ts +3 -0
  118. package/esm/helpers/setDbProps.d.ts.map +1 -0
  119. package/esm/helpers/setDbProps.js +25 -0
  120. package/esm/helpers/shouldFlipBeforeExport.d.ts +2 -0
  121. package/esm/helpers/shouldFlipBeforeExport.d.ts.map +1 -0
  122. package/esm/helpers/shouldFlipBeforeExport.js +3 -0
  123. package/esm/helpers/stringToArray.d.ts +2 -0
  124. package/esm/helpers/stringToArray.d.ts.map +1 -0
  125. package/esm/helpers/stringToArray.js +11 -0
  126. package/esm/helpers/stringifyDates.d.ts +5 -0
  127. package/esm/helpers/stringifyDates.d.ts.map +1 -0
  128. package/esm/helpers/stringifyDates.js +14 -0
  129. package/esm/helpers/stringifyDatesInvert.d.ts +5 -0
  130. package/esm/helpers/stringifyDatesInvert.d.ts.map +1 -0
  131. package/esm/helpers/stringifyDatesInvert.js +14 -0
  132. package/esm/helpers/unifyColumns.d.ts +9 -0
  133. package/esm/helpers/unifyColumns.d.ts.map +1 -0
  134. package/esm/helpers/unifyColumns.js +21 -0
  135. package/esm/helpers/unnestQuery.d.ts +2 -0
  136. package/esm/helpers/unnestQuery.d.ts.map +1 -0
  137. package/esm/helpers/unnestQuery.js +8 -0
  138. package/esm/helpers/wrapString.d.ts +35 -0
  139. package/esm/helpers/wrapString.d.ts.map +1 -0
  140. package/esm/helpers/wrapString.js +83 -0
  141. package/esm/helpers/writeDataAsArrays.d.ts +3 -0
  142. package/esm/helpers/writeDataAsArrays.d.ts.map +1 -0
  143. package/esm/helpers/writeDataAsArrays.js +13 -0
  144. package/esm/helpers/writeProjectionsAndIndexes.d.ts +3 -0
  145. package/esm/helpers/writeProjectionsAndIndexes.d.ts.map +1 -0
  146. package/esm/helpers/writeProjectionsAndIndexes.js +29 -0
  147. package/esm/index.d.ts +31 -0
  148. package/esm/index.d.ts.map +1 -0
  149. package/esm/index.js +30 -0
  150. package/esm/methods/aggregateGeoQuery.d.ts +5 -0
  151. package/esm/methods/aggregateGeoQuery.d.ts.map +1 -0
  152. package/esm/methods/aggregateGeoQuery.js +24 -0
  153. package/esm/methods/binsQuery.d.ts +5 -0
  154. package/esm/methods/binsQuery.d.ts.map +1 -0
  155. package/esm/methods/binsQuery.js +40 -0
  156. package/esm/methods/bm25.d.ts +17 -0
  157. package/esm/methods/bm25.d.ts.map +1 -0
  158. package/esm/methods/bm25.js +48 -0
  159. package/esm/methods/cache.d.ts +6 -0
  160. package/esm/methods/cache.d.ts.map +1 -0
  161. package/esm/methods/cache.js +133 -0
  162. package/esm/methods/capitalizeQuery.d.ts +2 -0
  163. package/esm/methods/capitalizeQuery.d.ts.map +1 -0
  164. package/esm/methods/capitalizeQuery.js +8 -0
  165. package/esm/methods/cloneColumn.d.ts +4 -0
  166. package/esm/methods/cloneColumn.d.ts.map +1 -0
  167. package/esm/methods/cloneColumn.js +13 -0
  168. package/esm/methods/cloneQuery.d.ts +4 -0
  169. package/esm/methods/cloneQuery.d.ts.map +1 -0
  170. package/esm/methods/cloneQuery.js +6 -0
  171. package/esm/methods/concatenateQuery.d.ts +4 -0
  172. package/esm/methods/concatenateQuery.d.ts.map +1 -0
  173. package/esm/methods/concatenateQuery.js +13 -0
  174. package/esm/methods/convertQuery.d.ts +7 -0
  175. package/esm/methods/convertQuery.d.ts.map +1 -0
  176. package/esm/methods/convertQuery.js +78 -0
  177. package/esm/methods/correlations.d.ts +9 -0
  178. package/esm/methods/correlations.d.ts.map +1 -0
  179. package/esm/methods/correlations.js +40 -0
  180. package/esm/methods/correlationsQuery.d.ts +5 -0
  181. package/esm/methods/correlationsQuery.d.ts.map +1 -0
  182. package/esm/methods/correlationsQuery.js +26 -0
  183. package/esm/methods/createFtsIndex.d.ts +11 -0
  184. package/esm/methods/createFtsIndex.d.ts.map +1 -0
  185. package/esm/methods/createFtsIndex.js +28 -0
  186. package/esm/methods/createVssIndex.d.ts +9 -0
  187. package/esm/methods/createVssIndex.d.ts.map +1 -0
  188. package/esm/methods/createVssIndex.js +38 -0
  189. package/esm/methods/crossJoinQuery.d.ts +4 -0
  190. package/esm/methods/crossJoinQuery.d.ts.map +1 -0
  191. package/esm/methods/crossJoinQuery.js +3 -0
  192. package/esm/methods/distanceQuery.d.ts +6 -0
  193. package/esm/methods/distanceQuery.d.ts.map +1 -0
  194. package/esm/methods/distanceQuery.js +42 -0
  195. package/esm/methods/fill.d.ts +7 -0
  196. package/esm/methods/fill.d.ts.map +1 -0
  197. package/esm/methods/fill.js +60 -0
  198. package/esm/methods/fuzzyClean.d.ts +7 -0
  199. package/esm/methods/fuzzyClean.d.ts.map +1 -0
  200. package/esm/methods/fuzzyClean.js +194 -0
  201. package/esm/methods/fuzzyJoin.d.ts +8 -0
  202. package/esm/methods/fuzzyJoin.d.ts.map +1 -0
  203. package/esm/methods/fuzzyJoin.js +57 -0
  204. package/esm/methods/fuzzyJoinQuery.d.ts +2 -0
  205. package/esm/methods/fuzzyJoinQuery.d.ts.map +1 -0
  206. package/esm/methods/fuzzyJoinQuery.js +19 -0
  207. package/esm/methods/getBottom.d.ts +8 -0
  208. package/esm/methods/getBottom.d.ts.map +1 -0
  209. package/esm/methods/getBottom.js +22 -0
  210. package/esm/methods/getColumns.d.ts +3 -0
  211. package/esm/methods/getColumns.d.ts.map +1 -0
  212. package/esm/methods/getColumns.js +15 -0
  213. package/esm/methods/getDescription.d.ts +9 -0
  214. package/esm/methods/getDescription.d.ts.map +1 -0
  215. package/esm/methods/getDescription.js +20 -0
  216. package/esm/methods/getFirstRow.d.ts +7 -0
  217. package/esm/methods/getFirstRow.d.ts.map +1 -0
  218. package/esm/methods/getFirstRow.js +15 -0
  219. package/esm/methods/getGeoData.d.ts +17 -0
  220. package/esm/methods/getGeoData.d.ts.map +1 -0
  221. package/esm/methods/getGeoData.js +41 -0
  222. package/esm/methods/getLastRow.d.ts +7 -0
  223. package/esm/methods/getLastRow.d.ts.map +1 -0
  224. package/esm/methods/getLastRow.js +19 -0
  225. package/esm/methods/getMax.d.ts +3 -0
  226. package/esm/methods/getMax.d.ts.map +1 -0
  227. package/esm/methods/getMax.js +18 -0
  228. package/esm/methods/getMean.d.ts +5 -0
  229. package/esm/methods/getMean.d.ts.map +1 -0
  230. package/esm/methods/getMean.js +17 -0
  231. package/esm/methods/getMedian.d.ts +5 -0
  232. package/esm/methods/getMedian.d.ts.map +1 -0
  233. package/esm/methods/getMedian.js +17 -0
  234. package/esm/methods/getMin.d.ts +3 -0
  235. package/esm/methods/getMin.d.ts.map +1 -0
  236. package/esm/methods/getMin.js +18 -0
  237. package/esm/methods/getNbCharacters.d.ts +3 -0
  238. package/esm/methods/getNbCharacters.d.ts.map +1 -0
  239. package/esm/methods/getNbCharacters.js +15 -0
  240. package/esm/methods/getNbRows.d.ts +3 -0
  241. package/esm/methods/getNbRows.d.ts.map +1 -0
  242. package/esm/methods/getNbRows.js +15 -0
  243. package/esm/methods/getQuantile.d.ts +5 -0
  244. package/esm/methods/getQuantile.d.ts.map +1 -0
  245. package/esm/methods/getQuantile.js +17 -0
  246. package/esm/methods/getSkew.d.ts +5 -0
  247. package/esm/methods/getSkew.d.ts.map +1 -0
  248. package/esm/methods/getSkew.js +17 -0
  249. package/esm/methods/getStdDev.d.ts +5 -0
  250. package/esm/methods/getStdDev.d.ts.map +1 -0
  251. package/esm/methods/getStdDev.js +17 -0
  252. package/esm/methods/getSum.d.ts +3 -0
  253. package/esm/methods/getSum.d.ts.map +1 -0
  254. package/esm/methods/getSum.js +15 -0
  255. package/esm/methods/getTableNames.d.ts +3 -0
  256. package/esm/methods/getTableNames.d.ts.map +1 -0
  257. package/esm/methods/getTableNames.js +15 -0
  258. package/esm/methods/getTop.d.ts +7 -0
  259. package/esm/methods/getTop.d.ts.map +1 -0
  260. package/esm/methods/getTop.js +14 -0
  261. package/esm/methods/getTypes.d.ts +5 -0
  262. package/esm/methods/getTypes.d.ts.map +1 -0
  263. package/esm/methods/getTypes.js +13 -0
  264. package/esm/methods/getUniques.d.ts +3 -0
  265. package/esm/methods/getUniques.d.ts.map +1 -0
  266. package/esm/methods/getUniques.js +15 -0
  267. package/esm/methods/getValues.d.ts +3 -0
  268. package/esm/methods/getValues.d.ts.map +1 -0
  269. package/esm/methods/getValues.js +15 -0
  270. package/esm/methods/getVar.d.ts +5 -0
  271. package/esm/methods/getVar.d.ts.map +1 -0
  272. package/esm/methods/getVar.js +17 -0
  273. package/esm/methods/insertRowsQuery.d.ts +4 -0
  274. package/esm/methods/insertRowsQuery.d.ts.map +1 -0
  275. package/esm/methods/insertRowsQuery.js +11 -0
  276. package/esm/methods/join.d.ts +7 -0
  277. package/esm/methods/join.d.ts.map +1 -0
  278. package/esm/methods/join.js +63 -0
  279. package/esm/methods/joinGeo.d.ts +10 -0
  280. package/esm/methods/joinGeo.d.ts.map +1 -0
  281. package/esm/methods/joinGeo.js +76 -0
  282. package/esm/methods/joinGeoQuery.d.ts +2 -0
  283. package/esm/methods/joinGeoQuery.d.ts.map +1 -0
  284. package/esm/methods/joinGeoQuery.js +55 -0
  285. package/esm/methods/joinQuery.d.ts +2 -0
  286. package/esm/methods/joinQuery.d.ts.map +1 -0
  287. package/esm/methods/joinQuery.js +21 -0
  288. package/esm/methods/keepQuery.d.ts +4 -0
  289. package/esm/methods/keepQuery.d.ts.map +1 -0
  290. package/esm/methods/keepQuery.js +15 -0
  291. package/esm/methods/linearRegressionQuery.d.ts +5 -0
  292. package/esm/methods/linearRegressionQuery.d.ts.map +1 -0
  293. package/esm/methods/linearRegressionQuery.js +37 -0
  294. package/esm/methods/linearRegressions.d.ts +9 -0
  295. package/esm/methods/linearRegressions.d.ts.map +1 -0
  296. package/esm/methods/linearRegressions.js +43 -0
  297. package/esm/methods/loadArray.d.ts +5 -0
  298. package/esm/methods/loadArray.d.ts.map +1 -0
  299. package/esm/methods/loadArray.js +78 -0
  300. package/esm/methods/loadDataQuery.d.ts +23 -0
  301. package/esm/methods/loadDataQuery.d.ts.map +1 -0
  302. package/esm/methods/loadDataQuery.js +77 -0
  303. package/esm/methods/lowerQuery.d.ts +2 -0
  304. package/esm/methods/lowerQuery.d.ts.map +1 -0
  305. package/esm/methods/lowerQuery.js +7 -0
  306. package/esm/methods/normalizeQuery.d.ts +5 -0
  307. package/esm/methods/normalizeQuery.d.ts.map +1 -0
  308. package/esm/methods/normalizeQuery.js +22 -0
  309. package/esm/methods/normalizeString.d.ts +5 -0
  310. package/esm/methods/normalizeString.d.ts.map +1 -0
  311. package/esm/methods/normalizeString.js +26 -0
  312. package/esm/methods/outliersIQRQuery.d.ts +4 -0
  313. package/esm/methods/outliersIQRQuery.d.ts.map +1 -0
  314. package/esm/methods/outliersIQRQuery.js +31 -0
  315. package/esm/methods/proportionsHorizontalQuery.d.ts +5 -0
  316. package/esm/methods/proportionsHorizontalQuery.d.ts.map +1 -0
  317. package/esm/methods/proportionsHorizontalQuery.js +15 -0
  318. package/esm/methods/proportionsVerticalQuery.d.ts +5 -0
  319. package/esm/methods/proportionsVerticalQuery.d.ts.map +1 -0
  320. package/esm/methods/proportionsVerticalQuery.js +19 -0
  321. package/esm/methods/quantilesQuery.d.ts +4 -0
  322. package/esm/methods/quantilesQuery.d.ts.map +1 -0
  323. package/esm/methods/quantilesQuery.js +12 -0
  324. package/esm/methods/ranksQuery.d.ts +6 -0
  325. package/esm/methods/ranksQuery.d.ts.map +1 -0
  326. package/esm/methods/ranksQuery.js +12 -0
  327. package/esm/methods/removeDuplicatesQuery.d.ts +4 -0
  328. package/esm/methods/removeDuplicatesQuery.d.ts.map +1 -0
  329. package/esm/methods/removeDuplicatesQuery.js +12 -0
  330. package/esm/methods/removeMissing.d.ts +7 -0
  331. package/esm/methods/removeMissing.d.ts.map +1 -0
  332. package/esm/methods/removeMissing.js +21 -0
  333. package/esm/methods/removeMissingQuery.d.ts +7 -0
  334. package/esm/methods/removeMissingQuery.d.ts.map +1 -0
  335. package/esm/methods/removeMissingQuery.js +43 -0
  336. package/esm/methods/removeQuery.d.ts +4 -0
  337. package/esm/methods/removeQuery.d.ts.map +1 -0
  338. package/esm/methods/removeQuery.js +15 -0
  339. package/esm/methods/renameColumnQuery.d.ts +2 -0
  340. package/esm/methods/renameColumnQuery.d.ts.map +1 -0
  341. package/esm/methods/renameColumnQuery.js +7 -0
  342. package/esm/methods/replaceNullsQuery.d.ts +2 -0
  343. package/esm/methods/replaceNullsQuery.d.ts.map +1 -0
  344. package/esm/methods/replaceNullsQuery.js +10 -0
  345. package/esm/methods/replaceQuery.d.ts +5 -0
  346. package/esm/methods/replaceQuery.d.ts.map +1 -0
  347. package/esm/methods/replaceQuery.js +24 -0
  348. package/esm/methods/rollingQuery.d.ts +5 -0
  349. package/esm/methods/rollingQuery.d.ts.map +1 -0
  350. package/esm/methods/rollingQuery.js +33 -0
  351. package/esm/methods/roundQuery.d.ts +5 -0
  352. package/esm/methods/roundQuery.d.ts.map +1 -0
  353. package/esm/methods/roundQuery.js +16 -0
  354. package/esm/methods/selectRowsQuery.d.ts +5 -0
  355. package/esm/methods/selectRowsQuery.d.ts.map +1 -0
  356. package/esm/methods/selectRowsQuery.js +3 -0
  357. package/esm/methods/sortQuery.d.ts +8 -0
  358. package/esm/methods/sortQuery.d.ts.map +1 -0
  359. package/esm/methods/sortQuery.js +18 -0
  360. package/esm/methods/splitSpread.d.ts +5 -0
  361. package/esm/methods/splitSpread.d.ts.map +1 -0
  362. package/esm/methods/splitSpread.js +61 -0
  363. package/esm/methods/summarize.d.ts +13 -0
  364. package/esm/methods/summarize.d.ts.map +1 -0
  365. package/esm/methods/summarize.js +60 -0
  366. package/esm/methods/summarizeQuery.d.ts +7 -0
  367. package/esm/methods/summarizeQuery.d.ts.map +1 -0
  368. package/esm/methods/summarizeQuery.js +112 -0
  369. package/esm/methods/trimQuery.d.ts +5 -0
  370. package/esm/methods/trimQuery.d.ts.map +1 -0
  371. package/esm/methods/trimQuery.js +29 -0
  372. package/esm/methods/truncateQuery.d.ts +2 -0
  373. package/esm/methods/truncateQuery.d.ts.map +1 -0
  374. package/esm/methods/truncateQuery.js +3 -0
  375. package/esm/methods/upperQuery.d.ts +2 -0
  376. package/esm/methods/upperQuery.d.ts.map +1 -0
  377. package/esm/methods/upperQuery.js +7 -0
  378. package/esm/methods/writeDataQuery.d.ts +5 -0
  379. package/esm/methods/writeDataQuery.d.ts.map +1 -0
  380. package/esm/methods/writeDataQuery.js +44 -0
  381. package/esm/methods/writeGeoDataQuery.d.ts +4 -0
  382. package/esm/methods/writeGeoDataQuery.d.ts.map +1 -0
  383. package/esm/methods/writeGeoDataQuery.js +16 -0
  384. package/esm/methods/zScoreQuery.d.ts +5 -0
  385. package/esm/methods/zScoreQuery.d.ts.map +1 -0
  386. package/esm/methods/zScoreQuery.js +23 -0
  387. package/esm/package.json +3 -0
  388. package/package.json +27 -0
  389. package/script/class/Simple.d.ts +66 -0
  390. package/script/class/Simple.d.ts.map +1 -0
  391. package/script/class/Simple.js +97 -0
  392. package/script/class/SimpleDB.d.ts +487 -0
  393. package/script/class/SimpleDB.d.ts.map +1 -0
  394. package/script/class/SimpleDB.js +813 -0
  395. package/script/class/SimpleTable.d.ts +4408 -0
  396. package/script/class/SimpleTable.d.ts.map +1 -0
  397. package/script/class/SimpleTable.js +5407 -0
  398. package/script/helpers/accumulateQuery.d.ts +4 -0
  399. package/script/helpers/accumulateQuery.d.ts.map +1 -0
  400. package/script/helpers/accumulateQuery.js +21 -0
  401. package/script/helpers/camelCase.d.ts +30 -0
  402. package/script/helpers/camelCase.d.ts.map +1 -0
  403. package/script/helpers/camelCase.js +51 -0
  404. package/script/helpers/capitalize.d.ts +28 -0
  405. package/script/helpers/capitalize.d.ts.map +1 -0
  406. package/script/helpers/capitalize.js +36 -0
  407. package/script/helpers/checkVssIndexes.d.ts +2 -0
  408. package/script/helpers/checkVssIndexes.d.ts.map +1 -0
  409. package/script/helpers/checkVssIndexes.js +19 -0
  410. package/script/helpers/cleanCache.d.ts +3 -0
  411. package/script/helpers/cleanCache.d.ts.map +1 -0
  412. package/script/helpers/cleanCache.js +20 -0
  413. package/script/helpers/cleanPath.d.ts +2 -0
  414. package/script/helpers/cleanPath.d.ts.map +1 -0
  415. package/script/helpers/cleanPath.js +6 -0
  416. package/script/helpers/cleanSQL.d.ts +2 -0
  417. package/script/helpers/cleanSQL.d.ts.map +1 -0
  418. package/script/helpers/cleanSQL.js +27 -0
  419. package/script/helpers/concatenateRowQuery.d.ts +2 -0
  420. package/script/helpers/concatenateRowQuery.d.ts.map +1 -0
  421. package/script/helpers/concatenateRowQuery.js +12 -0
  422. package/script/helpers/convertForJS.d.ts +6 -0
  423. package/script/helpers/convertForJS.d.ts.map +1 -0
  424. package/script/helpers/convertForJS.js +42 -0
  425. package/script/helpers/createDirectory.d.ts +2 -0
  426. package/script/helpers/createDirectory.d.ts.map +1 -0
  427. package/script/helpers/createDirectory.js +13 -0
  428. package/script/helpers/csvFormat.d.ts +3 -0
  429. package/script/helpers/csvFormat.d.ts.map +1 -0
  430. package/script/helpers/csvFormat.js +168 -0
  431. package/script/helpers/dataToArrays.d.ts +51 -0
  432. package/script/helpers/dataToArrays.d.ts.map +1 -0
  433. package/script/helpers/dataToArrays.js +58 -0
  434. package/script/helpers/extractTypes.d.ts +6 -0
  435. package/script/helpers/extractTypes.d.ts.map +1 -0
  436. package/script/helpers/extractTypes.js +14 -0
  437. package/script/helpers/findGeoColumn.d.ts +3 -0
  438. package/script/helpers/findGeoColumn.d.ts.map +1 -0
  439. package/script/helpers/findGeoColumn.js +21 -0
  440. package/script/helpers/formatDate.d.ts +34 -0
  441. package/script/helpers/formatDate.d.ts.map +1 -0
  442. package/script/helpers/formatDate.js +72 -0
  443. package/script/helpers/formatNumber.d.ts +46 -0
  444. package/script/helpers/formatNumber.d.ts.map +1 -0
  445. package/script/helpers/formatNumber.js +125 -0
  446. package/script/helpers/getCombinations.d.ts +3 -0
  447. package/script/helpers/getCombinations.d.ts.map +1 -0
  448. package/script/helpers/getCombinations.js +26 -0
  449. package/script/helpers/getExtension.d.ts +2 -0
  450. package/script/helpers/getExtension.d.ts.map +1 -0
  451. package/script/helpers/getExtension.js +12 -0
  452. package/script/helpers/getIdenticalColumns.d.ts +2 -0
  453. package/script/helpers/getIdenticalColumns.d.ts.map +1 -0
  454. package/script/helpers/getIdenticalColumns.js +6 -0
  455. package/script/helpers/getName.d.ts +2 -0
  456. package/script/helpers/getName.d.ts.map +1 -0
  457. package/script/helpers/getName.js +17 -0
  458. package/script/helpers/getProjection.d.ts +3 -0
  459. package/script/helpers/getProjection.d.ts.map +1 -0
  460. package/script/helpers/getProjection.js +28 -0
  461. package/script/helpers/getProjectionParquet.d.ts +3 -0
  462. package/script/helpers/getProjectionParquet.d.ts.map +1 -0
  463. package/script/helpers/getProjectionParquet.js +30 -0
  464. package/script/helpers/index.d.ts +20 -0
  465. package/script/helpers/index.d.ts.map +1 -0
  466. package/script/helpers/index.js +30 -0
  467. package/script/helpers/keepNumericalColumns.d.ts +4 -0
  468. package/script/helpers/keepNumericalColumns.d.ts.map +1 -0
  469. package/script/helpers/keepNumericalColumns.js +16 -0
  470. package/script/helpers/logData.d.ts +6 -0
  471. package/script/helpers/logData.d.ts.map +1 -0
  472. package/script/helpers/logData.js +54 -0
  473. package/script/helpers/mergeOptions.d.ts +28 -0
  474. package/script/helpers/mergeOptions.d.ts.map +1 -0
  475. package/script/helpers/mergeOptions.js +15 -0
  476. package/script/helpers/nestQuery.d.ts +2 -0
  477. package/script/helpers/nestQuery.d.ts.map +1 -0
  478. package/script/helpers/nestQuery.js +19 -0
  479. package/script/helpers/parseDuckDBType.d.ts +2 -0
  480. package/script/helpers/parseDuckDBType.d.ts.map +1 -0
  481. package/script/helpers/parseDuckDBType.js +41 -0
  482. package/script/helpers/parseTypes.d.ts +2 -0
  483. package/script/helpers/parseTypes.d.ts.map +1 -0
  484. package/script/helpers/parseTypes.js +38 -0
  485. package/script/helpers/parseValue.d.ts +2 -0
  486. package/script/helpers/parseValue.d.ts.map +1 -0
  487. package/script/helpers/parseValue.js +23 -0
  488. package/script/helpers/prettyDuration.d.ts +55 -0
  489. package/script/helpers/prettyDuration.d.ts.map +1 -0
  490. package/script/helpers/prettyDuration.js +148 -0
  491. package/script/helpers/printTable.d.ts +47 -0
  492. package/script/helpers/printTable.d.ts.map +1 -0
  493. package/script/helpers/printTable.js +223 -0
  494. package/script/helpers/queryDB.d.ts +19 -0
  495. package/script/helpers/queryDB.d.ts.map +1 -0
  496. package/script/helpers/queryDB.js +68 -0
  497. package/script/helpers/rewind.d.ts +3 -0
  498. package/script/helpers/rewind.d.ts.map +1 -0
  499. package/script/helpers/rewind.js +1295 -0
  500. package/script/helpers/runQuery.d.ts +14 -0
  501. package/script/helpers/runQuery.d.ts.map +1 -0
  502. package/script/helpers/runQuery.js +32 -0
  503. package/script/helpers/setDbProps.d.ts +3 -0
  504. package/script/helpers/setDbProps.d.ts.map +1 -0
  505. package/script/helpers/setDbProps.js +28 -0
  506. package/script/helpers/shouldFlipBeforeExport.d.ts +2 -0
  507. package/script/helpers/shouldFlipBeforeExport.d.ts.map +1 -0
  508. package/script/helpers/shouldFlipBeforeExport.js +6 -0
  509. package/script/helpers/stringToArray.d.ts +2 -0
  510. package/script/helpers/stringToArray.d.ts.map +1 -0
  511. package/script/helpers/stringToArray.js +14 -0
  512. package/script/helpers/stringifyDates.d.ts +5 -0
  513. package/script/helpers/stringifyDates.d.ts.map +1 -0
  514. package/script/helpers/stringifyDates.js +17 -0
  515. package/script/helpers/stringifyDatesInvert.d.ts +5 -0
  516. package/script/helpers/stringifyDatesInvert.d.ts.map +1 -0
  517. package/script/helpers/stringifyDatesInvert.js +17 -0
  518. package/script/helpers/unifyColumns.d.ts +9 -0
  519. package/script/helpers/unifyColumns.d.ts.map +1 -0
  520. package/script/helpers/unifyColumns.js +24 -0
  521. package/script/helpers/unnestQuery.d.ts +2 -0
  522. package/script/helpers/unnestQuery.d.ts.map +1 -0
  523. package/script/helpers/unnestQuery.js +11 -0
  524. package/script/helpers/wrapString.d.ts +35 -0
  525. package/script/helpers/wrapString.d.ts.map +1 -0
  526. package/script/helpers/wrapString.js +86 -0
  527. package/script/helpers/writeDataAsArrays.d.ts +3 -0
  528. package/script/helpers/writeDataAsArrays.d.ts.map +1 -0
  529. package/script/helpers/writeDataAsArrays.js +19 -0
  530. package/script/helpers/writeProjectionsAndIndexes.d.ts +3 -0
  531. package/script/helpers/writeProjectionsAndIndexes.d.ts.map +1 -0
  532. package/script/helpers/writeProjectionsAndIndexes.js +32 -0
  533. package/script/index.d.ts +31 -0
  534. package/script/index.d.ts.map +1 -0
  535. package/script/index.js +38 -0
  536. package/script/methods/aggregateGeoQuery.d.ts +5 -0
  537. package/script/methods/aggregateGeoQuery.d.ts.map +1 -0
  538. package/script/methods/aggregateGeoQuery.js +30 -0
  539. package/script/methods/binsQuery.d.ts +5 -0
  540. package/script/methods/binsQuery.d.ts.map +1 -0
  541. package/script/methods/binsQuery.js +43 -0
  542. package/script/methods/bm25.d.ts +17 -0
  543. package/script/methods/bm25.d.ts.map +1 -0
  544. package/script/methods/bm25.js +54 -0
  545. package/script/methods/cache.d.ts +6 -0
  546. package/script/methods/cache.d.ts.map +1 -0
  547. package/script/methods/cache.js +139 -0
  548. package/script/methods/capitalizeQuery.d.ts +2 -0
  549. package/script/methods/capitalizeQuery.d.ts.map +1 -0
  550. package/script/methods/capitalizeQuery.js +11 -0
  551. package/script/methods/cloneColumn.d.ts +4 -0
  552. package/script/methods/cloneColumn.d.ts.map +1 -0
  553. package/script/methods/cloneColumn.js +16 -0
  554. package/script/methods/cloneQuery.d.ts +4 -0
  555. package/script/methods/cloneQuery.d.ts.map +1 -0
  556. package/script/methods/cloneQuery.js +9 -0
  557. package/script/methods/concatenateQuery.d.ts +4 -0
  558. package/script/methods/concatenateQuery.d.ts.map +1 -0
  559. package/script/methods/concatenateQuery.js +16 -0
  560. package/script/methods/convertQuery.d.ts +7 -0
  561. package/script/methods/convertQuery.d.ts.map +1 -0
  562. package/script/methods/convertQuery.js +84 -0
  563. package/script/methods/correlations.d.ts +9 -0
  564. package/script/methods/correlations.d.ts.map +1 -0
  565. package/script/methods/correlations.js +46 -0
  566. package/script/methods/correlationsQuery.d.ts +5 -0
  567. package/script/methods/correlationsQuery.d.ts.map +1 -0
  568. package/script/methods/correlationsQuery.js +32 -0
  569. package/script/methods/createFtsIndex.d.ts +11 -0
  570. package/script/methods/createFtsIndex.d.ts.map +1 -0
  571. package/script/methods/createFtsIndex.js +34 -0
  572. package/script/methods/createVssIndex.d.ts +9 -0
  573. package/script/methods/createVssIndex.d.ts.map +1 -0
  574. package/script/methods/createVssIndex.js +44 -0
  575. package/script/methods/crossJoinQuery.d.ts +4 -0
  576. package/script/methods/crossJoinQuery.d.ts.map +1 -0
  577. package/script/methods/crossJoinQuery.js +6 -0
  578. package/script/methods/distanceQuery.d.ts +6 -0
  579. package/script/methods/distanceQuery.d.ts.map +1 -0
  580. package/script/methods/distanceQuery.js +45 -0
  581. package/script/methods/fill.d.ts +7 -0
  582. package/script/methods/fill.d.ts.map +1 -0
  583. package/script/methods/fill.js +66 -0
  584. package/script/methods/fuzzyClean.d.ts +7 -0
  585. package/script/methods/fuzzyClean.d.ts.map +1 -0
  586. package/script/methods/fuzzyClean.js +200 -0
  587. package/script/methods/fuzzyJoin.d.ts +8 -0
  588. package/script/methods/fuzzyJoin.d.ts.map +1 -0
  589. package/script/methods/fuzzyJoin.js +63 -0
  590. package/script/methods/fuzzyJoinQuery.d.ts +2 -0
  591. package/script/methods/fuzzyJoinQuery.d.ts.map +1 -0
  592. package/script/methods/fuzzyJoinQuery.js +22 -0
  593. package/script/methods/getBottom.d.ts +8 -0
  594. package/script/methods/getBottom.d.ts.map +1 -0
  595. package/script/methods/getBottom.js +28 -0
  596. package/script/methods/getColumns.d.ts +3 -0
  597. package/script/methods/getColumns.d.ts.map +1 -0
  598. package/script/methods/getColumns.js +21 -0
  599. package/script/methods/getDescription.d.ts +9 -0
  600. package/script/methods/getDescription.d.ts.map +1 -0
  601. package/script/methods/getDescription.js +23 -0
  602. package/script/methods/getFirstRow.d.ts +7 -0
  603. package/script/methods/getFirstRow.d.ts.map +1 -0
  604. package/script/methods/getFirstRow.js +21 -0
  605. package/script/methods/getGeoData.d.ts +17 -0
  606. package/script/methods/getGeoData.d.ts.map +1 -0
  607. package/script/methods/getGeoData.js +47 -0
  608. package/script/methods/getLastRow.d.ts +7 -0
  609. package/script/methods/getLastRow.d.ts.map +1 -0
  610. package/script/methods/getLastRow.js +25 -0
  611. package/script/methods/getMax.d.ts +3 -0
  612. package/script/methods/getMax.d.ts.map +1 -0
  613. package/script/methods/getMax.js +24 -0
  614. package/script/methods/getMean.d.ts +5 -0
  615. package/script/methods/getMean.d.ts.map +1 -0
  616. package/script/methods/getMean.js +23 -0
  617. package/script/methods/getMedian.d.ts +5 -0
  618. package/script/methods/getMedian.d.ts.map +1 -0
  619. package/script/methods/getMedian.js +23 -0
  620. package/script/methods/getMin.d.ts +3 -0
  621. package/script/methods/getMin.d.ts.map +1 -0
  622. package/script/methods/getMin.js +24 -0
  623. package/script/methods/getNbCharacters.d.ts +3 -0
  624. package/script/methods/getNbCharacters.d.ts.map +1 -0
  625. package/script/methods/getNbCharacters.js +21 -0
  626. package/script/methods/getNbRows.d.ts +3 -0
  627. package/script/methods/getNbRows.d.ts.map +1 -0
  628. package/script/methods/getNbRows.js +21 -0
  629. package/script/methods/getQuantile.d.ts +5 -0
  630. package/script/methods/getQuantile.d.ts.map +1 -0
  631. package/script/methods/getQuantile.js +23 -0
  632. package/script/methods/getSkew.d.ts +5 -0
  633. package/script/methods/getSkew.d.ts.map +1 -0
  634. package/script/methods/getSkew.js +23 -0
  635. package/script/methods/getStdDev.d.ts +5 -0
  636. package/script/methods/getStdDev.d.ts.map +1 -0
  637. package/script/methods/getStdDev.js +23 -0
  638. package/script/methods/getSum.d.ts +3 -0
  639. package/script/methods/getSum.d.ts.map +1 -0
  640. package/script/methods/getSum.js +21 -0
  641. package/script/methods/getTableNames.d.ts +3 -0
  642. package/script/methods/getTableNames.d.ts.map +1 -0
  643. package/script/methods/getTableNames.js +21 -0
  644. package/script/methods/getTop.d.ts +7 -0
  645. package/script/methods/getTop.d.ts.map +1 -0
  646. package/script/methods/getTop.js +20 -0
  647. package/script/methods/getTypes.d.ts +5 -0
  648. package/script/methods/getTypes.d.ts.map +1 -0
  649. package/script/methods/getTypes.js +19 -0
  650. package/script/methods/getUniques.d.ts +3 -0
  651. package/script/methods/getUniques.d.ts.map +1 -0
  652. package/script/methods/getUniques.js +21 -0
  653. package/script/methods/getValues.d.ts +3 -0
  654. package/script/methods/getValues.d.ts.map +1 -0
  655. package/script/methods/getValues.js +21 -0
  656. package/script/methods/getVar.d.ts +5 -0
  657. package/script/methods/getVar.d.ts.map +1 -0
  658. package/script/methods/getVar.js +23 -0
  659. package/script/methods/insertRowsQuery.d.ts +4 -0
  660. package/script/methods/insertRowsQuery.d.ts.map +1 -0
  661. package/script/methods/insertRowsQuery.js +17 -0
  662. package/script/methods/join.d.ts +7 -0
  663. package/script/methods/join.d.ts.map +1 -0
  664. package/script/methods/join.js +69 -0
  665. package/script/methods/joinGeo.d.ts +10 -0
  666. package/script/methods/joinGeo.d.ts.map +1 -0
  667. package/script/methods/joinGeo.js +82 -0
  668. package/script/methods/joinGeoQuery.d.ts +2 -0
  669. package/script/methods/joinGeoQuery.d.ts.map +1 -0
  670. package/script/methods/joinGeoQuery.js +58 -0
  671. package/script/methods/joinQuery.d.ts +2 -0
  672. package/script/methods/joinQuery.d.ts.map +1 -0
  673. package/script/methods/joinQuery.js +24 -0
  674. package/script/methods/keepQuery.d.ts +4 -0
  675. package/script/methods/keepQuery.d.ts.map +1 -0
  676. package/script/methods/keepQuery.js +21 -0
  677. package/script/methods/linearRegressionQuery.d.ts +5 -0
  678. package/script/methods/linearRegressionQuery.d.ts.map +1 -0
  679. package/script/methods/linearRegressionQuery.js +43 -0
  680. package/script/methods/linearRegressions.d.ts +9 -0
  681. package/script/methods/linearRegressions.d.ts.map +1 -0
  682. package/script/methods/linearRegressions.js +49 -0
  683. package/script/methods/loadArray.d.ts +5 -0
  684. package/script/methods/loadArray.d.ts.map +1 -0
  685. package/script/methods/loadArray.js +84 -0
  686. package/script/methods/loadDataQuery.d.ts +23 -0
  687. package/script/methods/loadDataQuery.d.ts.map +1 -0
  688. package/script/methods/loadDataQuery.js +83 -0
  689. package/script/methods/lowerQuery.d.ts +2 -0
  690. package/script/methods/lowerQuery.d.ts.map +1 -0
  691. package/script/methods/lowerQuery.js +10 -0
  692. package/script/methods/normalizeQuery.d.ts +5 -0
  693. package/script/methods/normalizeQuery.d.ts.map +1 -0
  694. package/script/methods/normalizeQuery.js +28 -0
  695. package/script/methods/normalizeString.d.ts +5 -0
  696. package/script/methods/normalizeString.d.ts.map +1 -0
  697. package/script/methods/normalizeString.js +32 -0
  698. package/script/methods/outliersIQRQuery.d.ts +4 -0
  699. package/script/methods/outliersIQRQuery.d.ts.map +1 -0
  700. package/script/methods/outliersIQRQuery.js +37 -0
  701. package/script/methods/proportionsHorizontalQuery.d.ts +5 -0
  702. package/script/methods/proportionsHorizontalQuery.d.ts.map +1 -0
  703. package/script/methods/proportionsHorizontalQuery.js +18 -0
  704. package/script/methods/proportionsVerticalQuery.d.ts +5 -0
  705. package/script/methods/proportionsVerticalQuery.d.ts.map +1 -0
  706. package/script/methods/proportionsVerticalQuery.js +25 -0
  707. package/script/methods/quantilesQuery.d.ts +4 -0
  708. package/script/methods/quantilesQuery.d.ts.map +1 -0
  709. package/script/methods/quantilesQuery.js +18 -0
  710. package/script/methods/ranksQuery.d.ts +6 -0
  711. package/script/methods/ranksQuery.d.ts.map +1 -0
  712. package/script/methods/ranksQuery.js +18 -0
  713. package/script/methods/removeDuplicatesQuery.d.ts +4 -0
  714. package/script/methods/removeDuplicatesQuery.d.ts.map +1 -0
  715. package/script/methods/removeDuplicatesQuery.js +18 -0
  716. package/script/methods/removeMissing.d.ts +7 -0
  717. package/script/methods/removeMissing.d.ts.map +1 -0
  718. package/script/methods/removeMissing.js +27 -0
  719. package/script/methods/removeMissingQuery.d.ts +7 -0
  720. package/script/methods/removeMissingQuery.d.ts.map +1 -0
  721. package/script/methods/removeMissingQuery.js +46 -0
  722. package/script/methods/removeQuery.d.ts +4 -0
  723. package/script/methods/removeQuery.d.ts.map +1 -0
  724. package/script/methods/removeQuery.js +21 -0
  725. package/script/methods/renameColumnQuery.d.ts +2 -0
  726. package/script/methods/renameColumnQuery.d.ts.map +1 -0
  727. package/script/methods/renameColumnQuery.js +10 -0
  728. package/script/methods/replaceNullsQuery.d.ts +2 -0
  729. package/script/methods/replaceNullsQuery.d.ts.map +1 -0
  730. package/script/methods/replaceNullsQuery.js +16 -0
  731. package/script/methods/replaceQuery.d.ts +5 -0
  732. package/script/methods/replaceQuery.d.ts.map +1 -0
  733. package/script/methods/replaceQuery.js +27 -0
  734. package/script/methods/rollingQuery.d.ts +5 -0
  735. package/script/methods/rollingQuery.d.ts.map +1 -0
  736. package/script/methods/rollingQuery.js +39 -0
  737. package/script/methods/roundQuery.d.ts +5 -0
  738. package/script/methods/roundQuery.d.ts.map +1 -0
  739. package/script/methods/roundQuery.js +19 -0
  740. package/script/methods/selectRowsQuery.d.ts +5 -0
  741. package/script/methods/selectRowsQuery.d.ts.map +1 -0
  742. package/script/methods/selectRowsQuery.js +6 -0
  743. package/script/methods/sortQuery.d.ts +8 -0
  744. package/script/methods/sortQuery.d.ts.map +1 -0
  745. package/script/methods/sortQuery.js +21 -0
  746. package/script/methods/splitSpread.d.ts +5 -0
  747. package/script/methods/splitSpread.d.ts.map +1 -0
  748. package/script/methods/splitSpread.js +67 -0
  749. package/script/methods/summarize.d.ts +13 -0
  750. package/script/methods/summarize.d.ts.map +1 -0
  751. package/script/methods/summarize.js +66 -0
  752. package/script/methods/summarizeQuery.d.ts +7 -0
  753. package/script/methods/summarizeQuery.d.ts.map +1 -0
  754. package/script/methods/summarizeQuery.js +115 -0
  755. package/script/methods/trimQuery.d.ts +5 -0
  756. package/script/methods/trimQuery.d.ts.map +1 -0
  757. package/script/methods/trimQuery.js +32 -0
  758. package/script/methods/truncateQuery.d.ts +2 -0
  759. package/script/methods/truncateQuery.d.ts.map +1 -0
  760. package/script/methods/truncateQuery.js +6 -0
  761. package/script/methods/upperQuery.d.ts +2 -0
  762. package/script/methods/upperQuery.d.ts.map +1 -0
  763. package/script/methods/upperQuery.js +10 -0
  764. package/script/methods/writeDataQuery.d.ts +5 -0
  765. package/script/methods/writeDataQuery.d.ts.map +1 -0
  766. package/script/methods/writeDataQuery.js +50 -0
  767. package/script/methods/writeGeoDataQuery.d.ts +4 -0
  768. package/script/methods/writeGeoDataQuery.d.ts.map +1 -0
  769. package/script/methods/writeGeoDataQuery.js +22 -0
  770. package/script/methods/zScoreQuery.d.ts +5 -0
  771. package/script/methods/zScoreQuery.d.ts.map +1 -0
  772. package/script/methods/zScoreQuery.js +29 -0
  773. package/script/package.json +3 -0
@@ -0,0 +1,4408 @@
1
+ import type SimpleDB from "./SimpleDB.js";
2
+ import Simple from "./Simple.js";
3
+ /**
4
+ * IMPORTANT: When extending this class, always use `this.sdb.newTable()` to
5
+ * create new tables instead of `new SimpleTable(...)` directly. This ensures
6
+ * subclasses that override `tableClass` on their parent `SimpleDB` get their
7
+ * own table type back.
8
+ *
9
+ * Represents a table within a SimpleDB database, capable of handling tabular, geospatial, and vector data.
10
+ * SimpleTable instances are typically created via a SimpleDB instance.
11
+ *
12
+ * @category Main
13
+ * @example
14
+ * ```ts
15
+ * // Create a SimpleDB instance (in-memory by default)
16
+ * const sdb = new SimpleDB();
17
+ *
18
+ * // Create a new table named "employees" within the database
19
+ * const employees = sdb.newTable("employees");
20
+ *
21
+ * // Load data from a CSV file into the "employees" table
22
+ * await employees.loadData("./employees.csv");
23
+ *
24
+ * // Log the first few rows of the "employees" table to the console
25
+ * await employees.logTable();
26
+ *
27
+ * // Close the database connection and free up resources
28
+ * await sdb.done();
29
+ * ```
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * // Handling geospatial data
34
+ * // Create a SimpleDB instance
35
+ * const sdb = new SimpleDB();
36
+ *
37
+ * // Create a new table for geospatial data
38
+ * const boundaries = sdb.newTable("boundaries");
39
+ *
40
+ * // Load geospatial data from a GeoJSON file
41
+ * await boundaries.loadGeoData("./boundaries.geojson");
42
+ *
43
+ * // Close the database connection
44
+ * await sdb.done();
45
+ * ```
46
+ */
47
+ export default class SimpleTable extends Simple {
48
+ /**
49
+ * Name of the table in the database.
50
+ *
51
+ * @category Properties
52
+ */
53
+ name: string;
54
+ /**
55
+ * The projections of the geospatial data, if any.
56
+ *
57
+ * @defaultValue `{}`
58
+ * @category Properties
59
+ */
60
+ projections: {
61
+ [key: string]: string;
62
+ };
63
+ /**
64
+ * The indexes of the table.
65
+ *
66
+ * @defaultValue `[]`
67
+ * @category Properties
68
+ */
69
+ indexes: string[];
70
+ /**
71
+ * The SimpleDB instance that created this table.
72
+ *
73
+ * @category Properties
74
+ */
75
+ sdb: SimpleDB;
76
+ /**
77
+ * Creates an instance of SimpleTable.
78
+ *
79
+ * @param name - The name of the table.
80
+ * @param projections - An object mapping column names to their geospatial projections.
81
+ * @param simpleDB - The SimpleDB instance that this table belongs to.
82
+ * @param options - An optional object with configuration options:
83
+ * @param options.debug - A boolean indicating whether to enable debug mode.
84
+ * @param options.nbRowsToLog - The number of rows to log when displaying table data.
85
+ * @param options.nbCharactersToLog - The maximum number of characters to log for strings. Useful to avoid logging large text content.
86
+ * @param options.types - A boolean indicating whether to include data types when logging a table.
87
+ * @category Constructor
88
+ */
89
+ constructor(name: string, projections: {
90
+ [key: string]: string;
91
+ }, simpleDB: SimpleDB, options?: {
92
+ debug?: boolean;
93
+ nbRowsToLog?: number;
94
+ nbCharactersToLog?: number;
95
+ types?: boolean;
96
+ });
97
+ /**
98
+ * Renames the current table.
99
+ *
100
+ * @param name - The new name for the table.
101
+ * @returns A promise that resolves when the table has been renamed.
102
+ * @category Table Management
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * // Rename the table to "new_employees"
107
+ * await table.renameTable("new_employees");
108
+ * ```
109
+ */
110
+ renameTable(name: string): Promise<void>;
111
+ /**
112
+ * Sets the data types for columns in a new table. If the table already exists, it will be replaced.
113
+ * To convert the types of an existing table, use the `.convert()` method instead.
114
+ *
115
+ * @param types - An object specifying the column names and their target data types (JavaScript or SQL types).
116
+ * @returns A promise that resolves when the types have been set.
117
+ * @category Table Management
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * // Set types for a new table
122
+ * await table.setTypes({
123
+ * name: "string",
124
+ * salary: "integer",
125
+ * raise: "float",
126
+ * });
127
+ * ```
128
+ */
129
+ setTypes(types: {
130
+ [key: string]: "integer" | "float" | "number" | "string" | "date" | "time" | "datetime" | "datetimeTz" | "bigint" | "double" | "varchar" | "timestamp" | "timestamp with time zone" | "boolean" | "geometry";
131
+ }): Promise<void>;
132
+ /**
133
+ * Loads an array of JavaScript objects into the table.
134
+ *
135
+ * @param arrayOfObjects - An array of objects, where each object represents a row and its properties represent columns.
136
+ * @returns A promise that resolves to the SimpleTable instance after the data has been loaded.
137
+ * @category Importing Data
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * // Load data from an array of objects
142
+ * const data = [
143
+ * { letter: "a", number: 1 },
144
+ * { letter: "b", number: 2 }
145
+ * ];
146
+ * await table.loadArray(data);
147
+ * ```
148
+ */
149
+ loadArray(arrayOfObjects: {
150
+ [key: string]: unknown;
151
+ }[]): Promise<this>;
152
+ /**
153
+ * Loads data from one or more local or remote files into the table.
154
+ * Supported file formats include CSV, JSON, Parquet, and Excel.
155
+ *
156
+ * @param files - The path(s) or URL(s) of the file(s) containing the data to be loaded.
157
+ * @param options - An optional object with configuration options:
158
+ * @param options.fileType - The type of file to load ("csv", "dsv", "json", "parquet", "excel"). Defaults to being inferred from the file extension.
159
+ * @param options.autoDetect - A boolean indicating whether to automatically detect the data format. Defaults to `true`.
160
+ * @param options.limit - A number indicating the maximum number of rows to load. Defaults to all rows.
161
+ * @param options.fileName - A boolean indicating whether to include the file name as a new column in the loaded data. Defaults to `false`.
162
+ * @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`.
163
+ * @param options.columnTypes - An object mapping column names to their expected data types. By default, types are inferred.
164
+ * @param options.header - A boolean indicating whether the file has a header row. Applicable to CSV files. Defaults to `true`.
165
+ * @param options.allText - A boolean indicating whether all columns should be treated as text. Applicable to CSV files. Defaults to `false`.
166
+ * @param options.delim - The delimiter used in the file. Applicable to CSV and DSV files. By default, the delimiter is inferred.
167
+ * @param options.skip - The number of lines to skip at the beginning of the file. Applicable to CSV files. Defaults to `0`.
168
+ * @param options.nullPadding - If `true`, when a row has fewer columns than expected, the remaining columns on the right will be padded with `NULL` values. Defaults to `false`.
169
+ * @param options.ignoreErrors - If `true`, parsing errors encountered will be ignored, and rows with errors will be skipped. Defaults to `false`.
170
+ * @param options.compression - The compression type of the file. Applicable to CSV files. Defaults to `none`.
171
+ * @param options.strict - If `true`, an error will be thrown when encountering any issues. If `false`, structurally incorrect files will be parsed tentatively. Defaults to `true`.
172
+ * @param options.encoding - The encoding of the file. Applicable to CSV files. Defaults to `utf-8`.
173
+ * @param options.jsonFormat - The format of JSON files ("unstructured", "newlineDelimited", "array"). By default, the format is inferred.
174
+ * @param options.records - A boolean indicating whether each line in a newline-delimited JSON file represents a record. Applicable to JSON files. By default, it's inferred.
175
+ * @param options.sheet - A string indicating a specific sheet to import from an Excel file. By default, the first sheet is imported.
176
+ * @returns A promise that resolves to the SimpleTable instance after the data has been loaded.
177
+ * @category Importing Data
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * // Load data from a single local CSV file
182
+ * await table.loadData("./some-data.csv");
183
+ * ```
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * // Load data from a remote Parquet file
188
+ * await table.loadData("https://some-website.com/some-data.parquet");
189
+ * ```
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * // Load data from multiple local JSON files
194
+ * await table.loadData([
195
+ * "./some-data1.json",
196
+ * "./some-data2.json",
197
+ * "./some-data3.json"
198
+ * ]);
199
+ * ```
200
+ *
201
+ * @example
202
+ * ```ts
203
+ * // Load data from multiple remote Parquet files with column unification
204
+ * await table.loadData([
205
+ * "https://some-website.com/some-data1.parquet",
206
+ * "https://some-website.com/some-data2.parquet",
207
+ * "https://some-website.com/some-data3.parquet"
208
+ * ], { unifyColumns: true });
209
+ * ```
210
+ */
211
+ loadData(files: string | string[], options?: {
212
+ fileType?: "csv" | "dsv" | "json" | "parquet" | "excel";
213
+ autoDetect?: boolean;
214
+ limit?: number;
215
+ fileName?: boolean;
216
+ unifyColumns?: boolean;
217
+ columnTypes?: {
218
+ [key: string]: string;
219
+ };
220
+ header?: boolean;
221
+ allText?: boolean;
222
+ delim?: string;
223
+ skip?: number;
224
+ nullPadding?: boolean;
225
+ ignoreErrors?: boolean;
226
+ compression?: "none" | "gzip" | "zstd";
227
+ encoding?: string;
228
+ strict?: boolean;
229
+ jsonFormat?: "unstructured" | "newlineDelimited" | "array";
230
+ records?: boolean;
231
+ sheet?: string;
232
+ }): Promise<this>;
233
+ /**
234
+ * Loads data from all supported files (CSV, JSON, Parquet, Excel) within a local directory into the table.
235
+ *
236
+ * @param directory - The absolute path to the directory containing the data files.
237
+ * @param options - An optional object with configuration options:
238
+ * @param options.fileType - The type of file to load ("csv", "dsv", "json", "parquet", "excel"). Defaults to being inferred from the file extension.
239
+ * @param options.autoDetect - A boolean indicating whether to automatically detect the data format. Defaults to `true`.
240
+ * @param options.limit - A number indicating the maximum number of rows to load. Defaults to all rows.
241
+ * @param options.fileName - A boolean indicating whether to include the file name as a new column in the loaded data. Defaults to `false`.
242
+ * @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`.
243
+ * @param options.columnTypes - An object mapping column names to their expected data types. By default, types are inferred.
244
+ * @param options.header - A boolean indicating whether the file has a header row. Applicable to CSV files. Defaults to `true`.
245
+ * @param options.allText - A boolean indicating whether all columns should be treated as text. Applicable to CSV files. Defaults to `false`.
246
+ * @param options.delim - The delimiter used in the file. Applicable to CSV and DSV files. By default, the delimiter is inferred.
247
+ * @param options.skip - The number of lines to skip at the beginning of the file. Applicable to CSV files. Defaults to `0`.
248
+ * @param options.nullPadding - If `true`, when a row has fewer columns than expected, the remaining columns on the right will be padded with `NULL` values. Defaults to `false`.
249
+ * @param options.ignoreErrors - If `true`, parsing errors encountered will be ignored, and rows with errors will be skipped. Defaults to `false`.
250
+ * @param options.compression - The compression type of the file. Applicable to CSV files. Defaults to `none`.
251
+ * @param options.strict - If `true`, an error will be thrown when encountering any issues. If `false`, structurally incorrect files will be parsed tentatively. Defaults to `true`.
252
+ * @param options.encoding - The encoding of the files. Applicable to CSV files. Defaults to `utf-8`.
253
+ * @param options.jsonFormat - The format of JSON files ("unstructured", "newlineDelimited", "array"). By default, the format is inferred.
254
+ * @param options.records - A boolean indicating whether each line in a newline-delimited JSON file represents a record. Applicable to JSON files. By default, it's inferred.
255
+ * @param options.sheet - A string indicating a specific sheet to import from an Excel file. By default, the first sheet is imported.
256
+ * @returns A promise that resolves to the SimpleTable instance after the data has been loaded.
257
+ * @category Importing Data
258
+ *
259
+ * @example
260
+ * ```ts
261
+ * // Load all supported data files from the "./data/" directory
262
+ * await table.loadDataFromDirectory("./data/");
263
+ * ```
264
+ */
265
+ loadDataFromDirectory(directory: string, options?: {
266
+ fileType?: "csv" | "dsv" | "json" | "parquet" | "excel";
267
+ autoDetect?: boolean;
268
+ limit?: number;
269
+ fileName?: boolean;
270
+ unifyColumns?: boolean;
271
+ columnTypes?: {
272
+ [key: string]: string;
273
+ };
274
+ header?: boolean;
275
+ allText?: boolean;
276
+ delim?: string;
277
+ skip?: number;
278
+ nullPadding?: boolean;
279
+ ignoreErrors?: boolean;
280
+ compression?: "none" | "gzip" | "zstd";
281
+ encoding?: "utf-8" | "utf-16" | "latin-1";
282
+ strict?: boolean;
283
+ jsonFormat?: "unstructured" | "newlineDelimited" | "array";
284
+ records?: boolean;
285
+ sheet?: string;
286
+ }): Promise<this>;
287
+ /**
288
+ * Loads geospatial data from an external file or URL into the table.
289
+ * The coordinates of files or URLs ending with `.json` or `.geojson` are automatically flipped to `[latitude, longitude]` axis order.
290
+ *
291
+ * @param file - The URL or absolute path to the external file containing the geospatial data.
292
+ * @param options - An optional object with configuration options:
293
+ * @param options.toWGS84 - If `true`, the method will attempt to reproject the data to WGS84 with `[latitude, longitude]` axis order. If the file is `.json` or `.geojson`, coordinates are automatically flipped, and this option has no additional effect. Defaults to `false`.
294
+ * @param options.from - An optional string specifying the original projection of the data, if the method is unable to detect it automatically.
295
+ * @returns A promise that resolves to the SimpleTable instance after the geospatial data has been loaded.
296
+ * @category Geospatial
297
+ *
298
+ * @example
299
+ * ```ts
300
+ * // Load geospatial data from a URL
301
+ * await table.loadGeoData("https://some-website.com/some-data.geojson");
302
+ * ```
303
+ *
304
+ * @example
305
+ * ```ts
306
+ * // Load geospatial data from a local file
307
+ * await table.loadGeoData("./some-data.geojson");
308
+ * ```
309
+ *
310
+ * @example
311
+ * ```ts
312
+ * // Load geospatial data from a shapefile and reproject to WGS84
313
+ * await table.loadGeoData("./some-data.shp.zip", { toWGS84: true });
314
+ * ```
315
+ */
316
+ loadGeoData(file: string, options?: {
317
+ toWGS84?: boolean;
318
+ from?: string;
319
+ }): Promise<this>;
320
+ /**
321
+ * Creates a full-text search (FTS) index on a specified text column using DuckDB's [FTS extension](https://duckdb.org/docs/stable/core_extensions/full_text_search).
322
+ *
323
+ * If an FTS 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`.
324
+ *
325
+ * @param columnId - The name of the column containing unique identifiers for each row.
326
+ * @param columnText - The name of the column containing the text to index.
327
+ * @param options - An optional object with configuration options:
328
+ * @param options.stemmer - The language stemmer to apply for word normalization. Supports multiple languages or "none" to disable stemming. Defaults to 'porter'.
329
+ * @param options.stopwords - The table containing the stopwords to use for the FTS index. Supports multiple languages or "none" to disable stopwords. Defaults to "english".
330
+ * @param options.overwrite - If `true`, recreates the index even if it already exists. Defaults to `false`.
331
+ * @param options.verbose - If `true`, logs additional debugging information, including index creation status. Defaults to `false`.
332
+ * @returns A promise that resolves to the SimpleTable instance for method chaining.
333
+ * @category Text Search
334
+ *
335
+ * @example
336
+ * ```ts
337
+ * // Load a dataset and create an FTS index
338
+ * await table.loadData("recipes.parquet");
339
+ *
340
+ * // Create FTS index for later searches
341
+ * await table.createFtsIndex("Dish", "Recipe");
342
+ * ```
343
+ *
344
+ * @param columnId - The column containing the document identifiers.
345
+ * @param columnText - The column containing the text to search.
346
+ * @param options - An optional object with configuration options:
347
+ * @param options.stemmer - The stemmer to use for the FTS index. Supports multiple languages or "none" to disable stemming. Defaults to "porter".
348
+ * @param options.stopwords - The table containing the stopwords to use for the FTS index. Supports multiple languages or "none" to disable stopwords. Defaults to "english".
349
+ * @param options.ignore - The regular expression of patterns to be ignored. Defaults to "(\\.|[^a-z])+".
350
+ * @param options.stripAccents - A boolean indicating whether to remove accents. Defaults to true.
351
+ * @param options.lower - A boolean indicating whether to convert all text to lowercase. Defaults to true.
352
+ * @param options.overwrite - A boolean indicating whether to overwrite the existing FTS index. Defaults to false.
353
+ * @param options.verbose - A boolean indicating whether to log additional information. Defaults to false.
354
+ *
355
+ * @example
356
+ * ```ts
357
+ * // Create an index with a specific language stemmer
358
+ * await table.createFtsIndex("Dish", "Recipe", {
359
+ * stemmer: "french",
360
+ * });
361
+ * ```
362
+ *
363
+ * @example
364
+ * ```ts
365
+ * // Recreate an existing index with different settings
366
+ * await table.createFtsIndex("Dish", "Recipe", {
367
+ * stemmer: "english",
368
+ * overwrite: true,
369
+ * });
370
+ * ```
371
+ *
372
+ * @example
373
+ * ```ts
374
+ * // Create index with verbose logging
375
+ * await table.createFtsIndex("Dish", "Recipe", {
376
+ * verbose: true,
377
+ * });
378
+ * // Logs: "Creating FTS index on 'Recipe' column..."
379
+ * // Logs: "FTS index created successfully."
380
+ * ```
381
+ */
382
+ createFtsIndex(columnId: string, columnText: string, options?: {
383
+ stemmer?: "arabic" | "basque" | "catalan" | "danish" | "dutch" | "english" | "finnish" | "french" | "german" | "greek" | "hindi" | "hungarian" | "indonesian" | "irish" | "italian" | "lithuanian" | "nepali" | "norwegian" | "porter" | "portuguese" | "romanian" | "russian" | "serbian" | "spanish" | "swedish" | "tamil" | "turkish" | "none";
384
+ stopwords?: string;
385
+ ignore?: string;
386
+ stripAccents?: boolean;
387
+ lower?: boolean;
388
+ overwrite?: boolean;
389
+ verbose?: boolean;
390
+ }): Promise<this>;
391
+ /**
392
+ * Creates a vector similarity search (VSS) index on a specified column using DuckDB's [VSS extension](https://duckdb.org/docs/stable/extensions/vss).
393
+ *
394
+ * 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`.
395
+ *
396
+ * @param column - The name of the column containing vector embeddings (must be FLOAT array type).
397
+ * @param options - An optional object with configuration options:
398
+ * @param options.overwrite - If `true`, drops and recreates the index even if it already exists. Defaults to `false`.
399
+ * @param options.verbose - If `true`, logs additional debugging information, including index creation status. Defaults to `false`.
400
+ * @param options.efConstruction - The number of candidate vertices to consider during index construction. Higher values result in more accurate indexes but increase build time. Defaults to 128.
401
+ * @param options.efSearch - The number of candidate vertices to consider during search. Higher values result in more accurate searches but increase search time. Defaults to 64.
402
+ * @param options.M - The maximum number of neighbors to keep for each vertex in the graph. Higher values result in more accurate indexes but increase build time and memory usage. Defaults to 16.
403
+ * @returns A promise that resolves to the SimpleTable instance for method chaining.
404
+ * @category Vector Search
405
+ *
406
+ * @example
407
+ * ```ts
408
+ * // Load data that already contains an embedding column
409
+ * await table.loadData("data.csv");
410
+ *
411
+ * // Create VSS index for fast similarity searches
412
+ * await table.createVssIndex("embedding_column");
413
+ * ```
414
+ *
415
+ * @example
416
+ * ```ts
417
+ * // Recreate an existing index
418
+ * await table.createVssIndex("embedding_column", {
419
+ * overwrite: true,
420
+ * });
421
+ * ```
422
+ *
423
+ * @example
424
+ * ```ts
425
+ * // Create index with verbose logging
426
+ * await table.createVssIndex("embedding_column", {
427
+ * verbose: true,
428
+ * });
429
+ * // Logs: "Creating VSS index on 'embedding_column' column..."
430
+ * // Logs: "VSS index created successfully."
431
+ * ```
432
+ *
433
+ * @example
434
+ * ```ts
435
+ * // Create index with custom HNSW parameters for higher accuracy
436
+ * await table.createVssIndex("embedding_column", {
437
+ * efConstruction: 256,
438
+ * efSearch: 128,
439
+ * M: 32,
440
+ * });
441
+ * ```
442
+ */
443
+ createVssIndex(column: string, options?: {
444
+ overwrite?: boolean;
445
+ verbose?: boolean;
446
+ efConstruction?: number;
447
+ efSearch?: number;
448
+ M?: number;
449
+ }): Promise<this>;
450
+ /**
451
+ * Performs BM25 full-text search on a text column to find the most relevant results. BM25 (Best Matching 25) is a ranking function used in information retrieval that calculates relevance scores based on term frequency and document length normalization.
452
+ *
453
+ * This method creates a full-text search index on the specified text column using DuckDB's [FTS extension](https://duckdb.org/docs/stable/core_extensions/full_text_search). If the index already exists, it will be reused unless the `overwriteIndex` option is set to `true`.
454
+ *
455
+ * @param text - The search query text to match against the text column.
456
+ * @param columnId - The name of the column containing unique identifiers for each row.
457
+ * @param columnText - The name of the column containing the text to search.
458
+ * @param nbResults - The number of top-ranked results to return.
459
+ * @param options - An optional object with configuration options:
460
+ * @param options.outputTable - The name of a new table where the results will be stored. If not provided, the current table will be replaced with the search results.
461
+ * @param options.verbose - If `true`, logs additional debugging information, including FTS index creation status. Defaults to `false`.
462
+ * @param options.k - The BM25 k parameter controlling term frequency saturation. Defaults to 1.2.
463
+ * @param options.b - The BM25 b parameter controlling document length normalization (0-1 range). Defaults to 0.75.
464
+ * @param options.stemmer - The language stemmer to apply for word normalization. Supports multiple languages or "none" to disable stemming. Defaults to 'porter'.
465
+ * @param options.stopwords - The table containing the stopwords to use for the FTS index. Supports multiple languages or "none" to disable stopwords. Defaults to "english".
466
+ * @param options.ignore - The regular expression of patterns to be ignored. Defaults to "(\\.|[^a-z])+".
467
+ * @param options.stripAccents - A boolean indicating whether to remove accents. Defaults to true.
468
+ * @param options.lower - A boolean indicating whether to convert all text to lowercase. Defaults to true.
469
+ * @param options.overwriteIndex - If `true`, drops and recreates the FTS index even if it already exists. Defaults to `false`.
470
+ * @param options.conjunctive - If `true`, all terms in the query string must be present in order for a document to be retrieved. Defaults to `false`.
471
+ * @param options.minScore - A threshold to filter out results with a BM25 score below this value.
472
+ * @param options.scoreColumn - If provided, the BM25 score will be included in the output table under this column name.
473
+ * @returns A promise that resolves to a SimpleTable instance containing the search results, ordered by relevance (best matches first).
474
+ * @category Text Search
475
+ *
476
+ * @example
477
+ * ```ts
478
+ * // Load a dataset of recipes
479
+ * await table.loadData("recipes.parquet");
480
+ *
481
+ * // Search for "italian food" in the Recipe column, return top 5 results
482
+ * await table.bm25("italian food", "Dish", "Recipe", 5);
483
+ *
484
+ * // Check the results
485
+ * const dishes = await table.getValues("Dish");
486
+ * // Returns: ["Carbonara", "Pizza", "Risotto", "Tiramisu", "Escarole Soup"]
487
+ * ```
488
+ *
489
+ * @example
490
+ * ```ts
491
+ * // Search with a specific language stemmer
492
+ * await table.bm25("french food", "Dish", "Recipe", 5, {
493
+ * stemmer: "french",
494
+ * });
495
+ * ```
496
+ *
497
+ * @example
498
+ * ```ts
499
+ * // Recreate the index with different settings and perform search
500
+ * await table.bm25("italian food", "Dish", "Recipe", 5, {
501
+ * stemmer: "english",
502
+ * overwriteIndex: true,
503
+ * });
504
+ * ```
505
+ *
506
+ * @example
507
+ * ```ts
508
+ * // Save results to a new table without modifying the original
509
+ * const italianDishes = await table.bm25("italian food", "Dish", "Recipe", 5, {
510
+ * outputTable: "italian_results",
511
+ * });
512
+ *
513
+ * // Original table remains unchanged
514
+ * const allDishes = await table.getValues("Dish");
515
+ * console.log(allDishes.length); // 336 (all dishes)
516
+ *
517
+ * // New table contains only search results
518
+ * const italianOnly = await italianDishes.getValues("Dish");
519
+ * console.log(italianOnly.length); // 5 (top results)
520
+ * ```
521
+ *
522
+ * @example
523
+ * ```ts
524
+ * // Multiple searches reuse the same index for better performance
525
+ * // The first search creates the index
526
+ * const italian = await table.bm25("italian food", "Dish", "Recipe", 5, {
527
+ * outputTable: "italian",
528
+ * });
529
+ *
530
+ * // The second search reuses the existing index, so it's faster
531
+ * const french = await table.bm25("french food", "Dish", "Recipe", 5, {
532
+ * outputTable: "french",
533
+ * });
534
+ * ```
535
+ * * @example
536
+ * ```ts
537
+ * // Filter results by a minimum BM25 score and include the score in the output
538
+ * await table.bm25("spicy noodles", "Dish", "Recipe", 10, {
539
+ * minScore: 5.5,
540
+ * scoreColumn: "bm25_score"
541
+ * });
542
+ * ```
543
+ *
544
+ * @example
545
+ * ```ts
546
+ * // Use the conjunctive option to require all terms
547
+ * await table.bm25("italian sauce", "Dish", "Recipe", 5, {
548
+ * conjunctive: true,
549
+ * });
550
+ * ```
551
+ */
552
+ bm25(text: string, columnId: string, columnText: string, nbResults: number, options?: {
553
+ outputTable?: string;
554
+ verbose?: boolean;
555
+ k?: number;
556
+ b?: number;
557
+ stemmer?: "arabic" | "basque" | "catalan" | "danish" | "dutch" | "english" | "finnish" | "french" | "german" | "greek" | "hindi" | "hungarian" | "indonesian" | "irish" | "italian" | "lithuanian" | "nepali" | "norwegian" | "porter" | "portuguese" | "romanian" | "russian" | "serbian" | "spanish" | "swedish" | "tamil" | "turkish" | "none";
558
+ stopwords?: string;
559
+ ignore?: string;
560
+ stripAccents?: boolean;
561
+ lower?: boolean;
562
+ overwriteIndex?: boolean;
563
+ conjunctive?: boolean;
564
+ minScore?: number;
565
+ scoreColumn?: string;
566
+ }): Promise<this>;
567
+ /**
568
+ * Inserts rows, provided as an array of JavaScript objects, into the table.
569
+ *
570
+ * @param rows - An array of objects, where each object represents a row to be inserted and its properties correspond to column names.
571
+ * @returns A promise that resolves when the rows have been inserted.
572
+ * @category Importing Data
573
+ *
574
+ * @example
575
+ * ```ts
576
+ * // Insert new rows into the table
577
+ * const newRows = [
578
+ * { letter: "c", number: 3 },
579
+ * { letter: "d", number: 4 }
580
+ * ];
581
+ * await table.insertRows(newRows);
582
+ * ```
583
+ */
584
+ insertRows(rows: {
585
+ [key: string]: unknown;
586
+ }[]): Promise<void>;
587
+ /**
588
+ * 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`.
589
+ *
590
+ * @param tablesToInsert - The name(s) of the table(s) or SimpleTable instance(s) from which rows will be inserted.
591
+ * @param options - An optional object with configuration options:
592
+ * @param options.unifyColumns - A boolean indicating whether to unify the columns of the tables. If `true`, missing columns in a table will be filled with `NULL` values. Defaults to `false`.
593
+ * @returns A promise that resolves when the rows have been inserted.
594
+ * @category Importing Data
595
+ *
596
+ * @example
597
+ * ```ts
598
+ * // Insert all rows from 'tableB' into 'tableA'.
599
+ * await tableA.insertTables("tableB");
600
+ * ```
601
+ *
602
+ * @example
603
+ * ```ts
604
+ * // Insert all rows from 'tableB' and 'tableC' into 'tableA'.
605
+ * await tableA.insertTables(["tableB", "tableC"]);
606
+ * ```
607
+ *
608
+ * @example
609
+ * ```ts
610
+ * // Insert rows from multiple tables, unifying columns. Missing columns will be filled with NULL.
611
+ * await tableA.insertTables(["tableB", "tableC"], { unifyColumns: true });
612
+ * ```
613
+ */
614
+ insertTables(tablesToInsert: SimpleTable | SimpleTable[], options?: {
615
+ unifyColumns?: boolean;
616
+ }): Promise<void>;
617
+ /**
618
+ * Returns a new table with the same structure and data as this table. The data can be optionally filtered.
619
+ * Note that cloning large tables can be a slow operation.
620
+ *
621
+ * @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.
622
+ * @param nameOrOptions.outputTable - 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.
623
+ * @param nameOrOptions.conditions - A SQL `WHERE` clause condition to filter the data during cloning. Defaults to no condition (clones all rows).
624
+ * @param nameOrOptions.columns - An array of column names to include in the cloned table. If not provided, all columns will be included.
625
+ * @returns A promise that resolves to a new table instance containing the cloned data.
626
+ * @category Table Management
627
+ *
628
+ * @example
629
+ * ```ts
630
+ * // Clone tableA to a new table with a default generated name (e.g., "table1")
631
+ * const tableB = await tableA.cloneTable();
632
+ * ```
633
+ *
634
+ * @example
635
+ * ```ts
636
+ * // Clone tableA to a new table named "my_cloned_table" using string parameter
637
+ * const tableB = await tableA.cloneTable("my_cloned_table");
638
+ * ```
639
+ *
640
+ * @example
641
+ * ```ts
642
+ * // Clone tableA to a new table named "my_cloned_table" using options object
643
+ * const tableB = await tableA.cloneTable({ outputTable: "my_cloned_table" });
644
+ * ```
645
+ *
646
+ * @example
647
+ * ```ts
648
+ * // Clone tableA, including only rows where 'column1' is greater than 10
649
+ * const tableB = await tableA.cloneTable({ conditions: `column1 > 10` });
650
+ * ```
651
+ *
652
+ * @example
653
+ * ```ts
654
+ * // Clone tableA with only specific columns
655
+ * const tableB = await tableA.cloneTable({ columns: ["name", "age", "city"] });
656
+ * ```
657
+ *
658
+ * @example
659
+ * ```ts
660
+ * // Clone tableA to a specific table name with filtered data and specific columns
661
+ * const tableB = await tableA.cloneTable({
662
+ * outputTable: "filtered_data",
663
+ * conditions: `status = 'active' AND created_date >= '2023-01-01'`,
664
+ * columns: ["name", "status", "created_date"]
665
+ * });
666
+ * ```
667
+ */
668
+ cloneTable(nameOrOptions?: string | {
669
+ outputTable?: string;
670
+ conditions?: string;
671
+ columns?: string | string[];
672
+ }): Promise<this>;
673
+ /**
674
+ * Clones an existing column in this table, creating a new column with identical values.
675
+ *
676
+ * @param originalColumn - The name of the original column to clone.
677
+ * @param newColumn - The name of the new column to be created.
678
+ * @returns A promise that resolves when the column has been cloned.
679
+ * @category Column Operations
680
+ *
681
+ * @example
682
+ * ```ts
683
+ * // Clone 'firstName' column as 'contactName'
684
+ * await table.cloneColumn("firstName", "contactName");
685
+ * ```
686
+ */
687
+ cloneColumn(originalColumn: string, newColumn: string): Promise<void>;
688
+ /**
689
+ * Clones a column in the table and offsets its values by a specified number of rows.
690
+ * This is useful for time-series analysis or comparing values across different time points.
691
+ *
692
+ * **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.
693
+ *
694
+ * @param originalColumn - The name of the original column.
695
+ * @param newColumn - The name of the new column to be created with offset values.
696
+ * @param options - An optional object with configuration options:
697
+ * @param options.offset - The number of rows to offset the values. A positive number shifts values downwards (later rows), a negative number shifts values upwards (earlier rows). Defaults to `1`.
698
+ * @param options.categories - A string or an array of strings representing columns to partition the data by. The offset will be applied independently within each category.
699
+ * @returns A promise that resolves when the column has been cloned with offset values.
700
+ * @category Column Operations
701
+ *
702
+ * @example
703
+ * ```ts
704
+ * // Clone 'value' as 'previous_value', offsetting by 1 row (value of row N-1 goes to row N)
705
+ * await table.cloneColumnWithOffset("value", "previous_value");
706
+ * ```
707
+ *
708
+ * @example
709
+ * ```ts
710
+ * // Clone 'sales' as 'sales_2_days_ago', offsetting by 2 rows
711
+ * await table.cloneColumnWithOffset("sales", "sales_2_days_ago", { offset: 2 });
712
+ * ```
713
+ *
714
+ * @example
715
+ * ```ts
716
+ * // Clone 'temperature' as 'prev_temp_by_city', offsetting by 1 row within each 'city' category
717
+ * await table.cloneColumnWithOffset("temperature", "prev_temp_by_city", {
718
+ * offset: 1,
719
+ * categories: "city",
720
+ * });
721
+ * ```
722
+ *
723
+ * @example
724
+ * ```ts
725
+ * // Clone 'stock_price' as 'prev_price_by_stock_and_exchange', offsetting by 1 row within each 'stock_symbol' and 'exchange' category
726
+ * await table.cloneColumnWithOffset("stock_price", "prev_price_by_stock_and_exchange", {
727
+ * offset: 1,
728
+ * categories: ["stock_symbol", "exchange"],
729
+ * });
730
+ * ```
731
+ */
732
+ cloneColumnWithOffset(originalColumn: string, newColumn: string, options?: {
733
+ offset?: number;
734
+ categories?: string | string[];
735
+ }): Promise<void>;
736
+ /**
737
+ * 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`.
738
+ *
739
+ * @param columns - The column(s) for which to fill `NULL` values.
740
+ * @param options - An optional object with configuration options:
741
+ * @param options.categories - A string or an array of strings representing columns to partition the data by. The fill will be applied independently within each category.
742
+ * @param options.interpolate - If `true`, replaces `NULL` values with linearly interpolated values using DuckDB's `fill()` window function. When `interpolateBy` is not set, row positions are used as the X-axis, treating rows as equidistant. For `NULL` values at the ends, linear extrapolation is used. Both the column values and the X-axis values must support arithmetic. If `false` or omitted, the previous non-`NULL` value is used instead. Automatically assumed `true` when `interpolateBy` is set.
743
+ * @param options.interpolateBy - A column name to use as the X-axis for interpolation instead of equidistant row positions. When provided, `interpolate` is automatically assumed `true`. Use this when rows are not evenly spaced (e.g., timestamps or non-uniform numeric indices) so that interpolated values are proportional to the actual distance between X-axis values.
744
+ * @returns A promise that resolves when the `NULL` values have been filled.
745
+ * @category Updating Data
746
+ *
747
+ * @example
748
+ * ```ts
749
+ * // Fill NULL values in 'column1' with the previous non-NULL value
750
+ * await table.fill("column1");
751
+ * ```
752
+ *
753
+ * @example
754
+ * ```ts
755
+ * // Fill NULL values in multiple columns
756
+ * await table.fill(["columnA", "columnB"]);
757
+ * ```
758
+ *
759
+ * @example
760
+ * ```ts
761
+ * // Fill NULL values in 'value' independently within each 'group'
762
+ * await table.fill("value", { categories: "group" });
763
+ * ```
764
+ *
765
+ * @example
766
+ * ```ts
767
+ * // Fill NULL values in 'value' using linear interpolation
768
+ * await table.fill("value", { interpolate: true });
769
+ * ```
770
+ *
771
+ * @example
772
+ * ```ts
773
+ * // Fill NULL values in 'value' using linear interpolation, independently within each 'group'
774
+ * await table.fill("value", { categories: "group", interpolate: true });
775
+ * ```
776
+ *
777
+ * @example
778
+ * ```ts
779
+ * // Fill NULL values in 'value' using linear interpolation proportional to 'x' distances
780
+ * await table.fill("value", { interpolate: true, interpolateBy: "x" });
781
+ * ```
782
+ *
783
+ * @example
784
+ * ```ts
785
+ * // interpolateBy implies interpolate: true, so this is equivalent to the previous example
786
+ * await table.fill("value", { interpolateBy: "x" });
787
+ * ```
788
+ */
789
+ fill(columns: string | string[], options?: {
790
+ categories?: string | string[];
791
+ interpolate?: boolean;
792
+ interpolateBy?: string;
793
+ }): Promise<void>;
794
+ /**
795
+ * Sorts the rows of the table based on specified column(s) and order(s).
796
+ * If no columns are specified, all columns are sorted from left to right in ascending order.
797
+ *
798
+ * @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.
799
+ * @param options - An optional object with configuration options:
800
+ * @param options.lang - An object mapping column names to language codes for collation (e.g., `{ column1: "fr" }`). See DuckDB Collations documentation for more details: https://duckdb.org/docs/sql/expressions/collations.
801
+ * @returns A promise that resolves when the table has been sorted.
802
+ * @category Restructuring Data
803
+ *
804
+ * @example
805
+ * ```ts
806
+ * // Sort all columns from left to right in ascending order
807
+ * await table.sort();
808
+ * ```
809
+ *
810
+ * @example
811
+ * ```ts
812
+ * // Sort 'column1' in ascending order
813
+ * await table.sort({ column1: "asc" });
814
+ * ```
815
+ *
816
+ * @example
817
+ * ```ts
818
+ * // Sort 'column1' ascendingly, then 'column2' descendingly
819
+ * await table.sort({ column1: "asc", column2: "desc" });
820
+ * ```
821
+ *
822
+ * @example
823
+ * ```ts
824
+ * // Sort 'column1' considering French accents
825
+ * await table.sort({ column1: "asc" }, { lang: { column1: "fr" } });
826
+ * ```
827
+ */
828
+ sort(order?: {
829
+ [key: string]: "asc" | "desc";
830
+ } | null, options?: {
831
+ lang?: {
832
+ [key: string]: string;
833
+ };
834
+ }): Promise<void>;
835
+ /**
836
+ * Selects specific columns in the table, removing all others.
837
+ *
838
+ * @param columns - The name or an array of names of the columns to be selected.
839
+ * @returns A promise that resolves when the columns have been selected.
840
+ * @category Selecting or Filtering Data
841
+ *
842
+ * @example
843
+ * ```ts
844
+ * // Select only the 'firstName' and 'lastName' columns, removing all other columns.
845
+ * await table.selectColumns(["firstName", "lastName"]);
846
+ * ```
847
+ *
848
+ * @example
849
+ * ```ts
850
+ * // Select only the 'productName' column.
851
+ * await table.selectColumns("productName");
852
+ * ```
853
+ */
854
+ selectColumns(columns: string | string[]): Promise<void>;
855
+ /**
856
+ * Skips the first `n` rows of the table, effectively removing them.
857
+ *
858
+ * @param nbRowsToSkip - The number of rows to skip from the beginning of the table.
859
+ * @returns A promise that resolves when the rows have been skipped.
860
+ * @category Selecting or Filtering Data
861
+ *
862
+ * @example
863
+ * ```ts
864
+ * // Skip the first 10 rows of the table
865
+ * await table.skip(10);
866
+ * ```
867
+ */
868
+ skip(nbRowsToSkip: number): Promise<void>;
869
+ /**
870
+ * Checks if a column with the specified name exists in the table.
871
+ *
872
+ * @param column - The name of the column to check.
873
+ * @returns A promise that resolves to `true` if the column exists, `false` otherwise.
874
+ * @category Column Operations
875
+ *
876
+ * @example
877
+ * ```ts
878
+ * // Check if the table has a column named "age"
879
+ * const hasAgeColumn = await table.hasColumn("age");
880
+ * console.log(hasAgeColumn); // Output: true or false
881
+ * ```
882
+ */
883
+ hasColumn(column: string): Promise<boolean>;
884
+ /**
885
+ * Selects random rows from the table, removing all others. You can optionally specify a seed to ensure repeatable sampling.
886
+ *
887
+ * @param quantity - The number of rows to select (e.g., `100`) or a percentage string (e.g., `"10%"`) specifying the sampling size.
888
+ * @param options - An optional object with configuration options:
889
+ * @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.
890
+ * @returns A promise that resolves when the sampling is complete.
891
+ * @category Selecting or Filtering Data
892
+ *
893
+ * @example
894
+ * ```ts
895
+ * // Select 100 random rows from the table
896
+ * await table.sample(100);
897
+ * ```
898
+ *
899
+ * @example
900
+ * ```ts
901
+ * // Select 10% of the rows randomly
902
+ * await table.sample("10%");
903
+ * ```
904
+ *
905
+ * @example
906
+ * ```ts
907
+ * // Select random rows with a specific seed for repeatable results
908
+ * await table.sample("10%", { seed: 123 });
909
+ * ```
910
+ */
911
+ sample(quantity: number | string, options?: {
912
+ seed?: number;
913
+ }): Promise<void>;
914
+ /**
915
+ * 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.
916
+ *
917
+ * @param count - The number of rows to select.
918
+ * @param options - An optional object with configuration options:
919
+ * @param options.offset - The number of rows to skip from the beginning of the table before selecting. Defaults to `0`.
920
+ * @param options.outputTable - If `true`, the selected rows 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 modified. Defaults to `false`.
921
+ * @returns A promise that resolves to a table instance containing the selected rows (either the modified current table or a new table).
922
+ * @category Selecting or Filtering Data
923
+ *
924
+ * @example
925
+ * ```ts
926
+ * // Select the first 100 rows of the current table
927
+ * await table.selectRows(100);
928
+ * ```
929
+ *
930
+ * @example
931
+ * ```ts
932
+ * // Select 100 rows after skipping the first 50 rows
933
+ * await table.selectRows(100, { offset: 50 });
934
+ * ```
935
+ *
936
+ * @example
937
+ * ```ts
938
+ * // Select 50 rows and store them in a new table with a generated name
939
+ * const newTable = await table.selectRows(50, { outputTable: true });
940
+ * ```
941
+ *
942
+ * @example
943
+ * ```ts
944
+ * // Select 75 rows and store them in a new table named "top_customers"
945
+ * const topCustomersTable = await table.selectRows(75, { outputTable: "top_customers" });
946
+ * ```
947
+ */
948
+ selectRows(count: number | string, options?: {
949
+ offset?: number;
950
+ outputTable?: string | boolean;
951
+ }): Promise<this>;
952
+ /**
953
+ * Removes duplicate rows from this table, keeping only unique rows.
954
+ * Note that the resulting data order might differ from the original.
955
+ *
956
+ * @param options - An optional object with configuration options:
957
+ * @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.
958
+ * @returns A promise that resolves when the duplicate rows have been removed.
959
+ * @category Selecting or Filtering Data
960
+ *
961
+ * @example
962
+ * ```ts
963
+ * // Remove duplicate rows based on all columns
964
+ * await table.removeDuplicates();
965
+ * ```
966
+ *
967
+ * @example
968
+ * ```ts
969
+ * // Remove duplicate rows based only on the 'email' column
970
+ * await table.removeDuplicates({ on: "email" });
971
+ * ```
972
+ *
973
+ * @example
974
+ * ```ts
975
+ * // Remove duplicate rows based on 'firstName' and 'lastName' columns
976
+ * await table.removeDuplicates({ on: ["firstName", "lastName"] });
977
+ * ```
978
+ */
979
+ removeDuplicates(options?: {
980
+ on?: string | string[];
981
+ }): Promise<void>;
982
+ /**
983
+ * Removes rows with missing values from this table.
984
+ * By default, missing values include SQL `NULL`, as well as string representations like `"NULL"`, `"null"`, `"NaN"`, `"undefined"`, and empty strings `""`.
985
+ *
986
+ * @param options - An optional object with configuration options:
987
+ * @param options.columns - A string or an array of strings specifying the columns to consider for missing values. If omitted, all columns are considered.
988
+ * @param options.missingValues - An array of values to be treated as missing values instead of the default ones. Defaults to `["undefined", "NaN", "null", "NULL", ""]`.
989
+ * @param options.invert - A boolean indicating whether to invert the condition. If `true`, only rows containing missing values will be kept. Defaults to `false`.
990
+ * @returns A promise that resolves when the rows with missing values have been removed.
991
+ * @category Selecting or Filtering Data
992
+ *
993
+ * @example
994
+ * ```ts
995
+ * // Remove rows with missing values in any column
996
+ * await table.removeMissing();
997
+ * ```
998
+ *
999
+ * @example
1000
+ * ```ts
1001
+ * // Remove rows with missing values only in 'firstName' or 'lastName' columns
1002
+ * await table.removeMissing({ columns: ["firstName", "lastName"] });
1003
+ * ```
1004
+ *
1005
+ * @example
1006
+ * ```ts
1007
+ * // Keep only rows with missing values in any column
1008
+ * await table.removeMissing({ invert: true });
1009
+ * ```
1010
+ *
1011
+ * @example
1012
+ * ```ts
1013
+ * // Remove rows where 'age' is missing or is equal to -1
1014
+ * await table.removeMissing({ columns: "age", missingValues: [-1] });
1015
+ * ```
1016
+ */
1017
+ removeMissing(options?: {
1018
+ columns?: string | string[];
1019
+ missingValues?: (string | number)[];
1020
+ invert?: boolean;
1021
+ }): Promise<void>;
1022
+ /**
1023
+ * Trims specified characters from the beginning, end, or both sides of string values in the given columns.
1024
+ *
1025
+ * @param columns - The column name or an array of column names to trim.
1026
+ * @param options - An optional object with configuration options:
1027
+ * @param options.character - The string to trim. Defaults to whitespace characters.
1028
+ * @param options.method - The trimming method to apply: `"leftTrim"` (removes from the beginning), `"rightTrim"` (removes from the end), or `"trim"` (removes from both sides). Defaults to `"trim"`.
1029
+ * @returns A promise that resolves when the trimming operation is complete.
1030
+ * @category Updating Data
1031
+ *
1032
+ * @example
1033
+ * ```ts
1034
+ * // Trim whitespace from 'column1'
1035
+ * await table.trim("column1");
1036
+ * ```
1037
+ *
1038
+ * @example
1039
+ * ```ts
1040
+ * // Trim leading and trailing asterisks from 'productCode'
1041
+ * await table.trim("productCode", { character: "*" });
1042
+ * ```
1043
+ *
1044
+ * @example
1045
+ * ```ts
1046
+ * // Right-trim whitespace from 'description' and 'notes' columns
1047
+ * await table.trim(["description", "notes"], { method: "rightTrim" });
1048
+ * ```
1049
+ */
1050
+ trim(columns: string | string[], options?: {
1051
+ character?: string;
1052
+ method?: "leftTrim" | "rightTrim" | "trim";
1053
+ }): Promise<void>;
1054
+ /**
1055
+ * Filters rows from this table based on SQL conditions. Note that it's often faster to use the `removeRows` method for simple removals.
1056
+ * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
1057
+ *
1058
+ * @param conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"column1 > 10 AND column2 = 'value'"`).
1059
+ * @returns A promise that resolves when the rows have been filtered.
1060
+ * @category Selecting or Filtering Data
1061
+ *
1062
+ * @example
1063
+ * ```ts
1064
+ * // Keep only rows where the 'fruit' column is not 'apple'
1065
+ * await table.filter(`fruit != 'apple'`);
1066
+ * ```
1067
+ *
1068
+ * @example
1069
+ * ```ts
1070
+ * // Keep rows where 'price' is greater than 100 AND 'quantity' is greater than 0
1071
+ * await table.filter(`price > 100 && quantity > 0`); // Using JS syntax
1072
+ * ```
1073
+ *
1074
+ * @example
1075
+ * ```ts
1076
+ * // Keep rows where 'category' is 'Electronics' OR 'Appliances'
1077
+ * await table.filter(`category === 'Electronics' || category === 'Appliances'`); // Using JS syntax
1078
+ * ```
1079
+ *
1080
+ * @example
1081
+ * ```ts
1082
+ * // Keep rows where 'lastPurchaseDate' is on or after '2023-01-01'
1083
+ * await table.filter(`lastPurchaseDate >= '2023-01-01'`);
1084
+ * ```
1085
+ */
1086
+ filter(conditions: string): Promise<void>;
1087
+ /**
1088
+ * Keeps rows in this table that have specific values in specified columns, removing all other rows.
1089
+ *
1090
+ * @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.
1091
+ * @returns A promise that resolves when the rows have been filtered.
1092
+ * @category Selecting or Filtering Data
1093
+ *
1094
+ * @example
1095
+ * ```ts
1096
+ * // Keep only rows where 'job' is 'accountant' or 'developer', AND 'city' is 'Montreal'
1097
+ * await table.keep({ job: ["accountant", "developer"], city: "Montreal" });
1098
+ * ```
1099
+ *
1100
+ * @example
1101
+ * ```ts
1102
+ * // Keep only rows where 'status' is 'active'
1103
+ * await table.keep({ status: "active" });
1104
+ * ```
1105
+ */
1106
+ keep(columnsAndValues: {
1107
+ [key: string]: (number | string | Date | boolean | null)[] | (number | string | Date | boolean | null);
1108
+ }): Promise<void>;
1109
+ /**
1110
+ * Removes rows from this table that have specific values in specified columns.
1111
+ *
1112
+ * @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.
1113
+ * @returns A promise that resolves when the rows have been removed.
1114
+ * @category Selecting or Filtering Data
1115
+ *
1116
+ * @example
1117
+ * ```ts
1118
+ * // Remove rows where 'job' is 'accountant' or 'developer', AND 'city' is 'Montreal'
1119
+ * await table.remove({ job: ["accountant", "developer"], city: "Montreal" });
1120
+ * ```
1121
+ *
1122
+ * @example
1123
+ * ```ts
1124
+ * // Remove rows where 'status' is 'inactive'
1125
+ * await table.remove({ status: "inactive" });
1126
+ * ```
1127
+ */
1128
+ remove(columnsAndValues: {
1129
+ [key: string]: (number | string | Date | boolean | null)[] | (number | string | Date | boolean | null);
1130
+ }): Promise<void>;
1131
+ /**
1132
+ * Removes rows from this table based on SQL conditions. This method is similar to `filter()`, but removes rows instead of keeping them.
1133
+ * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
1134
+ *
1135
+ * @param conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"fruit = 'apple'"`).
1136
+ * @returns A promise that resolves when the rows have been removed.
1137
+ * @category Selecting or Filtering Data
1138
+ *
1139
+ * @example
1140
+ * ```ts
1141
+ * // Remove rows where the 'fruit' column is 'apple'
1142
+ * await table.removeRows(`fruit = 'apple'`);
1143
+ * ```
1144
+ *
1145
+ * @example
1146
+ * ```ts
1147
+ * // Remove rows where 'quantity' is less than 5
1148
+ * await table.removeRows(`quantity < 5`);
1149
+ * ```
1150
+ *
1151
+ * @example
1152
+ * ```ts
1153
+ * // Remove rows where 'price' is less than 100 AND 'quantity' is 0
1154
+ * await table.removeRows(`price < 100 && quantity === 0`); // Using JS syntax
1155
+ * ```
1156
+ *
1157
+ * @example
1158
+ * ```ts
1159
+ * // Remove rows where 'category' is 'Electronics' OR 'Appliances'
1160
+ * await table.removeRows(`category === 'Electronics' || category === 'Appliances'`); // Using JS syntax
1161
+ * ```
1162
+ */
1163
+ removeRows(conditions: string): Promise<void>;
1164
+ /**
1165
+ * Renames one or more columns in the table.
1166
+ *
1167
+ * @param names - An object mapping old column names to their new column names (e.g., `{ "oldName": "newName", "anotherOld": "anotherNew" }`).
1168
+ * @returns A promise that resolves when the columns have been renamed.
1169
+ * @category Column Operations
1170
+ *
1171
+ * @example
1172
+ * ```ts
1173
+ * // Rename "How old?" to "age" and "Man or woman?" to "sex"
1174
+ * await table.renameColumns({ "How old?": "age", "Man or woman?": "sex" });
1175
+ * ```
1176
+ *
1177
+ * @example
1178
+ * ```ts
1179
+ * // Rename a single column
1180
+ * await table.renameColumns({ "product_id": "productId" });
1181
+ * ```
1182
+ */
1183
+ renameColumns(names: {
1184
+ [key: string]: string;
1185
+ }): Promise<void>;
1186
+ /**
1187
+ * Cleans column names by removing non-alphanumeric characters and formatting them to camel case.
1188
+ *
1189
+ * @returns A promise that resolves when the column names have been cleaned.
1190
+ * @category Column Operations
1191
+ *
1192
+ * @example
1193
+ * ```ts
1194
+ * // Clean all column names in the table
1195
+ * // e.g., "First Name" becomes "firstName", "Product ID" becomes "productId"
1196
+ * await table.cleanColumnNames();
1197
+ * ```
1198
+ */
1199
+ cleanColumnNames(): Promise<void>;
1200
+ /**
1201
+ * Restructures this table by stacking (unpivoting) columns. This is useful for tidying up data from a wide format to a long format.
1202
+ *
1203
+ * For example, given a table showing employee counts per department per year:
1204
+ *
1205
+ * | Department | 2021 | 2022 | 2023 |
1206
+ * | :--------- | :--- | :--- | :--- |
1207
+ * | Accounting | 10 | 9 | 15 |
1208
+ * | Sales | 52 | 75 | 98 |
1209
+ *
1210
+ * We can restructure it by putting all year columns into a new column named `Year` and their corresponding employee counts into a new column named `Employees`.
1211
+ *
1212
+ * @example
1213
+ * ```ts
1214
+ * // Restructure the table by stacking year columns into 'year' and 'employees'
1215
+ * await table.longer(["2021", "2022", "2023"], "year", "employees");
1216
+ * ```
1217
+ *
1218
+ * The table will then look like this:
1219
+ *
1220
+ * | Department | Year | Employees |
1221
+ * | :--------- | :--- | :-------- |
1222
+ * | Accounting | 2021 | 10 |
1223
+ * | Accounting | 2022 | 9 |
1224
+ * | Accounting | 2023 | 15 |
1225
+ * | Sales | 2021 | 52 |
1226
+ * | Sales | 2022 | 75 |
1227
+ * | Sales | 2023 | 98 |
1228
+ *
1229
+ * @param columns - An array of strings representing the names of the columns to be stacked (unpivoted).
1230
+ * @param columnsTo - The name of the new column that will contain the original column names (e.g., "Year").
1231
+ * @param valuesTo - The name of the new column that will contain the values from the stacked columns (e.g., "Employees").
1232
+ * @returns A promise that resolves when the table has been restructured.
1233
+ * @category Restructuring Data
1234
+ */
1235
+ longer(columns: string[], columnsTo: string, valuesTo: string): Promise<void>;
1236
+ /**
1237
+ * Restructures this table by unstacking (pivoting) values, transforming data from a long format to a wide format.
1238
+ *
1239
+ * For example, given a table showing employee counts per department per year:
1240
+ *
1241
+ * | Department | Year | Employees |
1242
+ * | :--------- | :--- | :-------- |
1243
+ * | Accounting | 2021 | 10 |
1244
+ * | Accounting | 2022 | 9 |
1245
+ * | Accounting | 2023 | 15 |
1246
+ * | Sales | 2021 | 52 |
1247
+ * | Sales | 2022 | 75 |
1248
+ * | Sales | 2023 | 98 |
1249
+ *
1250
+ * We can restructure it by creating new columns for each year, with the associated employee counts as values.
1251
+ *
1252
+ * @example
1253
+ * ```ts
1254
+ * // Restructure the table by pivoting 'Year' into new columns with 'Employees' as values
1255
+ * await table.wider("Year", "Employees");
1256
+ * ```
1257
+ *
1258
+ * The table will then look like this:
1259
+ *
1260
+ * | Department | 2021 | 2022 | 2023 |
1261
+ * | :--------- | :--- | :--- | :--- |
1262
+ * | Accounting | 10 | 9 | 15 |
1263
+ * | Sales | 52 | 75 | 98 |
1264
+ *
1265
+ * @param columnsFrom - The name of the column containing the values that will be transformed into new column headers (e.g., "Year").
1266
+ * @param valuesFrom - The name of the column containing the values to be spread across the new columns (e.g., "Employees").
1267
+ * @returns A promise that resolves when the table has been restructured.
1268
+ * @category Restructuring Data
1269
+ */
1270
+ wider(columnsFrom: string, valuesFrom: string): Promise<void>;
1271
+ /**
1272
+ * Converts data types of specified columns to target types (JavaScript or SQL types).
1273
+ *
1274
+ * When converting timestamps, dates, or times to/from strings, you must provide a `datetimeFormat` option using [DuckDB's format specifiers](https://duckdb.org/docs/sql/functions/dateformat).
1275
+ *
1276
+ * When converting timestamps, dates, or times to/from numbers, the numerical representation will be in milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).
1277
+ *
1278
+ * When converting strings to numbers, commas (often used as thousand separators) will be automatically removed before conversion.
1279
+ *
1280
+ * @param types - An object mapping column names to their target data types for conversion.
1281
+ * @param options - An optional object with configuration options:
1282
+ * @param options.try - If `true`, values that cannot be converted will be replaced by `NULL` instead of throwing an error. Defaults to `false`.
1283
+ * @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).
1284
+ * @returns A promise that resolves when the column types have been converted.
1285
+ * @category Updating Data
1286
+ *
1287
+ * @example
1288
+ * ```ts
1289
+ * // Convert 'column1' to string and 'column2' to integer (JavaScript types)
1290
+ * await table.convert({ column1: "string", column2: "integer" });
1291
+ * ```
1292
+ *
1293
+ * @example
1294
+ * ```ts
1295
+ * // Convert 'column1' to VARCHAR and 'column2' to BIGINT (SQL types)
1296
+ * await table.convert({ column1: "varchar", column2: "bigint" });
1297
+ * ```
1298
+ *
1299
+ * @example
1300
+ * ```ts
1301
+ * // Convert strings in 'column3' to datetime using a specific format
1302
+ * await table.convert({ column3: "datetime" }, { datetimeFormat: "%Y-%m-%d" });
1303
+ * ```
1304
+ *
1305
+ * @example
1306
+ * ```ts
1307
+ * // Convert datetime values in 'column3' to strings using a specific format
1308
+ * await table.convert({ column3: "string" }, { datetimeFormat: "%Y-%m-%d %H:%M:%S" });
1309
+ * ```
1310
+ *
1311
+ * @example
1312
+ * ```ts
1313
+ * // Convert 'amount' to float, replacing unconvertible values with NULL
1314
+ * await table.convert({ amount: "float" }, { try: true });
1315
+ * ```
1316
+ */
1317
+ convert(types: {
1318
+ [key: string]: "integer" | "float" | "number" | "string" | "date" | "time" | "datetime" | "datetimeTz" | "bigint" | "double" | "varchar" | "timestamp" | "timestamp with time zone" | "boolean";
1319
+ }, options?: {
1320
+ try?: boolean;
1321
+ datetimeFormat?: string;
1322
+ }): Promise<void>;
1323
+ /**
1324
+ * Removes the table from the database. After this operation, invoking methods on this SimpleTable instance will result in an error.
1325
+ *
1326
+ * @returns A promise that resolves when the table has been removed.
1327
+ * @category Table Management
1328
+ *
1329
+ * @example
1330
+ * ```ts
1331
+ * // Remove the current table from the database
1332
+ * await table.removeTable();
1333
+ * ```
1334
+ */
1335
+ removeTable(): Promise<void>;
1336
+ /**
1337
+ * Removes one or more columns from this table.
1338
+ *
1339
+ * @param columns - The name or an array of names of the columns to be removed.
1340
+ * @returns A promise that resolves when the columns have been removed.
1341
+ * @category Column Operations
1342
+ *
1343
+ * @example
1344
+ * ```ts
1345
+ * // Remove 'column1' and 'column2' from the table
1346
+ * await table.removeColumns(["column1", "column2"]);
1347
+ * ```
1348
+ *
1349
+ * @example
1350
+ * ```ts
1351
+ * // Remove a single column named 'tempColumn'
1352
+ * await table.removeColumns("tempColumn");
1353
+ * ```
1354
+ */
1355
+ removeColumns(columns: string | string[]): Promise<void>;
1356
+ /**
1357
+ * Adds a new column to the table based on a specified data type (JavaScript or SQL types) and a SQL definition.
1358
+ *
1359
+ * @param newColumn - The name of the new column to be added.
1360
+ * @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"`).
1361
+ * @param definition - A SQL expression defining how the values for the new column should be computed (e.g., `"column1 + column2"`, `"ST_Centroid(geom_column)"`).
1362
+ * @param options - An optional object with configuration options:
1363
+ * @param options.projection - Required if the new column stores geometries. Specifies the geospatial projection of the new geometry column. You can reuse the projection of an existing geometry column (available in `table.projections`).
1364
+ * @returns A promise that resolves when the new column has been added.
1365
+ * @category Column Operations
1366
+ *
1367
+ * @example
1368
+ * ```ts
1369
+ * // Add a new column 'total' as a float, calculated from 'column1' and 'column2'
1370
+ * await table.addColumn("total", "float", "column1 + column2");
1371
+ * ```
1372
+ *
1373
+ * @example
1374
+ * ```ts
1375
+ * // Add a new geometry column 'centroid' using the centroid of an existing 'country' geometry column
1376
+ * // The projection of the new 'centroid' column is set to be the same as 'country'.
1377
+ * await table.addColumn("centroid", "geometry", `ST_Centroid("country")`, {
1378
+ * projection: table.projections.country,
1379
+ * });
1380
+ * ```
1381
+ */
1382
+ addColumn(newColumn: string, type: "integer" | "float" | "number" | "string" | "date" | "time" | "datetime" | "datetimeTz" | "bigint" | "double" | "varchar" | "timestamp" | "timestamp with time zone" | "boolean" | "geometry", definition: string, options?: {
1383
+ projection?: string;
1384
+ }): Promise<void>;
1385
+ /**
1386
+ * Adds a new column to the table containing the row number.
1387
+ *
1388
+ * @param newColumn - The name of the new column that will store the row number.
1389
+ * @returns A promise that resolves when the row number column has been added.
1390
+ * @category Column Operations
1391
+ *
1392
+ * @example
1393
+ * ```ts
1394
+ * // Add a new column named 'rowNumber' with the row number for each row
1395
+ * await table.addRowNumber("rowNumber");
1396
+ * ```
1397
+ */
1398
+ addRowNumber(newColumn: string): Promise<void>;
1399
+ /**
1400
+ * 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.
1401
+ * This means that if the left table has `n` rows and the right table has `m` rows, the result will have `n * m` rows.
1402
+ *
1403
+ * @param rightTable - The SimpleTable instance to cross join with.
1404
+ * @param options - An optional object with configuration options:
1405
+ * @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`.
1406
+ * @returns A promise that resolves to a table instance containing the cross-joined data (either the modified current table or a new table).
1407
+ * @category Table Operations
1408
+ *
1409
+ * @example
1410
+ * ```ts
1411
+ * // Perform a cross join with 'tableB', overwriting the current table (tableA)
1412
+ * await tableA.crossJoin(tableB);
1413
+ * ```
1414
+ *
1415
+ * @example
1416
+ * ```ts
1417
+ * // Perform a cross join with 'tableB' and store the results in a new table with a generated name
1418
+ * const tableC = await tableA.crossJoin(tableB, { outputTable: true });
1419
+ * ```
1420
+ *
1421
+ * @example
1422
+ * ```ts
1423
+ * // Perform a cross join with 'tableB' and store the results in a new table named 'tableC'
1424
+ * const tableC = await tableA.crossJoin(tableB, { outputTable: "tableC" });
1425
+ * ```
1426
+ */
1427
+ crossJoin(rightTable: SimpleTable, options?: {
1428
+ outputTable?: string | boolean;
1429
+ }): Promise<this>;
1430
+ /**
1431
+ * Merges the data of this table (considered the left table) with another table (the right table) based on a common column or multiple columns.
1432
+ * Note that the order of rows in the returned data is not guaranteed to be the same as in the original tables.
1433
+ * This operation might create temporary files in a `.tmp` folder; consider adding `.tmp` to your `.gitignore`.
1434
+ *
1435
+ * @param rightTable - The SimpleTable instance to be joined with this table.
1436
+ * @param options - An optional object with configuration options:
1437
+ * @param options.commonColumn - The common column(s) used for the join operation. If omitted, the method automatically searches for a column name that exists in both tables. Can be a single string or an array of strings for multiple join keys.
1438
+ * @param options.type - The type of join operation to perform. Possible values are `"inner"`, `"left"` (default), `"right"`, or `"full"`.
1439
+ * @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`.
1440
+ * @returns A promise that resolves to a table instance containing the joined data (either the modified current table or a new table).
1441
+ * @category Table Operations
1442
+ *
1443
+ * @example
1444
+ * ```ts
1445
+ * // Perform a left join with 'tableB' on a common column (auto-detected), overwriting tableA
1446
+ * await tableA.join(tableB);
1447
+ * ```
1448
+ *
1449
+ * @example
1450
+ * ```ts
1451
+ * // Perform an inner join with 'tableB' on the 'id' column, storing results in a new table named 'tableC'
1452
+ * const tableC = await tableA.join(tableB, { commonColumn: 'id', type: 'inner', outputTable: "tableC" });
1453
+ * ```
1454
+ *
1455
+ * @example
1456
+ * ```ts
1457
+ * // Perform a join on multiple columns ('name' and 'category')
1458
+ * await tableA.join(tableB, { commonColumn: ['name', 'category'] });
1459
+ * ```
1460
+ */
1461
+ join(rightTable: SimpleTable, options?: {
1462
+ commonColumn?: string | string[];
1463
+ type?: "inner" | "left" | "right" | "full";
1464
+ outputTable?: string | boolean;
1465
+ }): Promise<this>;
1466
+ /**
1467
+ * Performs a fuzzy left join between this table (considered the left table) and another table
1468
+ * (the right table) based on string similarity between two text columns. Uses the
1469
+ * [rapidfuzz](https://query.farm/duckdb_extension_rapidfuzz) DuckDB community extension.
1470
+ *
1471
+ * If a similarity score column is added to the results, the rows will be ordered alphabetically by the left column, and then by descending similarity score within each group of identical left column values. Otherwise, the rows will be order alphabetically by the left column and then by the right column.
1472
+ *
1473
+ * This operation might create temporary files in a `.tmp` folder; consider adding `.tmp` to your `.gitignore`.
1474
+ *
1475
+ * @param rightTable - The SimpleTable instance to be joined with this table.
1476
+ * @param leftColumn - The name of the column in this (left) table containing the text to compare.
1477
+ * @param rightColumn - The name of the column in the right table containing the text to compare.
1478
+ * @param options - An optional object with configuration options:
1479
+ * @param options.method - The rapidfuzz similarity algorithm to use. Defaults to `"ratio"`.
1480
+ * - `"ratio"`: Overall similarity (Levenshtein-based).
1481
+ * - `"partial_ratio"`: Best partial/substring similarity.
1482
+ * - `"token_sort_ratio"`: Similarity after sorting tokens (words), useful for reordered words.
1483
+ * - `"token_set_ratio"`: Similarity based on sets of tokens, ignoring duplicates and word order.
1484
+ * @param options.threshold - The minimum similarity score (0–100) required for two rows to be joined. Defaults to `80`.
1485
+ * @param options.similarityColumn - If provided, a column with this name is added to the result containing the similarity score (0–100). If omitted, the score is not included in the output.
1486
+ * @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`.
1487
+ * @returns A promise that resolves to a table instance containing the fuzzy-joined data (either the modified current table or a new table).
1488
+ * @category Table Operations
1489
+ *
1490
+ * @example
1491
+ * ```ts
1492
+ * // Fuzzy left join tableA with tableB on 'name' (left) and 'standardName' (right) (ratio >= 80)
1493
+ * await tableA.fuzzyJoin(tableB, "name", "standardName");
1494
+ * ```
1495
+ *
1496
+ * @example
1497
+ * ```ts
1498
+ * // Fuzzy join with a custom threshold and method, storing results in a new table
1499
+ * const tableC = await tableA.fuzzyJoin(tableB, "name", "standardName", {
1500
+ * method: "token_sort_ratio",
1501
+ * threshold: 90,
1502
+ * outputTable: "tableC",
1503
+ * });
1504
+ * ```
1505
+ *
1506
+ * @example
1507
+ * ```ts
1508
+ * // Fuzzy join with a custom similarity column name
1509
+ * await tableA.fuzzyJoin(tableB, "name", "standardName", {
1510
+ * similarityColumn: "matchScore",
1511
+ * });
1512
+ * ```
1513
+ */
1514
+ fuzzyJoin(rightTable: SimpleTable, leftColumn: string, rightColumn: string, options?: {
1515
+ method?: "ratio" | "partial_ratio" | "token_sort_ratio" | "token_set_ratio";
1516
+ threshold?: number;
1517
+ similarityColumn?: string;
1518
+ outputTable?: string | boolean;
1519
+ }): Promise<this>;
1520
+ /**
1521
+ * Normalizes string values in a column by detecting fuzzy duplicates and replacing them with a single canonical value.
1522
+ *
1523
+ * Similar strings are grouped into clusters. Matching is transitive: if `"New York"` is similar to `"New Yorke"` and
1524
+ * `"New Yorke"` is similar to `"New Yorkk"`, all three land in the same cluster even if `"New York"` and `"New Yorkk"`
1525
+ * would not match directly. Each cluster is then collapsed to one representative value based on the `keep` strategy.
1526
+ *
1527
+ * Similarity is computed using the [rapidfuzz](https://query.farm/duckdb_extension_rapidfuzz) DuckDB community extension,
1528
+ * which is installed and loaded automatically.
1529
+ *
1530
+ * @param column - The name of the column containing the strings to normalize.
1531
+ * @param newColumn - The name of the column to write the normalized values to. Use the same name as `column` to normalize in-place.
1532
+ * @param options - An optional object with configuration options:
1533
+ * @param options.method - The rapidfuzz similarity algorithm to use. Defaults to `"ratio"`.
1534
+ * - `"ratio"`: Overall similarity.
1535
+ * - `"partial_ratio"`: Best partial/substring similarity.
1536
+ * - `"token_sort_ratio"`: Similarity after sorting tokens (words), useful for reordered words.
1537
+ * - `"token_set_ratio"`: Similarity based on sets of tokens, ignoring duplicates and word order.
1538
+ * @param options.threshold - The minimum similarity score (0–100) for two strings to be considered duplicates. Defaults to `80`.
1539
+ * @param options.keep - The strategy for choosing the canonical value within each cluster of similar strings. Defaults to `"mostCommon"`.
1540
+ * - `"mostCommon"`: Keep the value that appears most frequently in the original column.
1541
+ * - `"longestString"`: Keep the longest string in the cluster.
1542
+ * - `"shortestString"`: Keep the shortest string in the cluster.
1543
+ * - `"mostCentral"`: Keep the string with the highest total similarity score to all other cluster members (the most "central" string).
1544
+ * - `"maxScore"`: Keep the string that participates in the single highest-scoring pairwise match within the cluster.
1545
+ * @returns A promise that resolves when the column has been normalized.
1546
+ * @category Updating Data
1547
+ *
1548
+ * @example
1549
+ * ```ts
1550
+ * // Normalize 'city' into a new 'cityClean' column, keeping the most common string per cluster
1551
+ * await table.fuzzyClean("city", "cityClean");
1552
+ * ```
1553
+ *
1554
+ * @example
1555
+ * ```ts
1556
+ * // Normalize 'companyName' into a new column using token_sort_ratio and a stricter threshold
1557
+ * await table.fuzzyClean("companyName", "companyNameClean", { method: "token_sort_ratio", threshold: 90 });
1558
+ * ```
1559
+ *
1560
+ * @example
1561
+ * ```ts
1562
+ * // Normalize 'category' in-place, keeping the longest string in each cluster
1563
+ * await table.fuzzyClean("category", "category", { keep: "longestString" });
1564
+ * ```
1565
+ */
1566
+ fuzzyClean(column: string, newColumn: string, options?: {
1567
+ method?: "ratio" | "partial_ratio" | "token_sort_ratio" | "token_set_ratio";
1568
+ threshold?: number;
1569
+ keep?: "mostCommon" | "longestString" | "shortestString" | "mostCentral" | "maxScore";
1570
+ }): Promise<void>;
1571
+ /**
1572
+ * Replaces specified strings in the selected columns.
1573
+ *
1574
+ * @param columns - The column name or an array of column names where string replacements will occur.
1575
+ * @param strings - An object mapping old strings to new strings (e.g., `{ "oldValue": "newValue" }`).
1576
+ * @param options - An optional object with configuration options:
1577
+ * @param options.entireString - A boolean indicating whether the entire cell content must match the `oldString` for replacement to occur. Defaults to `false` (replaces substrings).
1578
+ * @param options.regex - A boolean indicating whether the `oldString` should be treated as a regular expression for global replacement. Cannot be used with `entireString: true`. Defaults to `false`.
1579
+ * @returns A promise that resolves when the string replacements are complete.
1580
+ * @category Updating Data
1581
+ *
1582
+ * @example
1583
+ * ```ts
1584
+ * // Replace all occurrences of "kilograms" with "kg" in 'column1'
1585
+ * await table.replace("column1", { "kilograms": "kg" });
1586
+ * ```
1587
+ *
1588
+ * @example
1589
+ * ```ts
1590
+ * // Replace "kilograms" with "kg" and "liters" with "l" in 'column1' and 'column2'
1591
+ * await table.replace(["column1", "column2"], { "kilograms": "kg", "liters": "l" });
1592
+ * ```
1593
+ *
1594
+ * @example
1595
+ * ```ts
1596
+ * // Replace only if the entire string in 'column1' is "kilograms"
1597
+ * await table.replace("column1", { "kilograms": "kg" }, { entireString: true });
1598
+ * ```
1599
+ *
1600
+ * @example
1601
+ * ```ts
1602
+ * // Replace any sequence of one or more digits with a hyphen in 'column1' using regex
1603
+ * await table.replace("column1", { "\d+": "-" }, { regex: true });
1604
+ * ```
1605
+ */
1606
+ replace(columns: string | string[], strings: {
1607
+ [key: string]: string;
1608
+ }, options?: {
1609
+ entireString?: boolean;
1610
+ regex?: boolean;
1611
+ }): Promise<void>;
1612
+ /**
1613
+ * Converts string values in the specified columns to lowercase.
1614
+ *
1615
+ * @param columns - The column name or an array of column names to be converted to lowercase.
1616
+ * @returns A promise that resolves when the strings have been converted to lowercase.
1617
+ * @category Updating Data
1618
+ *
1619
+ * @example
1620
+ * ```ts
1621
+ * // Convert strings in 'column1' to lowercase
1622
+ * await table.lower("column1");
1623
+ * ```
1624
+ *
1625
+ * @example
1626
+ * ```ts
1627
+ * // Convert strings in 'column1' and 'column2' to lowercase
1628
+ * await table.lower(["column1", "column2"]);
1629
+ * ```
1630
+ */
1631
+ lower(columns: string | string[]): Promise<void>;
1632
+ /**
1633
+ * Converts string values in the specified columns to uppercase.
1634
+ *
1635
+ * @param columns - The column name or an array of column names to be converted to uppercase.
1636
+ * @returns A promise that resolves when the strings have been converted to uppercase.
1637
+ * @category Updating Data
1638
+ *
1639
+ * @example
1640
+ * ```ts
1641
+ * // Convert strings in 'column1' to uppercase
1642
+ * await table.upper("column1");
1643
+ * ```
1644
+ *
1645
+ * @example
1646
+ * ```ts
1647
+ * // Convert strings in 'column1' and 'column2' to uppercase
1648
+ * await table.upper(["column1", "column2"]);
1649
+ * ```
1650
+ */
1651
+ upper(columns: string | string[]): Promise<void>;
1652
+ /**
1653
+ * Capitalizes the first letter of each string in the specified columns and converts the rest of the string to lowercase.
1654
+ *
1655
+ * @param columns - The column name or an array of column names to be capitalized.
1656
+ * @returns A promise that resolves when the strings have been capitalized.
1657
+ * @category Updating Data
1658
+ *
1659
+ * @example
1660
+ * ```ts
1661
+ * // Capitalize strings in 'column1' (e.g., "hello world" becomes "Hello world")
1662
+ * await table.capitalize("column1");
1663
+ * ```
1664
+ *
1665
+ * @example
1666
+ * ```ts
1667
+ * // Capitalize strings in 'column1' and 'column2'
1668
+ * await table.capitalize(["column1", "column2"]);
1669
+ * ```
1670
+ */
1671
+ capitalize(columns: string | string[]): Promise<void>;
1672
+ /**
1673
+ * Truncates string values in a specified column to a maximum number of characters.
1674
+ *
1675
+ * @param column - The column name containing strings to be truncated.
1676
+ * @param length - The maximum number of characters to keep.
1677
+ * @returns A promise that resolves when the strings have been truncated.
1678
+ * @category Updating Data
1679
+ *
1680
+ * @example
1681
+ * ```ts
1682
+ * // Truncate strings in 'description' column to 50 characters
1683
+ * await table.truncate("description", 50);
1684
+ * ```
1685
+ *
1686
+ * @example
1687
+ * ```ts
1688
+ * // Truncate strings in 'name' column to 10 characters
1689
+ * await table.truncate("name", 10);
1690
+ * ```
1691
+ */
1692
+ truncate(column: string, length: number): Promise<void>;
1693
+ /**
1694
+ * 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.
1695
+ * If the index is out of bounds, an empty string will be returned for that row.
1696
+ *
1697
+ * @param column - The name of the column containing the strings to be split.
1698
+ * @param separator - The substring to use as a delimiter for splitting the strings.
1699
+ * @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.
1700
+ * @param newColumn - The name of the column where the extracted substrings will be stored. To overwrite the original column, use the same name as `column`.
1701
+ * @returns A promise that resolves when the strings have been split and extracted.
1702
+ * @category Updating Data
1703
+ *
1704
+ * @example
1705
+ * ```ts
1706
+ * // Split 'address' by comma and extract the second part (index 1) into a new 'city' column
1707
+ * // e.g., "123 Main St, Anytown, USA" -> "Anytown"
1708
+ * await table.splitExtract("address", ",", 1, "city");
1709
+ * ```
1710
+ *
1711
+ * @example
1712
+ * ```ts
1713
+ * // Split 'fileName' by dot and extract the first part (index 0), overwriting 'fileName'
1714
+ * // e.g., "document.pdf" -> "document"
1715
+ * await table.splitExtract("fileName", ".", 0, "fileName");
1716
+ * ```
1717
+ */
1718
+ splitExtract(column: string, separator: string, index: number, newColumn: string): Promise<void>;
1719
+ /**
1720
+ * Splits strings in a specified column by a separator and spreads the resulting parts into multiple new columns.
1721
+ *
1722
+ * Each part of the split string will be stored in a separate column. The number of columns created is determined by the length of the `newColumns` array.
1723
+ * 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 `noCheck` is set to true).
1724
+ * If a row has more parts than the number of new columns, an error will be thrown unless `noCheck` is set to true.
1725
+ *
1726
+ * @param column - The name of the column containing the strings to be split.
1727
+ * @param separator - The substring to use as a delimiter for splitting the strings.
1728
+ * @param newColumns - An array of column names for the extracted parts.
1729
+ * @param options - Optional configuration.
1730
+ * @param options.noCheck - If true, skips all validation checks (both max and min parts). Default is false.
1731
+ * @returns A promise that resolves when the strings have been split and spread into new columns.
1732
+ * @category Updating Data
1733
+ *
1734
+ * @example
1735
+ * ```ts
1736
+ * // Split 'fullName' by comma and spread into 'lastName' and 'firstName'
1737
+ * // e.g., "Shiab, Nael" -> lastName: "Shiab", firstName: "Nael"
1738
+ * await table.splitSpread("fullName", ",", ["lastName", "firstName"]);
1739
+ * ```
1740
+ *
1741
+ * @example
1742
+ * ```ts
1743
+ * // Split 'address' by comma and spread into three columns
1744
+ * // e.g., "123 Main St, Anytown, USA" -> street: "123 Main St", city: "Anytown", country: "USA"
1745
+ * await table.splitSpread("address", ",", ["street", "city", "country"]);
1746
+ * ```
1747
+ *
1748
+ * @example
1749
+ * ```ts
1750
+ * // Skip validation for performance with noCheck option
1751
+ * await table.splitSpread("data", "|", ["col1", "col2"], { noCheck: true });
1752
+ * ```
1753
+ */
1754
+ splitSpread(column: string, separator: string, newColumns: string[], options?: {
1755
+ noCheck?: boolean;
1756
+ }): Promise<void>;
1757
+ /**
1758
+ * Extracts a specific number of characters from the beginning (left side) of string values in the specified column.
1759
+ *
1760
+ * @param column - The name of the column containing the strings to be modified.
1761
+ * @param numberOfCharacters - The number of characters to extract from the left side of each string.
1762
+ * @returns A promise that resolves when the strings have been updated.
1763
+ * @category Updating Data
1764
+ *
1765
+ * @example
1766
+ * ```ts
1767
+ * // Replace strings in 'productCode' with their first two characters
1768
+ * // e.g., "ABC-123" becomes "AB"
1769
+ * await table.left("productCode", 2);
1770
+ * ```
1771
+ */
1772
+ left(column: string, numberOfCharacters: number): Promise<void>;
1773
+ /**
1774
+ * Extracts a specific number of characters from the end (right side) of string values in the specified column.
1775
+ *
1776
+ * @param column - The name of the column containing the strings to be modified.
1777
+ * @param numberOfCharacters - The number of characters to extract from the right side of each string.
1778
+ * @returns A promise that resolves when the strings have been updated.
1779
+ * @category Updating Data
1780
+ *
1781
+ * @example
1782
+ * ```ts
1783
+ * // Replace strings in 'productCode' with their last two characters
1784
+ * // e.g., "ABC-123" becomes "23"
1785
+ * await table.right("productCode", 2);
1786
+ * ```
1787
+ */
1788
+ right(column: string, numberOfCharacters: number): Promise<void>;
1789
+ /**
1790
+ * Replaces `NULL` values in the specified columns with a given value.
1791
+ *
1792
+ * @param columns - The column name or an array of column names in which to replace `NULL` values.
1793
+ * @param value - The value to replace `NULL` occurrences with.
1794
+ * @returns A promise that resolves when the `NULL` values have been replaced.
1795
+ * @category Updating Data
1796
+ *
1797
+ * @example
1798
+ * ```ts
1799
+ * // Replace NULL values in 'column1' with 0
1800
+ * await table.replaceNulls("column1", 0);
1801
+ * ```
1802
+ *
1803
+ * @example
1804
+ * ```ts
1805
+ * // Replace NULL values in 'columnA' and 'columnB' with the string "N/A"
1806
+ * await table.replaceNulls(["columnA", "columnB"], "N/A");
1807
+ * ```
1808
+ *
1809
+ * @example
1810
+ * ```ts
1811
+ * // Replace NULL values in 'dateColumn' with a specific date
1812
+ * await table.replaceNulls("dateColumn", new Date("2023-01-01"));
1813
+ * ```
1814
+ */
1815
+ replaceNulls(columns: string | string[], value: number | string | Date | boolean): Promise<void>;
1816
+ /**
1817
+ * Concatenates values from specified columns into a new column.
1818
+ *
1819
+ * @param columns - An array of column names whose values will be concatenated.
1820
+ * @param newColumn - The name of the new column to store the concatenated values.
1821
+ * @param options - An optional object with configuration options:
1822
+ * @param options.separator - The string used to separate concatenated values. Defaults to an empty string (`""`).
1823
+ * @returns A promise that resolves when the concatenation is complete.
1824
+ * @category Updating Data
1825
+ *
1826
+ * @example
1827
+ * ```ts
1828
+ * // Concatenate 'firstName' and 'lastName' into a new 'fullName' column
1829
+ * await table.concatenate(["firstName", "lastName"], "fullName");
1830
+ * ```
1831
+ *
1832
+ * @example
1833
+ * ```ts
1834
+ * // Concatenate 'city' and 'country' into 'location', separated by a comma and space
1835
+ * await table.concatenate(["city", "country"], "location", { separator: ", " });
1836
+ * ```
1837
+ */
1838
+ concatenate(columns: string[], newColumn: string, options?: {
1839
+ separator?: string;
1840
+ }): Promise<void>;
1841
+ /**
1842
+ * Concatenates values from multiple columns into a new column with labeled rows.
1843
+ *
1844
+ * This method creates a new column where each value is a concatenation of the specified columns,
1845
+ * with each column value prefixed by its column name and a colon, followed by a newline.
1846
+ * Column entries are separated by double newlines ("\n\n").
1847
+ *
1848
+ * All values must be string, otherwise an error will be thrown. Use the `convert()` method first to convert non-string columns to string.
1849
+ *
1850
+ * If a column value is `NULL`, it will be replaced by `'Unknown'` in the concatenated result.
1851
+ *
1852
+ * @param columns - An array of column names whose values will be concatenated with labels.
1853
+ * @param newColumn - The name of the new column to create with the concatenated values.
1854
+ * @returns A promise that resolves when the concatenation is complete.
1855
+ * @category Updating Data
1856
+ *
1857
+ * @example
1858
+ * ```ts
1859
+ * // Concatenate multiple string columns into a labeled text field
1860
+ * await table.concatenateRow(
1861
+ * ["summary", "findings", "context", "date", "quote"],
1862
+ * "fullText"
1863
+ * );
1864
+ * // Result in "fullText" will look like:
1865
+ * // summary:
1866
+ * // [value]
1867
+ * //
1868
+ * // findings:
1869
+ * // [value]
1870
+ * //
1871
+ * // context:
1872
+ * // [value]
1873
+ * //
1874
+ * // date:
1875
+ * // [value]
1876
+ * //
1877
+ * // quote:
1878
+ * // [value]
1879
+ * ```
1880
+ *
1881
+ * @example
1882
+ * ```ts
1883
+ * // Convert numeric columns to strings first, then concatenate
1884
+ * // NULL values will appear as 'Unknown'
1885
+ * await table.convert({ age: "string", salary: "string" });
1886
+ * await table.concatenateRow(["name", "age", "salary"], "profile");
1887
+ * ```
1888
+ */
1889
+ concatenateRow(columns: string[], newColumn: string): Promise<void>;
1890
+ /**
1891
+ * Unnests (expands) rows by splitting a column's string values into multiple rows based on a separator.
1892
+ *
1893
+ * 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.
1894
+ *
1895
+ * @param column - The name of the column containing string values to be split and unnested.
1896
+ * @param separator - The delimiter string used to split the column values.
1897
+ * @returns A promise that resolves when the unnesting is complete.
1898
+ * @category Updating Data
1899
+ *
1900
+ * @example
1901
+ * ```ts
1902
+ * // Unnest 'tags' column separated by commas
1903
+ * // Before: [{ id: 1, tags: "red,blue,green" }]
1904
+ * // After: [{ id: 1, tags: "red" }, { id: 1, tags: "blue" }, { id: 1, tags: "green" }]
1905
+ * await table.unnest("tags", ",");
1906
+ * ```
1907
+ *
1908
+ * @example
1909
+ * ```ts
1910
+ * // Unnest 'neighborhoods' column separated by " / "
1911
+ * // Before: [{ city: "Montreal", neighborhoods: "Old Montreal / Chinatown / Griffintown" }]
1912
+ * // After: [{ city: "Montreal", neighborhoods: "Old Montreal" },
1913
+ * // { city: "Montreal", neighborhoods: "Chinatown" },
1914
+ * // { city: "Montreal", neighborhoods: "Griffintown" }]
1915
+ * await table.unnest("neighborhoods", " / ");
1916
+ * ```
1917
+ */
1918
+ unnest(column: string, separator: string): Promise<void>;
1919
+ /**
1920
+ * Nests (collapses) rows by aggregating a column's values into a single string per group, separated by a delimiter.
1921
+ *
1922
+ * 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.
1923
+ *
1924
+ * @param column - The name of the column whose values will be aggregated and concatenated.
1925
+ * @param separator - The delimiter string used to join the column values.
1926
+ * @param categories - The column name or an array of column names to group by.
1927
+ * @returns A promise that resolves when the nesting is complete.
1928
+ * @category Updating Data
1929
+ *
1930
+ * @example
1931
+ * ```ts
1932
+ * // Nest 'neighborhoods' column separated by " / " for each city
1933
+ * // Before: [{ city: "Montreal", neighborhoods: "Old Montreal" },
1934
+ * // { city: "Montreal", neighborhoods: "Chinatown" },
1935
+ * // { city: "Montreal", neighborhoods: "Griffintown" }]
1936
+ * // After: [{ city: "Montreal", neighborhoods: "Old Montreal / Chinatown / Griffintown" }]
1937
+ * await table.nest("neighborhoods", " / ", "city");
1938
+ * ```
1939
+ *
1940
+ * @example
1941
+ * ```ts
1942
+ * // Nest with multiple category columns
1943
+ * // Before: [{ country: "Canada", city: "Montreal", tags: "red" },
1944
+ * // { country: "Canada", city: "Montreal", tags: "blue" }]
1945
+ * // After: [{ country: "Canada", city: "Montreal", tags: "red,blue" }]
1946
+ * await table.nest("tags", ",", ["country", "city"]);
1947
+ * ```
1948
+ */
1949
+ nest(column: string, separator: string, categories: string | string[]): Promise<void>;
1950
+ /**
1951
+ * Rounds numeric values in specified columns.
1952
+ *
1953
+ * @param columns - The column name or an array of column names containing numeric values to be rounded.
1954
+ * @param options - An optional object with configuration options:
1955
+ * @param options.decimals - The number of decimal places to round to. Defaults to `0` (rounds to the nearest integer).
1956
+ * @param options.method - The rounding method to use: `"round"` (rounds to the nearest integer, with halves rounding up), `"ceiling"` (rounds up to the nearest integer), or `"floor"` (rounds down to the nearest integer). Defaults to `"round"`.
1957
+ * @returns A promise that resolves when the numeric values have been rounded.
1958
+ * @category Updating Data
1959
+ *
1960
+ * @example
1961
+ * ```ts
1962
+ * // Round 'column1' values to the nearest integer
1963
+ * await table.round("column1");
1964
+ * ```
1965
+ *
1966
+ * @example
1967
+ * ```ts
1968
+ * // Round 'column1' values to 2 decimal places
1969
+ * await table.round("column1", { decimals: 2 });
1970
+ * ```
1971
+ *
1972
+ * @example
1973
+ * ```ts
1974
+ * // Round 'column1' values down to the nearest integer (floor)
1975
+ * await table.round("column1", { method: "floor" });
1976
+ * ```
1977
+ *
1978
+ * @example
1979
+ * ```ts
1980
+ * // Round 'columnA' and 'columnB' values to 1 decimal place using ceiling method
1981
+ * await table.round(["columnA", "columnB"], { decimals: 1, method: "ceiling" });
1982
+ * ```
1983
+ */
1984
+ round(columns: string | string[], options?: {
1985
+ decimals?: number;
1986
+ method?: "round" | "ceiling" | "floor";
1987
+ }): Promise<void>;
1988
+ /**
1989
+ * Updates values in a specified column using a SQL expression.
1990
+ *
1991
+ * @param column - The name of the column to be updated.
1992
+ * @param definition - The SQL expression used to set the new values in the column (e.g., `"column1 * 2"`, `"UPPER(column_name)"`).
1993
+ * @returns A promise that resolves when the column has been updated.
1994
+ * @category Updating Data
1995
+ *
1996
+ * @example
1997
+ * ```ts
1998
+ * // Update 'column1' with the left 5 characters of 'column2'
1999
+ * await table.updateColumn("column1", `LEFT(column2, 5)`);
2000
+ * ```
2001
+ *
2002
+ * @example
2003
+ * ```ts
2004
+ * // Double the values in 'price' column
2005
+ * await table.updateColumn("price", `price * 2`);
2006
+ * ```
2007
+ *
2008
+ * @example
2009
+ * ```ts
2010
+ * // Set 'status' to 'active' where 'isActive' is true
2011
+ * await table.updateColumn("status", `CASE WHEN isActive THEN 'active' ELSE 'inactive' END`);
2012
+ * ```
2013
+ */
2014
+ updateColumn(column: string, definition: string): Promise<void>;
2015
+ /**
2016
+ * Assigns ranks to rows in a new column based on the values of a specified column.
2017
+ *
2018
+ * @param values - The column containing the values to be used for ranking.
2019
+ * @param newColumn - The name of the new column where the ranks will be stored.
2020
+ * @param options - An optional object with configuration options:
2021
+ * @param options.order - The order of values for ranking: `"asc"` for ascending (default) or `"desc"` for descending.
2022
+ * @param options.categories - The column name or an array of column names that define categories for ranking. Ranks will be assigned independently within each category.
2023
+ * @param options.noGaps - A boolean indicating whether to assign ranks without gaps (dense ranking). If `true`, ranks will be consecutive integers (e.g., 1, 2, 2, 3). If `false` (default), ranks might have gaps (e.g., 1, 2, 2, 4).
2024
+ * @returns A promise that resolves when the ranks have been assigned.
2025
+ * @category Analyzing Data
2026
+ *
2027
+ * @example
2028
+ * ```ts
2029
+ * // Compute ranks in a new 'rank' column based on 'score' values (ascending)
2030
+ * await table.ranks("score", "rank");
2031
+ * ```
2032
+ *
2033
+ * @example
2034
+ * ```ts
2035
+ * // Compute ranks in a new 'descRank' column based on 'score' values (descending)
2036
+ * await table.ranks("score", "descRank", { order: "desc" });
2037
+ * ```
2038
+ *
2039
+ * @example
2040
+ * ```ts
2041
+ * // Compute ranks within 'department' categories, based on 'salary' values, without gaps
2042
+ * await table.ranks("salary", "salaryRank", { categories: "department", noGaps: true });
2043
+ * ```
2044
+ *
2045
+ * @example
2046
+ * ```ts
2047
+ * // Compute ranks within multiple categories ('department' and 'city')
2048
+ * await table.ranks("sales", "salesRank", { categories: ["department", "city"] });
2049
+ * ```
2050
+ */
2051
+ ranks(values: string, newColumn: string, options?: {
2052
+ order?: "asc" | "desc";
2053
+ categories?: string | string[];
2054
+ noGaps?: boolean;
2055
+ }): Promise<void>;
2056
+ /**
2057
+ * Assigns quantiles to rows in a new column based on specified column values.
2058
+ *
2059
+ * @param values - The column containing values from which quantiles will be assigned.
2060
+ * @param nbQuantiles - The number of quantiles to divide the data into (e.g., `4` for quartiles, `10` for deciles).
2061
+ * @param newColumn - The name of the new column where the assigned quantiles will be stored.
2062
+ * @param options - An optional object with configuration options:
2063
+ * @param options.categories - The column name or an array of column names that define categories for computing quantiles. Quantiles will be assigned independently within each category.
2064
+ * @returns A promise that resolves when the quantiles have been assigned.
2065
+ * @category Analyzing Data
2066
+ *
2067
+ * @example
2068
+ * ```ts
2069
+ * // Assigns a quantile from 1 to 10 for each row in a new 'quantiles' column, based on 'column1' values.
2070
+ * await table.quantiles("column1", 10, "quantiles");
2071
+ * ```
2072
+ *
2073
+ * @example
2074
+ * ```ts
2075
+ * // Assigns quantiles within 'column2' categories, based on 'column1' values.
2076
+ * await table.quantiles("column1", 10, "quantiles", { categories: "column2" });
2077
+ * ```
2078
+ *
2079
+ * @example
2080
+ * ```ts
2081
+ * // Assigns quartiles (4 quantiles) to 'sales' data, storing results in 'salesQuartile'
2082
+ * await table.quantiles("sales", 4, "salesQuartile");
2083
+ * ```
2084
+ */
2085
+ quantiles(values: string, nbQuantiles: number, newColumn: string, options?: {
2086
+ categories?: string | string[];
2087
+ }): Promise<void>;
2088
+ /**
2089
+ * Assigns bins for specified column values based on an interval size.
2090
+ *
2091
+ * @param values - The column containing values from which bins will be computed.
2092
+ * @param interval - The interval size for binning the values.
2093
+ * @param newColumn - The name of the new column where the bins will be stored.
2094
+ * @param options - An optional object with configuration options:
2095
+ * @param options.startValue - The starting value for binning. Defaults to the minimum value in the specified column.
2096
+ * @returns A promise that resolves when the bins have been assigned.
2097
+ * @category Analyzing Data
2098
+ *
2099
+ * @example
2100
+ * ```ts
2101
+ * // Assigns a bin for each row in a new 'bins' column based on 'column1' values, with an interval of 10.
2102
+ * // If the minimum value in 'column1' is 5, the bins will follow this pattern: "[5-14]", "[15-24]", etc.
2103
+ * await table.bins("column1", 10, "bins");
2104
+ * ```
2105
+ *
2106
+ * @example
2107
+ * ```ts
2108
+ * // Assigns bins starting at a specific value (0) with an interval of 10.
2109
+ * // The bins will follow this pattern: "[0-9]", "[10-19]", "[20-29]", etc.
2110
+ * await table.bins("column1", 10, "bins", { startValue: 0 });
2111
+ * ```
2112
+ */
2113
+ bins(values: string, interval: number, newColumn: string, options?: {
2114
+ startValue?: number;
2115
+ }): Promise<void>;
2116
+ /**
2117
+ * Computes proportions horizontally across specified columns for each row.
2118
+ *
2119
+ * For example, given a table showing counts of men, women, and non-binary individuals per year:
2120
+ *
2121
+ * | Year | Men | Women | NonBinary |
2122
+ * | :--- | :-- | :---- | :-------- |
2123
+ * | 2021 | 564 | 685 | 145 |
2124
+ * | 2022 | 354 | 278 | 56 |
2125
+ * | 2023 | 856 | 321 | 221 |
2126
+ *
2127
+ * This method computes the proportion of men, women, and non-binary individuals on each row, adding new columns for these proportions.
2128
+ *
2129
+ * @example
2130
+ * ```ts
2131
+ * // Compute horizontal proportions for 'Men', 'Women', and 'NonBinary' columns, rounded to 2 decimal places
2132
+ * await table.proportionsHorizontal(["Men", "Women", "NonBinary"], { decimals: 2 });
2133
+ * ```
2134
+ *
2135
+ * The table will then look like this:
2136
+ *
2137
+ * | Year | Men | Women | NonBinary | MenPerc | WomenPerc | NonBinaryPerc |
2138
+ * | :--- | :-- | :---- | :-------- | :------ | :-------- | :------------ |
2139
+ * | 2021 | 564 | 685 | 145 | 0.4 | 0.49 | 0.10 |
2140
+ * | 2022 | 354 | 278 | 56 | 0.51 | 0.4 | 0.08 |
2141
+ * | 2023 | 856 | 321 | 221 | 0.61 | 0.23 | 0.16 |
2142
+ *
2143
+ * By default, the new columns will be named with a suffix of `"Perc"`. You can customize this suffix using the `suffix` option.
2144
+ *
2145
+ * @example
2146
+ * ```ts
2147
+ * // Compute horizontal proportions with a custom suffix "Prop"
2148
+ * await table.proportionsHorizontal(["Men", "Women", "NonBinary"], { suffix: "Prop", decimals: 2 });
2149
+ * ```
2150
+ *
2151
+ * The table will then look like this:
2152
+ *
2153
+ * | Year | Men | Women | NonBinary | MenProp | WomenProp | NonBinaryProp |
2154
+ * | :--- | :-- | :---- | :-------- | :------ | :-------- | :------------ |
2155
+ * | 2021 | 564 | 685 | 145 | 0.4 | 0.49 | 0.10 |
2156
+ * | 2022 | 354 | 278 | 56 | 0.51 | 0.4 | 0.08 |
2157
+ * | 2023 | 856 | 321 | 221 | 0.61 | 0.23 | 0.16 |
2158
+ *
2159
+ * @param columns - An array of column names for which proportions will be computed on each row.
2160
+ * @param options - An optional object with configuration options:
2161
+ * @param options.suffix - A string suffix to append to the names of the new columns storing the computed proportions. Defaults to `"Perc"`.
2162
+ * @param options.decimals - The number of decimal places to round the computed proportions. Defaults to `undefined` (no rounding).
2163
+ * @returns A promise that resolves when the horizontal proportions have been computed.
2164
+ * @category Analyzing Data
2165
+ */
2166
+ proportionsHorizontal(columns: string[], options?: {
2167
+ suffix?: string;
2168
+ decimals?: number;
2169
+ }): Promise<void>;
2170
+ /**
2171
+ * Computes proportions vertically over a column's values, relative to the sum of all values in that column (or within specified categories).
2172
+ *
2173
+ * @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.
2174
+ * @param newColumn - The name of the new column where the proportions will be stored.
2175
+ * @param options - An optional object with configuration options:
2176
+ * @param options.categories - The column name or an array of column names that define categories for computing proportions. Proportions will be calculated independently within each category.
2177
+ * @param options.decimals - The number of decimal places to round the computed proportions. Defaults to `undefined` (no rounding).
2178
+ * @returns A promise that resolves when the vertical proportions have been computed.
2179
+ * @category Analyzing Data
2180
+ *
2181
+ * @example
2182
+ * ```ts
2183
+ * // Add a new column 'perc' with each 'column1' value divided by the sum of all 'column1' values
2184
+ * await table.proportionsVertical("column1", "perc");
2185
+ * ```
2186
+ *
2187
+ * @example
2188
+ * ```ts
2189
+ * // Compute proportions for 'column1' within 'column2' categories, rounded to two decimal places
2190
+ * await table.proportionsVertical("column1", "perc", { categories: "column2", decimals: 2 });
2191
+ * ```
2192
+ *
2193
+ * @example
2194
+ * ```ts
2195
+ * // Compute proportions for 'sales' within 'region' and 'product_type' categories
2196
+ * await table.proportionsVertical("sales", "sales_proportion", { categories: ["region", "product_type"] });
2197
+ * ```
2198
+ */
2199
+ proportionsVertical(column: string, newColumn: string, options?: {
2200
+ categories?: string | string[];
2201
+ decimals?: number;
2202
+ }): Promise<void>;
2203
+ /**
2204
+ * Creates a summary table based on specified values, categories, and summary operations.
2205
+ * This method allows you to aggregate data, calculate statistics (e.g., count, mean, sum), and group results by categorical columns.
2206
+ *
2207
+ * @param options - An object with configuration options for summarization:
2208
+ * @param options.values - The column name or an array of column names whose values will be summarized. If omitted, all columns will be summarized.
2209
+ * @param options.categories - The column name or an array of column names that define categories for the summarization. Results will be grouped by these categories.
2210
+ * @param options.summaries - The summary operations to be performed. Can be a single operation (e.g., `"mean"`), an array of operations (e.g., `["min", "max"]`), or an object mapping new column names to operations (e.g., `{ avgSalary: "mean" }`). Supported operations include: `"count"`, `"countUnique"`, `"countNull"`, `"min"`, `"max"`, `"mean"`, `"median"`, `"sum"`, `"skew"`, `"stdDev"`, `"var"`.
2211
+ * @param options.decimals - The number of decimal places to round the summarized values. Defaults to `undefined` (no rounding).
2212
+ * @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`.
2213
+ * @param options.toMs - If `true`, timestamps, dates, and times will be converted to milliseconds before summarizing. This is useful when summarizing mixed data types (numbers and dates) as values must be of the same type for aggregation.
2214
+ * @param options.noColumnValue - If `true`, the default `value` column will be removed. This option only works when summarizing a single column without categories. Defaults to `false`.
2215
+ * @returns A promise that resolves to a table instance containing the summarized data (either the modified current table or a new table).
2216
+ * @category Analyzing Data
2217
+ *
2218
+ * @example
2219
+ * ```ts
2220
+ * // Summarize all columns with all available summary operations, overwriting the current table
2221
+ * const columns = await table.getColumns();
2222
+ * await table.summarize({ values: columns });
2223
+ * ```
2224
+ *
2225
+ * @example
2226
+ * ```ts
2227
+ * // Summarize all columns and store the results in a new table with a generated name
2228
+ * const columns = await table.getColumns();
2229
+ * const summaryTable = await table.summarize({ values: columns, outputTable: true });
2230
+ * ```
2231
+ *
2232
+ * @example
2233
+ * ```ts
2234
+ * // Summarize all columns and store the results in a new table named 'mySummary'
2235
+ * const columns = await table.getColumns();
2236
+ * const mySummaryTable = await table.summarize({ values: columns, outputTable: "mySummary" });
2237
+ * ```
2238
+ *
2239
+ * @example
2240
+ * ```ts
2241
+ * // Summarize a single column ('sales') with all available summary operations
2242
+ * await table.summarize({ values: "sales" });
2243
+ * ```
2244
+ *
2245
+ * @example
2246
+ * ```ts
2247
+ * // Summarize multiple columns ('sales' and 'profit') with all available summary operations
2248
+ * await table.summarize({ values: ["sales", "profit"] });
2249
+ * ```
2250
+ *
2251
+ * @example
2252
+ * ```ts
2253
+ * // Summarize 'sales' by 'region' (single category)
2254
+ * await table.summarize({ values: "sales", categories: "region" });
2255
+ * ```
2256
+ *
2257
+ * @example
2258
+ * ```ts
2259
+ * // Summarize 'sales' by 'region' and 'product_type' (multiple categories)
2260
+ * await table.summarize({ values: "sales", categories: ["region", "product_type"] });
2261
+ * ```
2262
+ *
2263
+ * @example
2264
+ * ```ts
2265
+ * // Summarize 'sales' by 'region' with a specific summary operation (mean)
2266
+ * await table.summarize({ values: "sales", categories: "region", summaries: "mean" });
2267
+ * ```
2268
+ *
2269
+ * @example
2270
+ * ```ts
2271
+ * // Summarize 'sales' by 'region' with specific summary operations (mean and sum)
2272
+ * await table.summarize({ values: "sales", categories: "region", summaries: ["mean", "sum"] });
2273
+ * ```
2274
+ *
2275
+ * @example
2276
+ * ```ts
2277
+ * // Summarize 'sales' by 'region' with custom named summary operations
2278
+ * await table.summarize({ values: "sales", categories: "region", summaries: { averageSales: "mean", totalSales: "sum" } });
2279
+ * ```
2280
+ *
2281
+ * @example
2282
+ * ```ts
2283
+ * // Summarize 'price' and 'cost', rounding aggregated values to 2 decimal places
2284
+ * await table.summarize({ values: ["price", "cost"], decimals: 2 });
2285
+ * ```
2286
+ *
2287
+ * @example
2288
+ * ```ts
2289
+ * // Summarize 'timestamp_column' by converting to milliseconds first
2290
+ * await table.summarize({ values: "timestamp_column", toMs: true, summaries: "mean" });
2291
+ * ```
2292
+ *
2293
+ * @example
2294
+ * ```ts
2295
+ * // Summarize a single column 'value_column' without the default 'value' column in the output
2296
+ * await table.summarize({ values: "value_column", noColumnValue: true });
2297
+ * ```
2298
+ */
2299
+ summarize(options?: {
2300
+ values?: string | string[];
2301
+ categories?: string | string[];
2302
+ summaries?: ("count" | "countUnique" | "countNull" | "min" | "max" | "mean" | "median" | "sum" | "skew" | "stdDev" | "var") | ("count" | "countUnique" | "countNull" | "min" | "max" | "mean" | "median" | "sum" | "skew" | "stdDev" | "var")[] | {
2303
+ [key: string]: "count" | "countUnique" | "countNull" | "min" | "max" | "mean" | "median" | "sum" | "skew" | "stdDev" | "var";
2304
+ };
2305
+ decimals?: number;
2306
+ outputTable?: string | boolean;
2307
+ toMs?: boolean;
2308
+ noColumnValue?: boolean;
2309
+ }): Promise<this>;
2310
+ /**
2311
+ * Computes the cumulative sum of values in a column. For this method to work properly, ensure your data is sorted first.
2312
+ *
2313
+ * @param column - The name of the column storing the values to be accumulated.
2314
+ * @param newColumn - The name of the new column in which the computed cumulative values will be stored.
2315
+ * @param options - An optional object with configuration options:
2316
+ * @param options.categories - The column name or an array of column names that define categories for the accumulation. Accumulation will be performed independently within each category.
2317
+ * @returns A promise that resolves when the cumulative sum has been computed.
2318
+ * @category Analyzing Data
2319
+ *
2320
+ * @example
2321
+ * ```ts
2322
+ * // Compute the cumulative sum of 'sales' in a new 'cumulativeSales' column
2323
+ * // Ensure the table is sorted by a relevant column (e.g., date) before calling this method.
2324
+ * await table.accumulate("sales", "cumulativeSales");
2325
+ * ```
2326
+ *
2327
+ * @example
2328
+ * ```ts
2329
+ * // Compute the cumulative sum of 'orders' within 'customer_id' categories
2330
+ * // Ensure the table is sorted by 'customer_id' and then by a relevant order column (e.g., order_date).
2331
+ * await table.accumulate("orders", "cumulativeOrders", { categories: "customer_id" });
2332
+ * ```
2333
+ *
2334
+ * @example
2335
+ * ```ts
2336
+ * // Compute the cumulative sum of 'revenue' within 'region' and 'product_category' categories
2337
+ * await table.accumulate("revenue", "cumulativeRevenue", { categories: ["region", "product_category"] });
2338
+ * ```
2339
+ */
2340
+ accumulate(column: string, newColumn: string, options?: {
2341
+ categories?: string | string[];
2342
+ }): Promise<void>;
2343
+ /**
2344
+ * Computes rolling aggregations (e.g., rolling average, min, max) over a specified column.
2345
+ * For rows without enough preceding or following rows to form a complete window, `NULL` will be returned.
2346
+ * For this method to work properly, ensure your data is sorted by the relevant column(s) first.
2347
+ *
2348
+ * @param column - The name of the column storing the values to be aggregated.
2349
+ * @param newColumn - The name of the new column in which the computed rolling values will be stored.
2350
+ * @param summary - The aggregation function to apply: `"min"`, `"max"`, `"mean"`, `"median"`, or `"sum"`.
2351
+ * @param preceding - The number of preceding rows to include in the rolling window.
2352
+ * @param following - The number of following rows to include in the rolling window.
2353
+ * @param options - An optional object with configuration options:
2354
+ * @param options.categories - The column name or an array of column names that define categories for the aggregation. Rolling aggregations will be computed independently within each category.
2355
+ * @param options.decimals - The number of decimal places to round the aggregated values. Defaults to `undefined` (no rounding).
2356
+ * @returns A promise that resolves when the rolling aggregation is complete.
2357
+ * @category Analyzing Data
2358
+ *
2359
+ * @example
2360
+ * ```ts
2361
+ * // Compute a 7-day rolling average of 'sales' with 3 preceding and 3 following rows
2362
+ * // (total window size of 7: 3 preceding + current + 3 following)
2363
+ * await table.rolling("sales", "rollingAvgSales", "mean", 3, 3);
2364
+ * ```
2365
+ *
2366
+ * @example
2367
+ * ```ts
2368
+ * // Compute a rolling sum of 'transactions' within 'customer_id' categories
2369
+ * await table.rolling("transactions", "rollingSumTransactions", "sum", 5, 0, { categories: "customer_id" });
2370
+ * ```
2371
+ *
2372
+ * @example
2373
+ * ```ts
2374
+ * // Compute a rolling maximum of 'temperature' rounded to 1 decimal place
2375
+ * await table.rolling("temperature", "rollingMaxTemp", "max", 2, 2, { decimals: 1 });
2376
+ * ```
2377
+ */
2378
+ rolling(column: string, newColumn: string, summary: "min" | "max" | "mean" | "median" | "sum", preceding: number, following: number, options?: {
2379
+ categories?: string | string[];
2380
+ decimals?: number;
2381
+ }): Promise<void>;
2382
+ /**
2383
+ * Calculates correlations between columns. If no `x` and `y` columns are specified, the method computes the correlations for all numeric column combinations.
2384
+ * Note that correlation is symmetrical: the correlation of `x` with `y` is the same as `y` with `x`.
2385
+ *
2386
+ * @param options - An optional object with configuration options:
2387
+ * @param options.x - The name of the column for the x-values. If omitted, correlations will be computed for all numeric columns.
2388
+ * @param options.y - The name of the column for the y-values. If omitted, correlations will be computed for all numeric columns.
2389
+ * @param options.categories - The column name or an array of column names that define categories. Correlation calculations will be performed independently for each category.
2390
+ * @param options.decimals - The number of decimal places to round the correlation values. Defaults to `undefined` (no rounding).
2391
+ * @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`.
2392
+ * @returns A promise that resolves to a table instance containing the correlation results (either the modified current table or a new table).
2393
+ * @category Analyzing Data
2394
+ *
2395
+ * @example
2396
+ * ```ts
2397
+ * // Compute correlations between all numeric columns, overwriting the current table
2398
+ * await table.correlations();
2399
+ * ```
2400
+ *
2401
+ * @example
2402
+ * ```ts
2403
+ * // Compute correlations between 'column1' and all other numeric columns
2404
+ * await table.correlations({ x: "column1" });
2405
+ * ```
2406
+ *
2407
+ * @example
2408
+ * ```ts
2409
+ * // Compute the correlation between 'column1' and 'column2'
2410
+ * await table.correlations({ x: "column1", y: "column2" });
2411
+ * ```
2412
+ *
2413
+ * @example
2414
+ * ```ts
2415
+ * // Compute correlations within 'categoryColumn' and store results in a new table
2416
+ * const correlationTable = await table.correlations({ categories: "categoryColumn", outputTable: true });
2417
+ * ```
2418
+ *
2419
+ * @example
2420
+ * ```ts
2421
+ * // Compute correlations, rounded to 2 decimal places
2422
+ * await table.correlations({ decimals: 2 });
2423
+ * ```
2424
+ */
2425
+ correlations(options?: {
2426
+ x?: string;
2427
+ y?: string;
2428
+ categories?: string | string[];
2429
+ decimals?: number;
2430
+ outputTable?: string | boolean;
2431
+ }): Promise<this>;
2432
+ /**
2433
+ * Performs linear regression analysis. The results include the slope, the y-intercept, and the R-squared value.
2434
+ * If no `x` and `y` columns are specified, the method computes linear regression analysis for all numeric column permutations.
2435
+ * Note that linear regression analysis is asymmetrical: the linear regression of `x` over `y` is not the same as `y` over `x`.
2436
+ *
2437
+ * @param options - An optional object with configuration options:
2438
+ * @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.
2439
+ * @param options.y - The name of the column for the dependent variable (y-values). If omitted, linear regressions will be computed for all numeric columns as y.
2440
+ * @param options.categories - The column name or an array of column names that define categories. Linear regression analysis will be performed independently for each category.
2441
+ * @param options.decimals - The number of decimal places to round the regression values (slope, intercept, r-squared). Defaults to `undefined` (no rounding).
2442
+ * @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`.
2443
+ * @returns A promise that resolves to a table instance containing the linear regression results (either the modified current table or a new table).
2444
+ * @category Analyzing Data
2445
+ *
2446
+ * @example
2447
+ * ```ts
2448
+ * // Compute all linear regressions between all numeric columns, overwriting the current table
2449
+ * await table.linearRegressions();
2450
+ * ```
2451
+ *
2452
+ * @example
2453
+ * ```ts
2454
+ * // Compute linear regressions with 'column1' as the independent variable and all other numeric columns as dependent variables
2455
+ * await table.linearRegressions({ x: "column1" });
2456
+ * ```
2457
+ *
2458
+ * @example
2459
+ * ```ts
2460
+ * // Compute the linear regression of 'sales' (y) over 'advertising' (x)
2461
+ * await table.linearRegressions({ x: "advertising", y: "sales" });
2462
+ * ```
2463
+ *
2464
+ * @example
2465
+ * ```ts
2466
+ * // Compute linear regressions within 'region' categories and store results in a new table
2467
+ * const regressionTable = await table.linearRegressions({ categories: "region", outputTable: true });
2468
+ * ```
2469
+ *
2470
+ * @example
2471
+ * ```ts
2472
+ * // Compute linear regressions, rounded to 3 decimal places
2473
+ * await table.linearRegressions({ decimals: 3 });
2474
+ * ```
2475
+ */
2476
+ linearRegressions(options?: {
2477
+ x?: string;
2478
+ y?: string;
2479
+ categories?: string | string[];
2480
+ decimals?: number;
2481
+ outputTable?: string | boolean;
2482
+ }): Promise<this>;
2483
+ /**
2484
+ * Identifies outliers in a specified column using the Interquartile Range (IQR) method.
2485
+ *
2486
+ * @param column - The name of the column in which outliers will be identified.
2487
+ * @param newColumn - The name of the new column where the boolean results (`TRUE` for outlier, `FALSE` otherwise) will be stored.
2488
+ * @param options - An optional object with configuration options:
2489
+ * @param options.categories - The column name or an array of column names that define categories. Outlier detection will be performed independently within each category.
2490
+ * @returns A promise that resolves when the outliers have been identified.
2491
+ * @category Analyzing Data
2492
+ *
2493
+ * @example
2494
+ * ```ts
2495
+ * // Look for outliers in the 'age' column and store results in a new 'isOutlier' column
2496
+ * await table.outliersIQR("age", "isOutlier");
2497
+ * ```
2498
+ *
2499
+ * @example
2500
+ * ```ts
2501
+ * // Look for outliers in 'salary' within 'gender' categories
2502
+ * await table.outliersIQR("salary", "salaryOutlier", { categories: "gender" });
2503
+ * ```
2504
+ */
2505
+ outliersIQR(column: string, newColumn: string, options?: {
2506
+ categories?: string | string[];
2507
+ }): Promise<void>;
2508
+ /**
2509
+ * Computes the Z-score for values in a specified column.
2510
+ *
2511
+ * @param column - The name of the column for which Z-scores will be calculated.
2512
+ * @param newColumn - The name of the new column where the computed Z-scores will be stored.
2513
+ * @param options - An optional object with configuration options:
2514
+ * @param options.categories - The column name or an array of column names that define categories. Z-scores will be calculated independently within each category.
2515
+ * @param options.decimals - The number of decimal places to round the Z-score values. Defaults to `undefined` (no rounding).
2516
+ * @returns A promise that resolves when the Z-scores have been computed.
2517
+ * @category Analyzing Data
2518
+ *
2519
+ * @example
2520
+ * ```ts
2521
+ * // Calculate the Z-score for 'age' values and store results in a new 'ageZScore' column
2522
+ * await table.zScore("age", "ageZScore");
2523
+ * ```
2524
+ *
2525
+ * @example
2526
+ * ```ts
2527
+ * // Calculate Z-scores for 'salary' within 'department' categories
2528
+ * await table.zScore("salary", "salaryZScore", { categories: "department" });
2529
+ * ```
2530
+ *
2531
+ * @example
2532
+ * ```ts
2533
+ * // Calculate Z-scores for 'score', rounded to 2 decimal places
2534
+ * await table.zScore("score", "scoreZScore", { decimals: 2 });
2535
+ * ```
2536
+ */
2537
+ zScore(column: string, newColumn: string, options?: {
2538
+ categories?: string | string[];
2539
+ decimals?: number;
2540
+ }): Promise<void>;
2541
+ /**
2542
+ * Normalizes the values in a column using min-max normalization.
2543
+ *
2544
+ * @param column - The name of the column in which values will be normalized.
2545
+ * @param newColumn - The name of the new column where normalized values will be stored.
2546
+ * @param options - An optional object with configuration options:
2547
+ * @param options.categories - The column name or an array of column names that define categories for the normalization. Normalization will be performed independently within each category.
2548
+ * @param options.decimals - The number of decimal places to round the normalized values. Defaults to `undefined` (no rounding).
2549
+ * @returns A promise that resolves when the values have been normalized.
2550
+ * @category Analyzing Data
2551
+ *
2552
+ * @example
2553
+ * ```ts
2554
+ * // Normalize the values in 'column1' and store them in a new 'normalizedColumn1' column
2555
+ * await table.normalize("column1", "normalizedColumn1");
2556
+ * ```
2557
+ *
2558
+ * @example
2559
+ * ```ts
2560
+ * // Normalize 'value' within 'group' categories
2561
+ * await table.normalize("value", "normalizedValue", { categories: "group" });
2562
+ * ```
2563
+ *
2564
+ * @example
2565
+ * ```ts
2566
+ * // Normalize 'data' values, rounded to 2 decimal places
2567
+ * await table.normalize("data", "normalizedData", { decimals: 2 });
2568
+ * ```
2569
+ */
2570
+ normalize(column: string, newColumn: string, options?: {
2571
+ categories?: string | string[];
2572
+ decimals?: number;
2573
+ }): Promise<void>;
2574
+ /**
2575
+ * 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.
2576
+ * This method offers high flexibility for data manipulation but can be slow for large tables as it involves transferring data between DuckDB and JavaScript.
2577
+ * This method does not work with tables containing geometries.
2578
+ *
2579
+ * @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).
2580
+ * @returns A promise that resolves when the data has been updated.
2581
+ * @category Updating Data
2582
+ *
2583
+ * @example
2584
+ * ```ts
2585
+ * // Add 1 to values in 'column1'. If values are not numbers, they are replaced by null.
2586
+ * await table.updateWithJS((rows) => {
2587
+ * const modifiedRows = rows.map(d => ({
2588
+ * ...d,
2589
+ * column1: typeof d.column1 === "number" ? d.column1 + 1 : null,
2590
+ * }));
2591
+ * return modifiedRows;
2592
+ * });
2593
+ * ```
2594
+ *
2595
+ * @example
2596
+ * ```ts
2597
+ * // Convert a date string to a Date object in 'dateColumn'
2598
+ * await table.updateWithJS((rows) => {
2599
+ * const modifiedRows = rows.map(d => ({
2600
+ * ...d,
2601
+ * dateColumn: typeof d.dateColumn === "string" ? new Date(d.dateColumn) : d.dateColumn,
2602
+ * }));
2603
+ * return modifiedRows;
2604
+ * });
2605
+ * ```
2606
+ */
2607
+ updateWithJS(dataModifier: ((rows: {
2608
+ [key: string]: number | string | Date | boolean | null;
2609
+ }[]) => Promise<{
2610
+ [key: string]: number | string | Date | boolean | null;
2611
+ }[]>) | ((rows: {
2612
+ [key: string]: number | string | Date | boolean | null;
2613
+ }[]) => {
2614
+ [key: string]: number | string | Date | boolean | null;
2615
+ }[])): Promise<void>;
2616
+ /**
2617
+ * Returns the schema of the table, including column names and their data types.
2618
+ *
2619
+ * @returns A promise that resolves to an array of objects, where each object represents a column with its name and data type.
2620
+ * @category Getting Data
2621
+ *
2622
+ * @example
2623
+ * ```ts
2624
+ * // Get the schema of the table
2625
+ * const schema = await table.getSchema();
2626
+ * console.table(schema); // Log the schema in a readable table format
2627
+ * ```
2628
+ */
2629
+ getSchema(): Promise<{
2630
+ [key: string]: string | null;
2631
+ }[]>;
2632
+ /**
2633
+ * Returns descriptive statistical information about the columns, including details like data types, number of null values, and distinct values.
2634
+ *
2635
+ * @returns A promise that resolves to an array of objects, each representing descriptive statistics for a column.
2636
+ * @category Getting Data
2637
+ *
2638
+ * @example
2639
+ * ```ts
2640
+ * // Get and log descriptive information about the table's columns
2641
+ * const description = await table.getDescription();
2642
+ * console.table(description);
2643
+ * ```
2644
+ */
2645
+ getDescription(): Promise<{
2646
+ [key: string]: unknown;
2647
+ }[]>;
2648
+ /**
2649
+ * Returns the name of the table.
2650
+ *
2651
+ * @returns The name of the table as a string.
2652
+ * @category Getting Data
2653
+ *
2654
+ * @example
2655
+ * ```ts
2656
+ * // Get the table name
2657
+ * const tableName = table.getTableName();
2658
+ * console.log(tableName); // e.g., "employees"
2659
+ * ```
2660
+ */
2661
+ getTableName(): string;
2662
+ /**
2663
+ * Returns a list of all column names in the table.
2664
+ *
2665
+ * @returns A promise that resolves to an array of strings, where each string is a column name.
2666
+ * @category Getting Data
2667
+ *
2668
+ * @example
2669
+ * ```ts
2670
+ * // Get all column names from the table
2671
+ * const columns = await table.getColumns();
2672
+ * console.log(columns); // e.g., ["id", "name", "age"]
2673
+ * ```
2674
+ */
2675
+ getColumns(): Promise<string[]>;
2676
+ /**
2677
+ * Normalizes string values in a column by:
2678
+ * 1. Stripping accents
2679
+ * 2. Optionally stripping punctuation (default: true)
2680
+ * 3. Converting to lowercase
2681
+ * 4. Normalizing whitespace (multiple spaces/tabs/newlines → single space)
2682
+ * 5. Trimming leading/trailing whitespace
2683
+ *
2684
+ * Produces identical output to `journalism-format`'s `normalizeString()` function
2685
+ * for all common cases including accented Latin characters.
2686
+ *
2687
+ * @param column The column containing the text to normalize
2688
+ * @param newColumn The column to store the normalized results
2689
+ * @param options Configuration options
2690
+ * @param options.stripPunctuation Strip punctuation and underscores (default: true)
2691
+ *
2692
+ * @returns A promise that resolves when the operation is complete
2693
+ *
2694
+ * @example
2695
+ * ```ts
2696
+ * // Normalize text column and store in new column
2697
+ * await table.normalizeString("recipeName", "recipeNameNormalized");
2698
+ * // "Épicerie Parisienne!" → "epicerie parisienne"
2699
+ * ```
2700
+ *
2701
+ * @example
2702
+ * ```ts
2703
+ * // Keep punctuation for emails and URLs
2704
+ * await table.normalizeString("email", "emailNormalized", { stripPunctuation: false });
2705
+ * // "User@Example.com" → "user@example.com"
2706
+ * await table.normalizeString("url", "urlNormalized", { stripPunctuation: false });
2707
+ * // "https://Example.com/path" → "https://example.com/path"
2708
+ * ```
2709
+ *
2710
+ * @category Text Processing
2711
+ */
2712
+ normalizeString(column: string, newColumn: string, options?: {
2713
+ stripPunctuation?: boolean;
2714
+ }): Promise<void>;
2715
+ /**
2716
+ * Returns the number of columns in the table.
2717
+ *
2718
+ * @returns A promise that resolves to a number representing the total count of columns.
2719
+ * @category Getting Data
2720
+ *
2721
+ * @example
2722
+ * ```ts
2723
+ * // Get the number of columns in the table
2724
+ * const nbColumns = await table.getNbColumns();
2725
+ * console.log(nbColumns); // e.g., 3
2726
+ * ```
2727
+ */
2728
+ getNbColumns(): Promise<number>;
2729
+ /**
2730
+ * Returns the total number of characters in a column storing strings.
2731
+ *
2732
+ * @param column - The name of the string column to count characters from.
2733
+ * @returns A promise that resolves to the total number of characters across all rows in the specified column.
2734
+ * @category Getting Data
2735
+ *
2736
+ * @example
2737
+ * ```ts
2738
+ * // Get the total number of characters in the 'name' column
2739
+ * const totalChars = await table.getNbCharacters("name");
2740
+ * console.log(totalChars); // e.g., 523
2741
+ * ```
2742
+ */
2743
+ getNbCharacters(column: string): Promise<number>;
2744
+ /**
2745
+ * Returns the number of rows in the table.
2746
+ *
2747
+ * @returns A promise that resolves to a number representing the total count of rows.
2748
+ * @category Getting Data
2749
+ *
2750
+ * @example
2751
+ * ```ts
2752
+ * // Get the number of rows in the table
2753
+ * const nbRows = await table.getNbRows();
2754
+ * console.log(nbRows); // e.g., 100
2755
+ * ```
2756
+ */
2757
+ getNbRows(): Promise<number>;
2758
+ /**
2759
+ * Returns the total number of values in the table (number of columns multiplied by the number of rows).
2760
+ *
2761
+ * @returns A promise that resolves to a number representing the total count of values.
2762
+ * @category Getting Data
2763
+ *
2764
+ * @example
2765
+ * ```ts
2766
+ * // Get the total number of values in the table
2767
+ * const nbValues = await table.getNbValues();
2768
+ * console.log(nbValues); // e.g., 300 (if 3 columns and 100 rows)
2769
+ * ```
2770
+ */
2771
+ getNbValues(): Promise<number>;
2772
+ /**
2773
+ * Returns the data types of all columns in the table.
2774
+ *
2775
+ * @returns A promise that resolves to an object where keys are column names and values are their corresponding data types (e.g., `{ "id": "BIGINT", "name": "VARCHAR" }`).
2776
+ * @category Getting Data
2777
+ *
2778
+ * @example
2779
+ * ```ts
2780
+ * // Get the data types of all columns
2781
+ * const dataTypes = await table.getTypes();
2782
+ * console.log(dataTypes);
2783
+ * ```
2784
+ */
2785
+ getTypes(): Promise<{
2786
+ [key: string]: string;
2787
+ }>;
2788
+ /**
2789
+ * Returns all values from a specific column.
2790
+ *
2791
+ * @param column - The name of the column from which to retrieve values.
2792
+ * @returns A promise that resolves to an array containing all values from the specified column.
2793
+ * @category Getting Data
2794
+ *
2795
+ * @example
2796
+ * ```ts
2797
+ * // Get all values from the 'productName' column
2798
+ * const productNames = await table.getValues("productName");
2799
+ * console.log(productNames); // e.g., ["Laptop", "Mouse", "Keyboard"]
2800
+ * ```
2801
+ */
2802
+ getValues(column: string): Promise<(string | number | boolean | Date | null)[]>;
2803
+ /**
2804
+ * Returns the minimum value from a specific column.
2805
+ *
2806
+ * @param column - The name of the column from which to retrieve the minimum value.
2807
+ * @returns A promise that resolves to the minimum value of the specified column.
2808
+ * @category Getting Data
2809
+ *
2810
+ * @example
2811
+ * ```ts
2812
+ * // Get the minimum value from the 'price' column
2813
+ * const minPrice = await table.getMin("price");
2814
+ * console.log(minPrice); // e.g., 10.50
2815
+ * ```
2816
+ */
2817
+ getMin(column: string): Promise<string | number | boolean | Date | null>;
2818
+ /**
2819
+ * Returns the maximum value from a specific column.
2820
+ *
2821
+ * @param column - The name of the column from which to retrieve the maximum value.
2822
+ * @returns A promise that resolves to the maximum value of the specified column.
2823
+ * @category Getting Data
2824
+ *
2825
+ * @example
2826
+ * ```ts
2827
+ * // Get the maximum value from the 'price' column
2828
+ * const maxPrice = await table.getMax("price");
2829
+ * console.log(maxPrice); // e.g., 99.99
2830
+ * ```
2831
+ */
2832
+ getMax(column: string): Promise<string | number | boolean | Date | null>;
2833
+ /**
2834
+ * Returns the extent (minimum and maximum values) of a specific column as an array.
2835
+ *
2836
+ * @param column - The name of the column from which to retrieve the extent.
2837
+ * @returns A promise that resolves to an array `[min, max]` containing the minimum and maximum values of the specified column.
2838
+ * @category Getting Data
2839
+ *
2840
+ * @example
2841
+ * ```ts
2842
+ * // Get the extent of the 'temperature' column
2843
+ * const tempExtent = await table.getExtent("temperature");
2844
+ * console.log(tempExtent); // e.g., [15.2, 30.1]
2845
+ * ```
2846
+ */
2847
+ getExtent(column: string): Promise<[
2848
+ string | number | boolean | Date | null,
2849
+ string | number | boolean | Date | null
2850
+ ]>;
2851
+ /**
2852
+ * Returns the mean (average) value from a specific numeric column.
2853
+ *
2854
+ * @param column - The name of the numeric column from which to retrieve the mean value.
2855
+ * @param options - An optional object with configuration options:
2856
+ * @param options.decimals - The number of decimal places to round the result to. Defaults to `undefined` (no rounding).
2857
+ * @returns A promise that resolves to the mean value of the specified column.
2858
+ * @category Getting Data
2859
+ *
2860
+ * @example
2861
+ * ```ts
2862
+ * // Get the mean of the 'age' column
2863
+ * const meanAge = await table.getMean("age");
2864
+ * console.log(meanAge); // e.g., 35.75
2865
+ * ```
2866
+ *
2867
+ * @example
2868
+ * ```ts
2869
+ * // Get the mean of the 'salary' column, rounded to 2 decimal places
2870
+ * const meanSalary = await table.getMean("salary", { decimals: 2 });
2871
+ * console.log(meanSalary); // e.g., 55000.23
2872
+ * ```
2873
+ */
2874
+ getMean(column: string, options?: {
2875
+ decimals?: number;
2876
+ }): Promise<number>;
2877
+ /**
2878
+ * Returns the median value from a specific numeric column.
2879
+ *
2880
+ * @param column - The name of the numeric column from which to retrieve the median value.
2881
+ * @param options - An optional object with configuration options:
2882
+ * @param options.decimals - The number of decimal places to round the result to. Defaults to `undefined` (no rounding).
2883
+ * @returns A promise that resolves to the median value of the specified column.
2884
+ * @category Getting Data
2885
+ *
2886
+ * @example
2887
+ * ```ts
2888
+ * // Get the median of the 'age' column
2889
+ * const medianAge = await table.getMedian("age");
2890
+ * console.log(medianAge); // e.g., 30
2891
+ * ```
2892
+ *
2893
+ * @example
2894
+ * ```ts
2895
+ * // Get the median of the 'salary' column, rounded to 2 decimal places
2896
+ * const medianSalary = await table.getMedian("salary", { decimals: 2 });
2897
+ * console.log(medianSalary); // e.g., 50000.00
2898
+ * ```
2899
+ */
2900
+ getMedian(column: string, options?: {
2901
+ decimals?: number;
2902
+ }): Promise<number>;
2903
+ /**
2904
+ * Returns the sum of values from a specific numeric column.
2905
+ *
2906
+ * @param column - The name of the numeric column from which to retrieve the sum.
2907
+ * @returns A promise that resolves to the sum of values in the specified column.
2908
+ * @category Getting Data
2909
+ *
2910
+ * @example
2911
+ * ```ts
2912
+ * // Get the sum of the 'quantity' column
2913
+ * const totalQuantity = await table.getSum("quantity");
2914
+ * console.log(totalQuantity); // e.g., 1250
2915
+ * ```
2916
+ */
2917
+ getSum(column: string): Promise<number>;
2918
+ /**
2919
+ * Returns the skewness of values from a specific numeric column.
2920
+ *
2921
+ * @param column - The name of the numeric column from which to retrieve the skewness.
2922
+ * @param options - An optional object with configuration options:
2923
+ * @param options.decimals - The number of decimal places to round the result to. Defaults to `undefined` (no rounding).
2924
+ * @returns A promise that resolves to the skewness value of the specified column.
2925
+ * @category Getting Data
2926
+ *
2927
+ * @example
2928
+ * ```ts
2929
+ * // Get the skewness of the 'data' column
2930
+ * const dataSkew = await table.getSkew("data");
2931
+ * console.log(dataSkew); // e.g., 0.5
2932
+ * ```
2933
+ *
2934
+ * @example
2935
+ * ```ts
2936
+ * // Get the skewness of the 'values' column, rounded to 2 decimal places
2937
+ * const valuesSkew = await table.getSkew("values", { decimals: 2 });
2938
+ * console.log(valuesSkew); // e.g., -0.25
2939
+ * ```
2940
+ */
2941
+ getSkew(column: string, options?: {
2942
+ decimals?: number;
2943
+ }): Promise<number>;
2944
+ /**
2945
+ * Returns the standard deviation of values from a specific numeric column.
2946
+ *
2947
+ * @param column - The name of the numeric column from which to retrieve the standard deviation.
2948
+ * @param options - An optional object with configuration options:
2949
+ * @param options.decimals - The number of decimal places to round the result to. Defaults to `undefined` (no rounding).
2950
+ * @returns A promise that resolves to the standard deviation value of the specified column.
2951
+ * @category Getting Data
2952
+ *
2953
+ * @example
2954
+ * ```ts
2955
+ * // Get the standard deviation of the 'height' column
2956
+ * const heightStdDev = await table.getStdDev("height");
2957
+ * console.log(heightStdDev); // e.g., 5.2
2958
+ * ```
2959
+ *
2960
+ * @example
2961
+ * ```ts
2962
+ * // Get the standard deviation of the 'score' column, rounded to 3 decimal places
2963
+ * const scoreStdDev = await table.getStdDev("score", { decimals: 3 });
2964
+ * console.log(scoreStdDev); // e.g., 12.345
2965
+ * ```
2966
+ */
2967
+ getStdDev(column: string, options?: {
2968
+ decimals?: number;
2969
+ }): Promise<number>;
2970
+ /**
2971
+ * Returns the variance of values from a specific numeric column.
2972
+ *
2973
+ * @param column - The name of the numeric column from which to retrieve the variance.
2974
+ * @param options - An optional object with configuration options:
2975
+ * @param options.decimals - The number of decimal places to round the result to. Defaults to `undefined` (no rounding).
2976
+ * @returns A promise that resolves to the variance value of the specified column.
2977
+ * @category Getting Data
2978
+ *
2979
+ * @example
2980
+ * ```ts
2981
+ * // Get the variance of the 'data' column
2982
+ * const dataVariance = await table.getVar("data");
2983
+ * console.log(dataVariance); // e.g., 25.5
2984
+ * ```
2985
+ *
2986
+ * @example
2987
+ * ```ts
2988
+ * // Get the variance of the 'values' column, rounded to 2 decimal places
2989
+ * const valuesVariance = await table.getVar("values", { decimals: 2 });
2990
+ * console.log(valuesVariance); // e.g., 10.23
2991
+ * ```
2992
+ */
2993
+ getVar(column: string, options?: {
2994
+ decimals?: number;
2995
+ }): Promise<number>;
2996
+ /**
2997
+ * Returns the value of a specific quantile from the values in a given numeric column.
2998
+ *
2999
+ * @param column - The name of the numeric column from which to calculate the quantile.
3000
+ * @param quantile - The quantile to calculate, expressed as a number between 0 and 1 (e.g., `0.25` for the first quartile, `0.5` for the median, `0.75` for the third quartile).
3001
+ * @param options - An optional object with configuration options:
3002
+ * @param options.decimals - The number of decimal places to round the result to. Defaults to `undefined` (no rounding).
3003
+ * @returns A promise that resolves to the quantile value of the specified column.
3004
+ * @category Getting Data
3005
+ *
3006
+ * @example
3007
+ * ```ts
3008
+ * // Get the first quartile (25th percentile) of 'column1'
3009
+ * const firstQuartile = await table.getQuantile("column1", 0.25);
3010
+ * console.log(firstQuartile); // e.g., 15.7
3011
+ * ```
3012
+ *
3013
+ * @example
3014
+ * ```ts
3015
+ * // Get the 90th percentile of 'score' values, rounded to 2 decimal places
3016
+ * const ninetiethPercentile = await table.getQuantile("score", 0.9, { decimals: 2 });
3017
+ * console.log(ninetiethPercentile); // e.g., 88.55
3018
+ * ```
3019
+ */
3020
+ getQuantile(column: string, quantile: number, options?: {
3021
+ decimals?: number;
3022
+ }): Promise<number>;
3023
+ /**
3024
+ * Returns unique values from a specific column. The values are returned in ascending order.
3025
+ *
3026
+ * @param column - The name of the column from which to retrieve unique values.
3027
+ * @returns A promise that resolves to an array containing the unique values from the specified column, sorted in ascending order.
3028
+ * @category Getting Data
3029
+ *
3030
+ * @example
3031
+ * ```ts
3032
+ * // Get unique values from the 'category' column
3033
+ * const uniqueCategories = await table.getUniques("category");
3034
+ * console.log(uniqueCategories); // e.g., ["Books", "Clothing", "Electronics"]
3035
+ * ```
3036
+ */
3037
+ getUniques(column: string): Promise<(string | number | boolean | Date | null)[]>;
3038
+ /**
3039
+ * Returns the first row of the table, optionally filtered by SQL conditions.
3040
+ * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
3041
+ *
3042
+ * @param options - An optional object with configuration options:
3043
+ * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Book'"`).
3044
+ * @returns A promise that resolves to an object representing the first row, or `null` if no rows match the conditions.
3045
+ * @category Getting Data
3046
+ *
3047
+ * @example
3048
+ * ```ts
3049
+ * // Get the very first row of the table
3050
+ * const firstRow = await table.getFirstRow();
3051
+ * console.log(firstRow);
3052
+ * ```
3053
+ *
3054
+ * @example
3055
+ * ```ts
3056
+ * // Get the first row where the 'category' is 'Book'
3057
+ * const firstRowBooks = await table.getFirstRow({ conditions: `category === 'Book'` }); // Using JS syntax
3058
+ * console.log(firstRowBooks);
3059
+ * ```
3060
+ */
3061
+ getFirstRow(options?: {
3062
+ conditions?: string;
3063
+ }): Promise<{
3064
+ [key: string]: string | number | boolean | Date | null;
3065
+ }>;
3066
+ /**
3067
+ * Returns the last row of the table, optionally filtered by SQL conditions.
3068
+ * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
3069
+ *
3070
+ * @param options - An optional object with configuration options:
3071
+ * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Book'"`).
3072
+ * @returns A promise that resolves to an object representing the last row, or `null` if no rows match the conditions.
3073
+ * @category Getting Data
3074
+ *
3075
+ * @example
3076
+ * ```ts
3077
+ * // Get the very last row of the table
3078
+ * const lastRow = await table.getLastRow();
3079
+ * console.log(lastRow);
3080
+ * ```
3081
+ *
3082
+ * @example
3083
+ * ```ts
3084
+ * // Get the last row where the 'category' is 'Book'
3085
+ * const lastRowBooks = await table.getLastRow({ conditions: `category === 'Book'` }); // Using JS syntax
3086
+ * console.log(lastRowBooks);
3087
+ * ```
3088
+ */
3089
+ getLastRow(options?: {
3090
+ conditions?: string;
3091
+ }): Promise<{
3092
+ [key: string]: string | number | boolean | Date | null;
3093
+ }>;
3094
+ /**
3095
+ * Returns the top `n` rows of the table, optionally filtered by SQL conditions.
3096
+ * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
3097
+ *
3098
+ * @param count - The number of rows to return from the top of the table.
3099
+ * @param options - An optional object with configuration options:
3100
+ * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Books'"`).
3101
+ * @returns A promise that resolves to an array of objects representing the top `n` rows.
3102
+ * @category Getting Data
3103
+ *
3104
+ * @example
3105
+ * ```ts
3106
+ * // Get the first 10 rows of the table
3107
+ * const top10 = await table.getTop(10);
3108
+ * console.log(top10);
3109
+ * ```
3110
+ *
3111
+ * @example
3112
+ * ```ts
3113
+ * // Get the first 5 rows where the 'category' is 'Books'
3114
+ * const top5Books = await table.getTop(5, { conditions: `category === 'Books'` }); // Using JS syntax
3115
+ * console.log(top5Books);
3116
+ * ```
3117
+ */
3118
+ getTop(count: number, options?: {
3119
+ conditions?: string;
3120
+ }): Promise<{
3121
+ [key: string]: string | number | boolean | Date | null;
3122
+ }[]>;
3123
+ /**
3124
+ * Returns the bottom `n` rows of the table, optionally filtered by SQL conditions.
3125
+ * By default, the last row will be returned first. To preserve the original order, use the `originalOrder` option.
3126
+ * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
3127
+ *
3128
+ * @param count - The number of rows to return from the bottom of the table.
3129
+ * @param options - An optional object with configuration options:
3130
+ * @param options.originalOrder - A boolean indicating whether the rows should be returned in their original order (`true`) or in reverse order (last row first, `false`). Defaults to `false`.
3131
+ * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Books'"`).
3132
+ * @returns A promise that resolves to an array of objects representing the bottom `n` rows.
3133
+ * @category Getting Data
3134
+ *
3135
+ * @example
3136
+ * ```ts
3137
+ * // Get the last 10 rows (last row first)
3138
+ * const bottom10 = await table.getBottom(10);
3139
+ * console.log(bottom10);
3140
+ * ```
3141
+ *
3142
+ * @example
3143
+ * ```ts
3144
+ * // Get the last 10 rows in their original order
3145
+ * const bottom10OriginalOrder = await table.getBottom(10, { originalOrder: true });
3146
+ * console.log(bottom10OriginalOrder);
3147
+ * ```
3148
+ *
3149
+ * @example
3150
+ * ```ts
3151
+ * // Get the last 5 rows where the 'category' is 'Books' (using JS syntax)
3152
+ * const bottom5Books = await table.getBottom(5, { conditions: `category === 'Books'` });
3153
+ * console.log(bottom5Books);
3154
+ * ```
3155
+ */
3156
+ getBottom(count: number, options?: {
3157
+ originalOrder?: boolean;
3158
+ conditions?: string;
3159
+ }): Promise<{
3160
+ [key: string]: string | number | boolean | Date | null;
3161
+ }[]>;
3162
+ /**
3163
+ * 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.
3164
+ * You can also use JavaScript syntax for conditions (e.g., `AND`, `||`, `===`, `!==`).
3165
+ *
3166
+ * @param conditions - The conditions to match, specified as a SQL `WHERE` clause.
3167
+ * @param options - Optional settings:
3168
+ * @param options.noCheck - If `true`, no error will be thrown when no row or more than one row match the condition. Defaults to `false`.
3169
+ * @returns A promise that resolves to an object representing the matched row.
3170
+ * @throws {Error} If `noCheck` is `false` and no row or more than one row matches the conditions.
3171
+ * @category Getting Data
3172
+ *
3173
+ * @example
3174
+ * ```ts
3175
+ * // Get a row where 'name' is 'John'
3176
+ * const johnsRow = await table.getRow(`name = 'John'`);
3177
+ * console.log(johnsRow);
3178
+ * ```
3179
+ *
3180
+ * @example
3181
+ * ```ts
3182
+ * // Get a row where 'id' is 123 (using JS syntax)
3183
+ * const rowById = await table.getRow(`id === 123`);
3184
+ * console.log(rowById);
3185
+ * ```
3186
+ *
3187
+ * @example
3188
+ * ```ts
3189
+ * // Get a row without throwing an error if multiple matches or no match
3190
+ * const flexibleRow = await table.getRow(`status = 'pending'`, { noCheck: true });
3191
+ * console.log(flexibleRow);
3192
+ * ```
3193
+ */
3194
+ getRow(conditions: string, options?: {
3195
+ noCheck?: boolean;
3196
+ }): Promise<{
3197
+ [key: string]: string | number | boolean | Date | null;
3198
+ } | undefined>;
3199
+ /**
3200
+ * Returns the data from the table as an array of objects, optionally filtered by SQL conditions.
3201
+ * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
3202
+ *
3203
+ * @param options - An optional object with configuration options:
3204
+ * @param options.columns - An array of column names to include in the result. If omitted, all columns will be included.
3205
+ * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Book'"`).
3206
+ * @returns A promise that resolves to an array of objects, where each object represents a row in the table.
3207
+ * @category Getting Data
3208
+ *
3209
+ * @example
3210
+ * ```ts
3211
+ * // Get all data from the table
3212
+ * const allData = await table.getData();
3213
+ * console.log(allData);
3214
+ * ```
3215
+ *
3216
+ * @example
3217
+ * ```ts
3218
+ * // Get data filtered by a condition (using JS or SQL syntax)
3219
+ * const booksData = await table.getData({ conditions: `category === 'Book'` });
3220
+ * console.log(booksData);
3221
+ * ```
3222
+ *
3223
+ * @example
3224
+ * ```ts
3225
+ * // Get data filtered by a condition and specific columns
3226
+ * const booksData = await table.getData({ columns: ["title", "author"], conditions: `category === 'Book'` });
3227
+ * console.log(booksData);
3228
+ * ```
3229
+ */
3230
+ getData(options?: {
3231
+ columns?: string | string[];
3232
+ conditions?: string;
3233
+ }): Promise<{
3234
+ [key: string]: string | number | boolean | Date | null;
3235
+ }[]>;
3236
+ /**
3237
+ * Returns the data from the table as a CSV string, optionally filtered by SQL conditions.
3238
+ * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
3239
+ *
3240
+ * @param options - An optional object with configuration options:
3241
+ * @param options.columns - An array of column names to include in the CSV. If omitted, all columns will be included.
3242
+ * @param options.conditions - The filtering conditions specified as a SQL `WHERE` clause (e.g., `"category = 'Book'"`).
3243
+ * @returns A promise that resolves to a CSV-formatted string representation of the table data.
3244
+ * @category Getting Data
3245
+ *
3246
+ * @example
3247
+ * ```ts
3248
+ * // Get all data from the table as CSV
3249
+ * const allDataCSV = await table.getDataAsCSV();
3250
+ * console.log(allDataCSV);
3251
+ * ```
3252
+ *
3253
+ * @example
3254
+ * ```ts
3255
+ * // Get data filtered by a condition (using JS syntax or SQL syntax) as CSV
3256
+ * const booksDataCSV = await table.getDataAsCSV({ conditions: `category === 'Book'` });
3257
+ * console.log(booksDataCSV);
3258
+ * ```
3259
+ *
3260
+ * @example
3261
+ * ```ts
3262
+ * // Get data filtered by a condition and specific columns as CSV
3263
+ * const booksDataCSV = await table.getDataAsCSV({ columns: ["title", "author"], conditions: `category === 'Book'` });
3264
+ * console.log(booksDataCSV);
3265
+ * ```
3266
+ */
3267
+ getDataAsCSV(options?: {
3268
+ columns?: string | string[];
3269
+ conditions?: string;
3270
+ }): Promise<string>;
3271
+ /**
3272
+ * Creates point geometries from longitude and latitude columns. The geometries will have `[latitude, longitude]` axis order.
3273
+ *
3274
+ * @param columnLat - The name of the column storing the latitude values.
3275
+ * @param columnLon - The name of the column storing the longitude values.
3276
+ * @param newColumn - The name of the new column where the point geometries will be stored.
3277
+ * @returns A promise that resolves when the point geometries have been created.
3278
+ * @category Geospatial
3279
+ *
3280
+ * @example
3281
+ * ```ts
3282
+ * // Create point geometries in a new 'geom' column using 'lat' and 'lon' columns
3283
+ * await table.points("lat", "lon", "geom");
3284
+ * ```
3285
+ */
3286
+ points(columnLat: string, columnLon: string, newColumn: string): Promise<void>;
3287
+ /**
3288
+ * Adds a column with boolean values indicating the validity of geometries.
3289
+ *
3290
+ * @param newColumn - The name of the new column where the boolean results (`TRUE` for valid, `FALSE` for invalid) will be stored.
3291
+ * @param options - An optional object with configuration options:
3292
+ * @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.
3293
+ * @returns A promise that resolves when the validity check is complete.
3294
+ * @category Geospatial
3295
+ *
3296
+ * @example
3297
+ * ```ts
3298
+ * // Check if geometries are valid and store results in a new 'isValid' column
3299
+ * // The method will automatically detect the geometry column.
3300
+ * await table.isValidGeo("isValid");
3301
+ * ```
3302
+ *
3303
+ * @example
3304
+ * ```ts
3305
+ * // Check validity of geometries in a specific column named 'myGeom'
3306
+ * await table.isValidGeo("isValidMyGeom", { column: "myGeom" });
3307
+ * ```
3308
+ */
3309
+ isValidGeo(newColumn: string, options?: {
3310
+ column?: string;
3311
+ }): Promise<void>;
3312
+ /**
3313
+ * Adds a column with the number of vertices (points) in each geometry.
3314
+ *
3315
+ * @param newColumn - The name of the new column where the vertex counts will be stored.
3316
+ * @param options - An optional object with configuration options:
3317
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3318
+ * @returns A promise that resolves when the vertex counts have been added.
3319
+ * @category Geospatial
3320
+ *
3321
+ * @example
3322
+ * ```ts
3323
+ * // Add a new column 'vertexCount' with the number of vertices for each geometry
3324
+ * // The method will automatically detect the geometry column.
3325
+ * await table.nbVertices("vertexCount");
3326
+ * ```
3327
+ *
3328
+ * @example
3329
+ * ```ts
3330
+ * // Add vertex counts for geometries in a specific column named 'myGeom'
3331
+ * await table.nbVertices("myGeomVertices", { column: "myGeom" });
3332
+ * ```
3333
+ */
3334
+ nbVertices(newColumn: string, options?: {
3335
+ column?: string;
3336
+ }): Promise<void>;
3337
+ /**
3338
+ * Attempts to make invalid geometries valid without removing any vertices.
3339
+ *
3340
+ * @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.
3341
+ * @returns A promise that resolves when the geometries have been processed.
3342
+ * @category Geospatial
3343
+ *
3344
+ * @example
3345
+ * ```ts
3346
+ * // Fix invalid geometries in the default geometry column
3347
+ * await table.fixGeo();
3348
+ * ```
3349
+ *
3350
+ * @example
3351
+ * ```ts
3352
+ * // Fix invalid geometries in a specific column named 'myGeom'
3353
+ * await table.fixGeo("myGeom");
3354
+ * ```
3355
+ */
3356
+ fixGeo(column?: string): Promise<void>;
3357
+ /**
3358
+ * Adds a column with boolean values indicating whether geometries are closed (e.g., polygons) or open (e.g., linestrings).
3359
+ *
3360
+ * @param newColumn - The name of the new column where the boolean results (`TRUE` for closed, `FALSE` for open) will be stored.
3361
+ * @param options - An optional object with configuration options:
3362
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3363
+ * @returns A promise that resolves when the closed geometry check is complete.
3364
+ * @category Geospatial
3365
+ *
3366
+ * @example
3367
+ * ```ts
3368
+ * // Check if geometries are closed and store results in a new 'isClosed' column
3369
+ * await table.isClosedGeo("isClosed");
3370
+ * ```
3371
+ *
3372
+ * @example
3373
+ * ```ts
3374
+ * // Check closed status of geometries in a specific column named 'boundaryGeom'
3375
+ * await table.isClosedGeo("boundaryClosed", { column: "boundaryGeom" });
3376
+ * ```
3377
+ */
3378
+ isClosedGeo(newColumn: string, options?: {
3379
+ column?: string;
3380
+ }): Promise<void>;
3381
+ /**
3382
+ * Adds a column with the geometry type (e.g., `"POINT"`, `"LINESTRING"`, `"POLYGON"`) for each geometry.
3383
+ *
3384
+ * @param newColumn - The name of the new column where the geometry types will be stored.
3385
+ * @param options - An optional object with configuration options:
3386
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3387
+ * @returns A promise that resolves when the geometry types have been added.
3388
+ * @category Geospatial
3389
+ *
3390
+ * @example
3391
+ * ```ts
3392
+ * // Add a new column 'geometryType' with the type of each geometry
3393
+ * await table.typeGeo("geometryType");
3394
+ * ```
3395
+ *
3396
+ * @example
3397
+ * ```ts
3398
+ * // Get the geometry type for geometries in a specific column named 'featureGeom'
3399
+ * await table.typeGeo("featureType", { column: "featureGeom" });
3400
+ * ```
3401
+ */
3402
+ typeGeo(newColumn: string, options?: {
3403
+ column?: string;
3404
+ }): Promise<void>;
3405
+ /**
3406
+ * Flips the coordinate order of geometries in a specified column (e.g., from `[lon, lat]` to `[lat, lon]` or vice-versa).
3407
+ * **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. It also messes up with the projections stored in `table.projections`.
3408
+ *
3409
+ * @param column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3410
+ * @returns A promise that resolves when the coordinates have been flipped.
3411
+ * @category Geospatial
3412
+ *
3413
+ * @example
3414
+ * ```ts
3415
+ * // Flip coordinates in the default geometry column
3416
+ * await table.flipCoordinates();
3417
+ * ```
3418
+ *
3419
+ * @example
3420
+ * ```ts
3421
+ * // Flip coordinates in a specific column named 'myGeom'
3422
+ * await table.flipCoordinates("myGeom");
3423
+ * ```
3424
+ */
3425
+ flipCoordinates(column?: string): Promise<void>;
3426
+ /**
3427
+ * Reduces the precision of geometries in a specified column to a given number of decimal places.
3428
+ *
3429
+ * @param decimals - The number of decimal places to keep in the coordinates of the geometries.
3430
+ * @param options - An optional object with configuration options:
3431
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3432
+ * @returns A promise that resolves when the precision of the geometries has been reduced.
3433
+ * @category Geospatial
3434
+ *
3435
+ * @example
3436
+ * ```ts
3437
+ * // Reduce the precision of geometries in the default column to 3 decimal places
3438
+ * await table.reducePrecision(3);
3439
+ * ```
3440
+ *
3441
+ * @example
3442
+ * ```ts
3443
+ * // Reduce the precision of geometries in a specific column named 'myGeom' to 2 decimal places
3444
+ * await table.reducePrecision(2, { column: "myGeom" });
3445
+ * ```
3446
+ */
3447
+ reducePrecision(decimals: number, options?: {
3448
+ column?: string;
3449
+ }): Promise<void>;
3450
+ /**
3451
+ * Reprojects the geometries in a specified column to another Spatial Reference System (SRS).
3452
+ * If reprojecting to WGS84 (`"WGS84"` or `"EPSG:4326"`), the resulting geometries will have `[latitude, longitude]` axis order.
3453
+ *
3454
+ * @param to - The target SRS (e.g., `"EPSG:3347"`, `"WGS84"`).
3455
+ * @param options - An optional object with configuration options:
3456
+ * @param options.from - The original projection of the geometries. If omitted, the method attempts to automatically detect it. Provide this option if auto-detection fails.
3457
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3458
+ * @returns A promise that resolves when the geometries have been reprojected.
3459
+ * @category Geospatial
3460
+ *
3461
+ * @example
3462
+ * ```ts
3463
+ * // Reproject geometries in the default column to EPSG:3347 (NAD83/Statistics Canada Lambert)
3464
+ * await table.reproject("EPSG:3347");
3465
+ * ```
3466
+ *
3467
+ * @example
3468
+ * ```ts
3469
+ * // Reproject geometries from EPSG:4326 to EPSG:3347, specifying the original projection
3470
+ * await table.reproject("EPSG:3347", { from: "EPSG:4326" });
3471
+ * ```
3472
+ *
3473
+ * @example
3474
+ * ```ts
3475
+ * // Reproject geometries in a specific column named 'myGeom' to EPSG:3347
3476
+ * await table.reproject("EPSG:3347", { column: "myGeom", from: "EPSG:4326" });
3477
+ * ```
3478
+ */
3479
+ reproject(to: string, options?: {
3480
+ from?: string;
3481
+ column?: string;
3482
+ }): Promise<void>;
3483
+ /**
3484
+ * Computes the area of geometries in square meters (`"m2"`) or optionally square kilometers (`"km2"`).
3485
+ * The input geometry is assumed to be in the EPSG:4326 coordinate system (WGS84), with `[latitude, longitude]` axis order.
3486
+ *
3487
+ * @param newColumn - The name of the new column where the computed areas will be stored.
3488
+ * @param options - An optional object with configuration options:
3489
+ * @param options.unit - The unit for the computed area: `"m2"` (square meters) or `"km2"` (square kilometers). Defaults to `"m2"`.
3490
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3491
+ * @returns A promise that resolves when the areas have been computed.
3492
+ * @category Geospatial
3493
+ *
3494
+ * @example
3495
+ * ```ts
3496
+ * // Compute the area of geometries in square meters and store in 'area_m2'
3497
+ * await table.area("area_m2");
3498
+ * ```
3499
+ *
3500
+ * @example
3501
+ * ```ts
3502
+ * // Compute the area of geometries in square kilometers and store in 'area_km2'
3503
+ * await table.area("area_km2", { unit: "km2" });
3504
+ * ```
3505
+ *
3506
+ * @example
3507
+ * ```ts
3508
+ * // Compute the area of geometries in a specific column named 'myGeom'
3509
+ * await table.area("myGeomArea", { column: "myGeom" });
3510
+ * ```
3511
+ */
3512
+ area(newColumn: string, options?: {
3513
+ unit?: "m2" | "km2";
3514
+ column?: string;
3515
+ }): Promise<void>;
3516
+ /**
3517
+ * Computes the length of line geometries in meters (`"m"`) or optionally kilometers (`"km"`).
3518
+ * The input geometry is assumed to be in the EPSG:4326 coordinate system (WGS84), with `[latitude, longitude]` axis order.
3519
+ *
3520
+ * @param newColumn - The name of the new column where the computed lengths will be stored.
3521
+ * @param options - An optional object with configuration options:
3522
+ * @param options.unit - The unit for the computed length: `"m"` (meters) or `"km"` (kilometers). Defaults to `"m"`.
3523
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3524
+ * @returns A promise that resolves when the lengths have been computed.
3525
+ * @category Geospatial
3526
+ *
3527
+ * @example
3528
+ * ```ts
3529
+ * // Compute the length of line geometries in meters and store in 'length_m'
3530
+ * await table.length("length_m");
3531
+ * ```
3532
+ *
3533
+ * @example
3534
+ * ```ts
3535
+ * // Compute the length of line geometries in kilometers and store in 'length_km'
3536
+ * await table.length("length_km", { unit: "km" });
3537
+ * ```
3538
+ *
3539
+ * @example
3540
+ * ```ts
3541
+ * // Compute the length of geometries in a specific column named 'routeGeom'
3542
+ * await table.length("routeLength", { column: "routeGeom" });
3543
+ * ```
3544
+ */
3545
+ length(newColumn: string, options?: {
3546
+ unit?: "m" | "km";
3547
+ column?: string;
3548
+ }): Promise<void>;
3549
+ /**
3550
+ * Computes the perimeter of polygon geometries in meters (`"m"`) or optionally kilometers (`"km"`).
3551
+ * The input geometry is assumed to be in the EPSG:4326 coordinate system (WGS84), with `[latitude, longitude]` axis order.
3552
+ *
3553
+ * @param newColumn - The name of the new column where the computed perimeters will be stored.
3554
+ * @param options - An optional object with configuration options:
3555
+ * @param options.unit - The unit for the computed perimeter: `"m"` (meters) or `"km"` (kilometers). Defaults to `"m"`.
3556
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3557
+ * @returns A promise that resolves when the perimeters have been computed.
3558
+ * @category Geospatial
3559
+ *
3560
+ * @example
3561
+ * ```ts
3562
+ * // Compute the perimeter of polygon geometries in meters and store in 'perimeter_m'
3563
+ * await table.perimeter("perimeter_m");
3564
+ * ```
3565
+ *
3566
+ * @example
3567
+ * ```ts
3568
+ * // Compute the perimeter of polygon geometries in kilometers and store in 'perimeter_km'
3569
+ * await table.perimeter("perimeter_km", { unit: "km" });
3570
+ * ```
3571
+ *
3572
+ * @example
3573
+ * ```ts
3574
+ * // Compute the perimeter of geometries in a specific column named 'landParcelGeom'
3575
+ * await table.perimeter("landParcelPerimeter", { column: "landParcelGeom" });
3576
+ * ```
3577
+ */
3578
+ perimeter(newColumn: string, options?: {
3579
+ unit?: "m" | "km";
3580
+ column?: string;
3581
+ }): Promise<void>;
3582
+ /**
3583
+ * Computes a buffer (a polygon representing a specified distance around a geometry) for geometries in a specified column.
3584
+ * The distance is in the Spatial Reference System (SRS) unit of the input geometries.
3585
+ *
3586
+ * @param newColumn - The name of the new column where the buffered geometries will be stored.
3587
+ * @param distance - The distance for the buffer. This value is in the units of the geometry's SRS.
3588
+ * @param options - An optional object with configuration options:
3589
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3590
+ * @returns A promise that resolves when the buffers have been computed.
3591
+ * @category Geospatial
3592
+ *
3593
+ * @example
3594
+ * ```ts
3595
+ * // Create a buffer of 1 unit around geometries in the default column, storing results in 'bufferedGeom'
3596
+ * await table.buffer("bufferedGeom", 1);
3597
+ * ```
3598
+ *
3599
+ * @example
3600
+ * ```ts
3601
+ * // Create a buffer of 10 units around geometries in a specific column named 'pointsGeom'
3602
+ * await table.buffer("pointsBuffer", 10, { column: "pointsGeom" });
3603
+ * ```
3604
+ */
3605
+ buffer(newColumn: string, distance: number, options?: {
3606
+ column?: string;
3607
+ }): Promise<void>;
3608
+ /**
3609
+ * Merges the data of this table (considered the left table) with another table (the right table) based on a spatial relationship.
3610
+ * Note that the order of rows in the returned data is not guaranteed to be the same as in the original tables.
3611
+ * This operation might create temporary files in a `.tmp` folder; consider adding `.tmp` to your `.gitignore`.
3612
+ *
3613
+ * @param rightTable - The SimpleTable instance to be joined with this table.
3614
+ * @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 `"within"` (geometries of the left table are within a specified distance of geometries in the right table).
3615
+ * @param options - An optional object with configuration options:
3616
+ * @param options.leftTableColumn - The name of the column storing geometries in the left table (this table). If omitted, the method attempts to find one.
3617
+ * @param options.rightTableColumn - The name of the column storing geometries in the right table. If omitted, the method attempts to find one.
3618
+ * @param options.type - The type of join operation to perform: `"inner"`, `"left"` (default), `"right"`, or `"full"`. For some types (like `"inside"`), the table order is important.
3619
+ * @param options.distance - Required if `method` is `"within"`. The target distance for the spatial join. The unit depends on `distanceMethod`.
3620
+ * @param options.distanceMethod - The method for distance calculations: `"srs"` (default, uses the SRS unit), `"haversine"` (uses meters, requires EPSG:4326 input), or `"spheroid"` (uses meters, requires EPSG:4326 input, most accurate but slowest).
3621
+ * @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`.
3622
+ * @returns A promise that resolves to a table instance containing the spatially joined data (either the modified current table or a new table).
3623
+ * @category Geospatial
3624
+ *
3625
+ * @example
3626
+ * ```ts
3627
+ * // Merge data based on intersecting geometries, overwriting tableA
3628
+ * await tableA.joinGeo(tableB, "intersect");
3629
+ * ```
3630
+ *
3631
+ * @example
3632
+ * ```ts
3633
+ * // Merge data where geometries in tableA are inside geometries in tableB
3634
+ * await tableA.joinGeo(tableB, "inside");
3635
+ * ```
3636
+ *
3637
+ * @example
3638
+ * ```ts
3639
+ * // Merge data where geometries in tableA are within 10 units (SRS) of geometries in tableB
3640
+ * await tableA.joinGeo(tableB, "within", { distance: 10 });
3641
+ * ```
3642
+ *
3643
+ * @example
3644
+ * ```ts
3645
+ * // Merge data where geometries in tableA are within 10 kilometers (Haversine) of geometries in tableB
3646
+ * // Input geometries must be in EPSG:4326.
3647
+ * await tableA.joinGeo(tableB, "within", { distance: 10, distanceMethod: "haversine", unit: "km" });
3648
+ * ```
3649
+ *
3650
+ * @example
3651
+ * ```ts
3652
+ * // Merge data with specific geometry columns and an inner join type, storing results in a new table
3653
+ * const tableC = await tableA.joinGeo(tableB, "intersect", {
3654
+ * leftTableColumn: "geometriesA",
3655
+ * rightTableColumn: "geometriesB",
3656
+ * type: "inner",
3657
+ * outputTable: true,
3658
+ * });
3659
+ * ```
3660
+ */
3661
+ joinGeo(rightTable: SimpleTable, method: "intersect" | "inside" | "within", options?: {
3662
+ leftTableColumn?: string;
3663
+ rightTableColumn?: string;
3664
+ type?: "inner" | "left" | "right" | "full";
3665
+ distance?: number;
3666
+ distanceMethod?: "srs" | "haversine" | "spheroid";
3667
+ outputTable?: string | boolean;
3668
+ }): Promise<this>;
3669
+ /**
3670
+ * Computes the intersection of two sets of geometries, creating new geometries where they overlap.
3671
+ *
3672
+ * @param column1 - The name of the first column storing geometries.
3673
+ * @param column2 - The name of the second column storing geometries. Both columns must have the same projection.
3674
+ * @param newColumn - The name of the new column where the computed intersection geometries will be stored.
3675
+ * @returns A promise that resolves when the intersection geometries have been computed.
3676
+ * @category Geospatial
3677
+ *
3678
+ * @example
3679
+ * ```ts
3680
+ * // Compute the intersection of geometries in 'geomA' and 'geomB' columns, storing results in 'intersectGeom'
3681
+ * await table.intersection("geomA", "geomB", "intersectGeom");
3682
+ * ```
3683
+ */
3684
+ intersection(column1: string, column2: string, newColumn: string): Promise<void>;
3685
+ /**
3686
+ * Removes the intersection of two geometries from the first geometry, effectively computing the geometric difference.
3687
+ *
3688
+ * @param column1 - The name of the column storing the reference geometries. These geometries will have the intersection removed.
3689
+ * @param column2 - The name of the column storing the geometries used to compute the intersection. Both columns must have the same projection.
3690
+ * @param newColumn - The name of the new column where the resulting geometries (without the intersection) will be stored.
3691
+ * @returns A promise that resolves when the geometries have been processed.
3692
+ * @category Geospatial
3693
+ *
3694
+ * @example
3695
+ * ```ts
3696
+ * // Remove the intersection of 'geomB' from 'geomA', storing the result in 'geomA_minus_geomB'
3697
+ * await table.removeIntersection("geomA", "geomB", "geomA_minus_geomB");
3698
+ * ```
3699
+ */
3700
+ removeIntersection(column1: string, column2: string, newColumn: string): Promise<void>;
3701
+ /**
3702
+ * Fills holes in polygon geometries.
3703
+ *
3704
+ * @param column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3705
+ * @returns A promise that resolves when the holes have been filled.
3706
+ * @category Geospatial
3707
+ *
3708
+ * @example
3709
+ * ```ts
3710
+ * // Fill holes in geometries in the default geometry column
3711
+ * await table.fillHoles();
3712
+ * ```
3713
+ *
3714
+ * @example
3715
+ * ```ts
3716
+ * // Fill holes in geometries in a specific column named 'polygonGeom'
3717
+ * await table.fillHoles("polygonGeom");
3718
+ * ```
3719
+ */
3720
+ fillHoles(column?: string): Promise<void>;
3721
+ /**
3722
+ * Returns `TRUE` if two geometries intersect (overlap in any way), and `FALSE` otherwise.
3723
+ *
3724
+ * @param column1 - The name of the first column storing geometries.
3725
+ * @param column2 - The name of the second column storing geometries. Both columns must have the same projection.
3726
+ * @param newColumn - The name of the new column where the boolean results (`TRUE` for intersection, `FALSE` otherwise) will be stored.
3727
+ * @returns A promise that resolves when the intersection check is complete.
3728
+ * @category Geospatial
3729
+ *
3730
+ * @example
3731
+ * ```ts
3732
+ * // Check if geometries in 'geomA' and 'geomB' intersect, storing results in 'doIntersect'
3733
+ * await table.intersect("geomA", "geomB", "doIntersect");
3734
+ * ```
3735
+ */
3736
+ intersect(column1: string, column2: string, newColumn: string): Promise<void>;
3737
+ /**
3738
+ * Returns `TRUE` if all points of a geometry in `column1` lie inside a geometry in `column2`, and `FALSE` otherwise.
3739
+ *
3740
+ * @param column1 - The name of the column storing the geometries to be tested for containment.
3741
+ * @param column2 - The name of the column storing the geometries to be tested as containers. Both columns must have the same projection.
3742
+ * @param newColumn - The name of the new column where the boolean results (`TRUE` for inside, `FALSE` otherwise) will be stored.
3743
+ * @returns A promise that resolves when the containment check is complete.
3744
+ * @category Geospatial
3745
+ *
3746
+ * @example
3747
+ * ```ts
3748
+ * // Check if geometries in 'pointGeom' are inside 'polygonGeom', storing results in 'isInsidePolygon'
3749
+ * await table.inside("pointGeom", "polygonGeom", "isInsidePolygon");
3750
+ * ```
3751
+ */
3752
+ inside(column1: string, column2: string, newColumn: string): Promise<void>;
3753
+ /**
3754
+ * Computes the union of two geometries, creating a new geometry that represents the merged area of both.
3755
+ *
3756
+ * @param column1 - The name of the first column storing geometries.
3757
+ * @param column2 - The name of the second column storing geometries. Both columns must have the same projection.
3758
+ * @param newColumn - The name of the new column where the computed union geometries will be stored.
3759
+ * @returns A promise that resolves when the union geometries have been computed.
3760
+ * @category Geospatial
3761
+ *
3762
+ * @example
3763
+ * ```ts
3764
+ * // Compute the union of geometries in 'geomA' and 'geomB', storing results in 'unionGeom'
3765
+ * await table.union("geomA", "geomB", "unionGeom");
3766
+ * ```
3767
+ */
3768
+ union(column1: string, column2: string, newColumn: string): Promise<void>;
3769
+ /**
3770
+ * Extracts the latitude and longitude coordinates from point geometries.
3771
+ * The input geometry is assumed to be in the EPSG:4326 coordinate system (WGS84), with `[latitude, longitude]` axis order.
3772
+ *
3773
+ * @param column - The name of the column storing the point geometries.
3774
+ * @param columnLat - The name of the new column where the extracted latitude values will be stored.
3775
+ * @param columnLon - The name of the new column where the extracted longitude values will be stored.
3776
+ * @returns A promise that resolves when the latitude and longitude have been extracted.
3777
+ * @category Geospatial
3778
+ *
3779
+ * @example
3780
+ * ```ts
3781
+ * // Extract latitude and longitude from 'geom' column into new 'lat' and 'lon' columns
3782
+ * await table.latLon("geom", "lat", "lon");
3783
+ * ```
3784
+ */
3785
+ latLon(column: string, columnLat: string, columnLon: string): Promise<void>;
3786
+ /**
3787
+ * Simplifies geometries while preserving their overall coverage. A higher tolerance results in more significant simplification.
3788
+ *
3789
+ * @param tolerance - A numeric value representing the simplification tolerance. A higher value leads to greater simplification.
3790
+ * @param options - An optional object with configuration options:
3791
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3792
+ * @param options.simplifyBoundary - If `true` (default), the boundary of the geometries will also be simplified. If `false`, only the interior of the geometries will be simplified, preserving the original boundary.
3793
+ * @returns A promise that resolves when the geometries have been simplified.
3794
+ * @category Geospatial
3795
+ *
3796
+ * @example
3797
+ * ```ts
3798
+ * // Simplify geometries in the default column with a tolerance of 0.1
3799
+ * await table.simplify(0.1);
3800
+ * ```
3801
+ *
3802
+ * @example
3803
+ * ```ts
3804
+ * // Simplify geometries in 'myGeom' column, preserving the boundary
3805
+ * await table.simplify(0.05, { column: "myGeom", simplifyBoundary: false });
3806
+ * ```
3807
+ */
3808
+ simplify(tolerance: number, options?: {
3809
+ column?: string;
3810
+ simplifyBoundary?: boolean;
3811
+ }): Promise<void>;
3812
+ /**
3813
+ * Computes the centroid of geometries.
3814
+ * The values are returned in the SRS unit of the input geometries.
3815
+ *
3816
+ * @param newColumn - The name of the new column where the computed centroid geometries will be stored.
3817
+ * @param options - An optional object with configuration options:
3818
+ * @param options.column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3819
+ * @returns A promise that resolves when the centroids have been computed.
3820
+ * @category Geospatial
3821
+ *
3822
+ * @example
3823
+ * ```ts
3824
+ * // Compute the centroid of geometries in the default column, storing results in 'centerPoint'
3825
+ * await table.centroid("centerPoint");
3826
+ * ```
3827
+ *
3828
+ * @example
3829
+ * ```ts
3830
+ * // Compute the centroid of geometries in a specific column named 'areaGeom'
3831
+ * await table.centroid("areaCentroid", { column: "areaGeom" });
3832
+ * ```
3833
+ */
3834
+ centroid(newColumn: string, options?: {
3835
+ column?: string;
3836
+ }): Promise<void>;
3837
+ /**
3838
+ * Computes the distance between geometries in two specified columns.
3839
+ * By default, the distance is calculated in the Spatial Reference System (SRS) unit of the input geometries.
3840
+ * You can optionally specify `"spheroid"` or `"haversine"` methods to get results in meters or kilometers.
3841
+ * If using `"spheroid"` or `"haversine"`, the input geometries must be in the EPSG:4326 coordinate system (WGS84), with `[latitude, longitude]` axis order.
3842
+ *
3843
+ * @param column1 - The name of the first column storing geometries.
3844
+ * @param column2 - The name of the second column storing geometries.
3845
+ * @param newColumn - The name of the new column where the computed distances will be stored.
3846
+ * @param options - An optional object with configuration options:
3847
+ * @param options.method - The method to use for distance calculations: `"srs"` (default, uses SRS unit), `"haversine"` (meters, requires EPSG:4326), or `"spheroid"` (meters, requires EPSG:4326, most accurate but slowest).
3848
+ * @param options.unit - If `method` is `"spheroid"` or `"haversine"`, you can choose between `"m"` (meters, default) or `"km"` (kilometers).
3849
+ * @param options.decimals - The number of decimal places to round the distance values. Defaults to `undefined` (no rounding).
3850
+ * @returns A promise that resolves when the distances have been computed.
3851
+ * @category Geospatial
3852
+ *
3853
+ * @example
3854
+ * ```ts
3855
+ * // Compute distance between 'geomA' and 'geomB' in SRS units, store in 'distance_srs'
3856
+ * await table.distance("geomA", "geomB", "distance_srs");
3857
+ * ```
3858
+ *
3859
+ * @example
3860
+ * ```ts
3861
+ * // Compute Haversine distance in meters between 'point1' and 'point2', store in 'distance_m'
3862
+ * // Input geometries must be in EPSG:4326.
3863
+ * await table.distance("point1", "point2", "distance_m", { method: "haversine" });
3864
+ * ```
3865
+ *
3866
+ * @example
3867
+ * ```ts
3868
+ * // Compute Haversine distance in kilometers, rounded to 2 decimal places
3869
+ * // Input geometries must be in EPSG:4326.
3870
+ * await table.distance("point1", "point2", "distance_km", { method: "haversine", unit: "km", decimals: 2 });
3871
+ * ```
3872
+ *
3873
+ * @example
3874
+ * ```ts
3875
+ * // Compute Spheroid distance in kilometers
3876
+ * // Input geometries must be in EPSG:4326.
3877
+ * await table.distance("area1", "area2", "distance_spheroid_km", { method: "spheroid", unit: "km" });
3878
+ * ```
3879
+ */
3880
+ distance(column1: string, column2: string, newColumn: string, options?: {
3881
+ unit?: "m" | "km";
3882
+ method?: "srs" | "haversine" | "spheroid";
3883
+ decimals?: number;
3884
+ }): Promise<void>;
3885
+ /**
3886
+ * Unnests geometries recursively, transforming multi-part geometries (e.g., MultiPolygon) into individual single-part geometries (e.g., Polygon).
3887
+ *
3888
+ * @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.
3889
+ * @returns A promise that resolves when the geometries have been unnested.
3890
+ * @category Geospatial
3891
+ *
3892
+ * @example
3893
+ * ```ts
3894
+ * // Unnest geometries in the default column
3895
+ * await table.unnestGeo();
3896
+ * ```
3897
+ *
3898
+ * @example
3899
+ * ```ts
3900
+ * // Unnest geometries in a specific column named 'multiGeom'
3901
+ * await table.unnestGeo("multiGeom");
3902
+ * ```
3903
+ */
3904
+ unnestGeo(column?: string): Promise<void>;
3905
+ /**
3906
+ * Aggregates geometries in a specified column based on a chosen aggregation method.
3907
+ *
3908
+ * @param method - The aggregation method to apply: `"union"` (combines all geometries into a single multi-geometry) or `"intersection"` (computes the intersection of all geometries).
3909
+ * @param options - An optional object with configuration options:
3910
+ * @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.
3911
+ * @param options.categories - The column name or an array of column names that define categories for the aggregation. Aggregation will be performed independently within each category.
3912
+ * @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`.
3913
+ * @returns A promise that resolves to a table instance containing the aggregated geometries (either the modified current table or a new table).
3914
+ * @category Geospatial
3915
+ *
3916
+ * @example
3917
+ * ```ts
3918
+ * // Aggregate all geometries in the default column into a single union geometry
3919
+ * await table.aggregateGeo("union");
3920
+ * ```
3921
+ *
3922
+ * @example
3923
+ * ```ts
3924
+ * // Aggregate geometries by 'country' and compute their union
3925
+ * await table.aggregateGeo("union", { categories: "country" });
3926
+ * ```
3927
+ *
3928
+ * @example
3929
+ * ```ts
3930
+ * // Aggregate geometries in 'regions' column into their intersection, storing results in a new table
3931
+ * const intersectionTable = await table.aggregateGeo("intersection", { column: "regions", outputTable: true });
3932
+ * ```
3933
+ */
3934
+ aggregateGeo(method: "union" | "intersection", options?: {
3935
+ column?: string;
3936
+ categories?: string | string[];
3937
+ outputTable?: string | boolean;
3938
+ }): Promise<this>;
3939
+ /**
3940
+ * Transforms closed linestring geometries into polygon geometries.
3941
+ *
3942
+ * @param column - The name of the column storing the linestring geometries. If omitted, the method will automatically attempt to find a geometry column.
3943
+ * @returns A promise that resolves when the transformation is complete.
3944
+ * @category Geospatial
3945
+ *
3946
+ * @example
3947
+ * ```ts
3948
+ * // Transform closed linestrings in the default geometry column into polygons
3949
+ * await table.linesToPolygons();
3950
+ * ```
3951
+ *
3952
+ * @example
3953
+ * ```ts
3954
+ * // Transform closed linestrings in a specific column named 'routeLines' into polygons
3955
+ * await table.linesToPolygons("routeLines");
3956
+ * ```
3957
+ */
3958
+ linesToPolygons(column?: string): Promise<void>;
3959
+ /**
3960
+ * Returns the bounding box of geometries in `[minLat, minLon, maxLat, maxLon]` order.
3961
+ * By default, the method will try to find the column with the geometries. The input geometry is assumed to be in the EPSG:4326 coordinate system (WGS84), with `[latitude, longitude]` axis order.
3962
+ *
3963
+ * @param column - The name of the column storing geometries. If omitted, the method will automatically attempt to find a geometry column.
3964
+ * @returns A promise that resolves to an array `[minLat, minLon, maxLat, maxLon]` representing the bounding box.
3965
+ * @category Geospatial
3966
+ *
3967
+ * @example
3968
+ * ```ts
3969
+ * // Get the bounding box of geometries in the default column
3970
+ * const bbox = await table.getBoundingBox();
3971
+ * console.log(bbox); // e.g., [45.0, -75.0, 46.0, -73.0]
3972
+ * ```
3973
+ *
3974
+ * @example
3975
+ * ```ts
3976
+ * // Get the bounding box of geometries in a specific column named 'areaGeom'
3977
+ * const areaBbox = await table.getBoundingBox("areaGeom");
3978
+ * console.log(areaBbox);
3979
+ * ```
3980
+ */
3981
+ getBoundingBox(column?: string): Promise<[number, number, number, number]>;
3982
+ /**
3983
+ * Returns the table's geospatial data as a GeoJSON object.
3984
+ * If the table has multiple geometry columns, you must specify which one to use.
3985
+ * If the geometry column's projection is WGS84 or EPSG:4326 (`[latitude, longitude]` axis order), the coordinates will be flipped to follow the RFC7946 standard (`[longitude, latitude]` axis order) in the output GeoJSON.
3986
+ *
3987
+ * @param column - The name of the column storing the geometries. If omitted, the method will automatically attempt to find a geometry column.
3988
+ * @param options - An optional object with configuration options:
3989
+ * @param options.rewind - If `true`, rewinds the coordinates of polygons to follow the spherical winding order (important for D3.js). Defaults to `false`.
3990
+ * @returns A promise that resolves to a GeoJSON object representing the table's geospatial data.
3991
+ * @category Getting Data
3992
+ *
3993
+ * @example
3994
+ * ```ts
3995
+ * // Get GeoJSON data from the default geometry column
3996
+ * const geojson = await table.getGeoData();
3997
+ * console.log(geojson);
3998
+ * ```
3999
+ *
4000
+ * @example
4001
+ * ```ts
4002
+ * // Get GeoJSON data from a specific geometry column named 'myGeometries'
4003
+ * const myGeomJson = await table.getGeoData("myGeometries");
4004
+ * console.log(myGeomJson);
4005
+ * ```
4006
+ *
4007
+ * @example
4008
+ * ```ts
4009
+ * // Get GeoJSON data and rewind polygon coordinates for D3.js compatibility
4010
+ * const rewoundGeojson = await table.getGeoData(undefined, { rewind: true });
4011
+ * console.log(rewoundGeojson);
4012
+ * ```
4013
+ */
4014
+ getGeoData(column?: string, options?: {
4015
+ rewind?: boolean;
4016
+ }): Promise<{
4017
+ type: string;
4018
+ features: unknown[];
4019
+ }>;
4020
+ /**
4021
+ * Writes the table's data to a file in various formats (CSV, JSON, Parquet, DuckDB, SQLite).
4022
+ * If the specified path does not exist, it will be created.
4023
+ *
4024
+ * @param file - The absolute path to the output file (e.g., `"./output.csv"`, `"./output.json"`).
4025
+ * @param options - An optional object with configuration options:
4026
+ * @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`.
4027
+ * @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.
4028
+ * @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`.
4029
+ * @returns A promise that resolves when the data has been written to the file.
4030
+ * @category File Operations
4031
+ *
4032
+ * @example
4033
+ * ```ts
4034
+ * // Write data to a CSV file
4035
+ * await table.writeData("./output.csv");
4036
+ * ```
4037
+ *
4038
+ * @example
4039
+ * ```ts
4040
+ * // Write data to a JSON file with GZIP compression.
4041
+ * // The output file will be named output.json.gz.
4042
+ * await table.writeData("./output.json", { compression: true });
4043
+ * ```
4044
+ *
4045
+ * @example
4046
+ * ```ts
4047
+ * // Write data to a Parquet file
4048
+ * await table.writeData("./output.parquet");
4049
+ * ```
4050
+ *
4051
+ * @example
4052
+ * ```ts
4053
+ * // Write data to a DuckDB database file
4054
+ * await table.writeData("./my_database.db");
4055
+ * ```
4056
+ *
4057
+ * @example
4058
+ * ```ts
4059
+ * // Write data to a SQLite database file
4060
+ * await table.writeData("./my_database.sqlite");
4061
+ * ```
4062
+ *
4063
+ * @example
4064
+ * ```ts
4065
+ * // Write JSON data with dates formatted as ISO strings
4066
+ * await table.writeData("./output_dates.json", { formatDates: true });
4067
+ * ```
4068
+ */
4069
+ writeData(file: string, options?: {
4070
+ compression?: boolean;
4071
+ dataAsArrays?: boolean;
4072
+ formatDates?: boolean;
4073
+ }): Promise<void>;
4074
+ /**
4075
+ * Writes the table's geospatial data to a file in GeoJSON or GeoParquet format.
4076
+ * If the specified path does not exist, it will be created.
4077
+ *
4078
+ * For GeoJSON files (`.geojson` or `.json`), if the projection is WGS84 or EPSG:4326 (`[latitude, longitude]` axis order), the coordinates will be flipped to follow the RFC7946 standard (`[longitude, latitude]` axis order) in the output.
4079
+ *
4080
+ * @param file - The absolute path to the output file (e.g., `"./output.geojson"`, `"./output.geoparquet"`).
4081
+ * @param options - An optional object with configuration options:
4082
+ * @param options.precision - For GeoJSON, the maximum number of figures after the decimal separator to write in coordinates. Defaults to `undefined` (full precision).
4083
+ * @param options.compression - For GeoParquet, if `true`, the output will be ZSTD compressed. Defaults to `false`.
4084
+ * @param options.rewind - For GeoJSON, if `true`, rewinds the coordinates of polygons to follow the right-hand rule (RFC 7946). Defaults to `false`.
4085
+ * @param options.metadata - For GeoJSON, an object to be added as top-level metadata to the GeoJSON output.
4086
+ * @param options.formatDates - For GeoJSON, if `true`, formats date and timestamp columns to ISO 8601 strings. Defaults to `false`.
4087
+ * @returns A promise that resolves when the geospatial data has been written to the file.
4088
+ * @category File Operations
4089
+ *
4090
+ * @example
4091
+ * ```ts
4092
+ * // Write geospatial data to a GeoJSON file
4093
+ * await table.writeGeoData("./output.geojson");
4094
+ * ```
4095
+ *
4096
+ * @example
4097
+ * ```ts
4098
+ * // Write geospatial data to a compressed GeoParquet file
4099
+ * await table.writeGeoData("./output.geoparquet", { compression: true });
4100
+ * ```
4101
+ *
4102
+ * @example
4103
+ * ```ts
4104
+ * // Write GeoJSON with specific precision and metadata
4105
+ * await table.writeGeoData("./output_high_precision.geojson", {
4106
+ * precision: 6,
4107
+ * metadata: { source: "SimpleDataAnalysis" },
4108
+ * });
4109
+ * ```
4110
+ */
4111
+ writeGeoData(file: string, options?: {
4112
+ precision?: number;
4113
+ compression?: boolean;
4114
+ rewind?: boolean;
4115
+ metadata?: unknown;
4116
+ formatDates?: boolean;
4117
+ }): Promise<void>;
4118
+ /**
4119
+ * Caches the results of computations in `./.sda-cache`.
4120
+ * You should add `./.sda-cache` to your `.gitignore` file.
4121
+ *
4122
+ * @param run - A function wrapping the computations to be cached. This function will be executed on the first run or if the cached data is invalid/expired.
4123
+ * @param options - An optional object with configuration options:
4124
+ * @param options.ttl - Time to live (in seconds). If the data in the cache is older than this duration, the `run` function will be executed again to refresh the cache. By default, there is no TTL, meaning the cache is only invalidated if the `run` function's content changes.
4125
+ * @returns A promise that resolves when the computations are complete or the data is loaded from cache.
4126
+ * @category Caching
4127
+ *
4128
+ * @example
4129
+ * ```ts
4130
+ * // Basic usage: computations are cached and re-run only if the function content changes
4131
+ * const sdb = new SimpleDB();
4132
+ * const table = sdb.newTable();
4133
+ *
4134
+ * await table.cache(async () => {
4135
+ * await table.loadData("items.csv");
4136
+ * await table.summarize({
4137
+ * values: "price",
4138
+ * categories: "department",
4139
+ * summaries: ["min", "max", "mean"],
4140
+ * });
4141
+ * });
4142
+ *
4143
+ * // It's important to call done() on the SimpleDB instance to clean up the cache.
4144
+ * // This prevents the cache from growing indefinitely.
4145
+ * await sdb.done();
4146
+ * ```
4147
+ *
4148
+ * @example
4149
+ * ```ts
4150
+ * // Cache with a Time-To-Live (TTL) of 60 seconds
4151
+ * // The computations will be re-run if the cached data is older than 1 minute or if the function content changes.
4152
+ * const sdb = new SimpleDB();
4153
+ * const table = sdb.newTable();
4154
+ *
4155
+ * await table.cache(async () => {
4156
+ * await table.loadData("items.csv");
4157
+ * await table.summarize({
4158
+ * values: "price",
4159
+ * categories: "department",
4160
+ * summaries: ["min", "max", "mean"],
4161
+ * });
4162
+ * }, { ttl: 60 });
4163
+ *
4164
+ * await sdb.done();
4165
+ * ```
4166
+ *
4167
+ * @example
4168
+ * ```ts
4169
+ * // Enable verbose logging for cache operations via SimpleDB instance
4170
+ * const sdb = new SimpleDB({ cacheVerbose: true });
4171
+ * const table = sdb.newTable();
4172
+ *
4173
+ * await table.cache(async () => {
4174
+ * await table.loadData("items.csv");
4175
+ * await table.summarize({
4176
+ * values: "price",
4177
+ * categories: "department",
4178
+ * summaries: ["min", "max", "mean"],
4179
+ * });
4180
+ * });
4181
+ *
4182
+ * await sdb.done();
4183
+ * ```
4184
+ */
4185
+ cache(run: () => Promise<void>, options?: {
4186
+ ttl?: number;
4187
+ }): Promise<void>;
4188
+ /**
4189
+ * Logs a specified number of rows from the table to the console. By default, the first 10 rows are logged.
4190
+ * You can optionally log the column types and filter the data based on conditions.
4191
+ * You can also use JavaScript syntax for conditions (e.g., `&&`, `||`, `===`, `!==`).
4192
+ *
4193
+ * @param options - Either the number of rows to log (a specific number or `"all"`) or an object with configuration options:
4194
+ * @param options.nbRowsToLog - The number of rows to log. Defaults to 10 or the value set in the SimpleDB instance. Use `"all"` to log all rows.
4195
+ * @param options.types - If `true`, logs the column types along with the data. Defaults to `false`.
4196
+ * @param options.conditions - A SQL `WHERE` clause condition to filter the data before logging. Defaults to no condition.
4197
+ * @returns A promise that resolves when the table data has been logged.
4198
+ * @category Logging
4199
+ *
4200
+ * @example
4201
+ * ```ts
4202
+ * // Log the first 10 rows (default behavior)
4203
+ * await table.logTable();
4204
+ * ```
4205
+ *
4206
+ * @example
4207
+ * ```ts
4208
+ * // Log the first 50 rows
4209
+ * await table.logTable(50);
4210
+ * ```
4211
+ *
4212
+ * @example
4213
+ * ```ts
4214
+ * // Log all rows
4215
+ * await table.logTable("all");
4216
+ * ```
4217
+ *
4218
+ * @example
4219
+ * ```ts
4220
+ * // Log the first 20 rows and include column types
4221
+ * await table.logTable({ nbRowsToLog: 20, types: true });
4222
+ * ```
4223
+ *
4224
+ * @example
4225
+ * ```ts
4226
+ * // Log rows where 'status' is 'active' (using JS syntax for conditions)
4227
+ * await table.logTable({ conditions: `status === 'active'` });
4228
+ * ```
4229
+ */
4230
+ logTable(options?: "all" | number | {
4231
+ nbRowsToLog?: number | "all";
4232
+ types?: boolean;
4233
+ conditions?: string;
4234
+ }): Promise<void>;
4235
+ /**
4236
+ * Generates and logs a histogram of a numeric column to the console.
4237
+ *
4238
+ * @param values - The name of the numeric column for which to generate the histogram.
4239
+ * @param options - An optional object with configuration options:
4240
+ * @param options.bins - The number of bins (intervals) to use for the histogram. Defaults to 10.
4241
+ * @param options.formatLabels - A function to format the labels for the histogram bins. It receives the lower and upper bounds of each bin as arguments.
4242
+ * @param options.compact - If `true`, the histogram will be displayed in a more compact format. Defaults to `false`.
4243
+ * @param options.width - The maximum width of the histogram bars in characters.
4244
+ * @returns A promise that resolves when the histogram has been logged to the console.
4245
+ * @category Dataviz
4246
+ *
4247
+ * @example
4248
+ * // Basic histogram of the 'temperature' column
4249
+ * ```typescript
4250
+ * await table.logHistogram("temperature")
4251
+ * ```
4252
+ *
4253
+ * @example
4254
+ * // Histogram with 20 bins and custom label formatting
4255
+ * ```typescript
4256
+ * await table.logHistogram("age", {
4257
+ * bins: 20,
4258
+ * formatLabels: (min, max) => `${min}-${max} years`,
4259
+ * });
4260
+ * ```
4261
+ */
4262
+ /**
4263
+ * Logs descriptive information about the columns in the table to the console. This includes details such as data types, number of null values, and number of distinct values for each column.
4264
+ * It internally calls the `getDescription` method to retrieve the descriptive statistics.
4265
+ *
4266
+ * @returns A promise that resolves when the column description has been logged to the console.
4267
+ * @category Logging
4268
+ *
4269
+ * @example
4270
+ * ```ts
4271
+ * // Log descriptive information for all columns in the table
4272
+ * await table.logDescription();
4273
+ * ```
4274
+ */
4275
+ logDescription(): Promise<void>;
4276
+ /**
4277
+ * Logs the projections of the geospatial data (if any) to the console.
4278
+ *
4279
+ * @returns A promise that resolves to the SimpleTable instance after logging the projections.
4280
+ * @category Logging
4281
+ *
4282
+ * @example
4283
+ * ```ts
4284
+ * // Log the geospatial projections of the table
4285
+ * await table.logProjections();
4286
+ * ```
4287
+ */
4288
+ logProjections(): Promise<this>;
4289
+ /**
4290
+ * Logs the types of all columns in the table to the console.
4291
+ *
4292
+ * @returns A promise that resolves to the SimpleTable instance after logging the column types.
4293
+ * @category Logging
4294
+ *
4295
+ * @example
4296
+ * ```ts
4297
+ * // Log the data types of all columns in the table
4298
+ * await table.logTypes();
4299
+ * ```
4300
+ */
4301
+ logTypes(): Promise<this>;
4302
+ /**
4303
+ * Logs unique values for a specified column to the console. By default, a maximum of 100 values are logged (depending on your runtime).
4304
+ * You can optionally stringify the values to see them all.
4305
+ *
4306
+ * @param column - The name of the column from which to retrieve and log unique values.
4307
+ * @param options - An optional object with configuration options:
4308
+ * @param options.stringify - If `true`, converts the unique values to a JSON string before logging. Defaults to `false`.
4309
+ * @returns A promise that resolves to the SimpleTable instance after logging the unique values.
4310
+ * @category Logging
4311
+ *
4312
+ * @example
4313
+ * ```ts
4314
+ * // Logs unique values for the column "name"
4315
+ * await table.logUniques("name");
4316
+ * ```
4317
+ *
4318
+ * @example
4319
+ * ```ts
4320
+ * // Logs unique values for the column "name" and stringifies them
4321
+ * await table.logUniques("name", { stringify: true });
4322
+ * ```
4323
+ */
4324
+ logUniques(column: string, options?: {
4325
+ stringify?: boolean;
4326
+ }): Promise<this>;
4327
+ /**
4328
+ * Logs the columns in the table to the console. You can optionally include their data types.
4329
+ *
4330
+ * @param options - An optional object with configuration options:
4331
+ * @param options.types - If `true`, logs the column names along with their data types. Defaults to `false`.
4332
+ * @returns A promise that resolves to the SimpleTable instance after logging the columns.
4333
+ * @category Logging
4334
+ *
4335
+ * @example
4336
+ * ```ts
4337
+ * // Log only the column names
4338
+ * await table.logColumns();
4339
+ * ```
4340
+ *
4341
+ * @example
4342
+ * ```ts
4343
+ * // Log column names along with their types
4344
+ * await table.logColumns({ types: true });
4345
+ * ```
4346
+ */
4347
+ logColumns(options?: {
4348
+ types?: boolean;
4349
+ }): Promise<this>;
4350
+ /**
4351
+ * Logs the total number of rows in the table to the console.
4352
+ *
4353
+ * @returns A promise that resolves to the SimpleTable instance after logging the row count.
4354
+ * @category Logging
4355
+ *
4356
+ * @example
4357
+ * ```ts
4358
+ * // Log the total number of rows in the table
4359
+ * await table.logNbRows();
4360
+ * ```
4361
+ */
4362
+ logNbRows(): Promise<this>;
4363
+ /**
4364
+ * 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.
4365
+ *
4366
+ * @param count - The number of rows to log from the bottom of the table. Defaults to the table's `nbRowsToLog` option if not specified.
4367
+ * @param options - An optional object with logging preferences.
4368
+ * @param options.originalOrder - If true, the rows are displayed in their original order (top to bottom). Defaults to false.
4369
+ * @returns A promise that resolves when the rows have been logged to the console.
4370
+ * @category Logging
4371
+ *
4372
+ * @example
4373
+ * ```ts
4374
+ * // Log bottom rows with default count (uses table's nbRowsToLog option)
4375
+ * await table.logBottom();
4376
+ * ```
4377
+ *
4378
+ * @example
4379
+ * ```ts
4380
+ * // Log the last 10 rows (displayed with last row first)
4381
+ * await table.logBottom(10);
4382
+ * ```
4383
+ *
4384
+ * @example
4385
+ * ```ts
4386
+ * // Log the last 5 rows in original order (top to bottom)
4387
+ * await table.logBottom(5, { originalOrder: true });
4388
+ * ```
4389
+ */
4390
+ logBottom(count?: number, options?: {
4391
+ originalOrder?: boolean;
4392
+ }): Promise<void>;
4393
+ /**
4394
+ * Logs the extent (minimum and maximum values) of a numeric column to the console.
4395
+ *
4396
+ * @param column - The name of the numeric column for which to log the extent.
4397
+ * @returns A promise that resolves when the column extent has been logged to the console.
4398
+ * @category Logging
4399
+ *
4400
+ * @example
4401
+ * ```ts
4402
+ * // Log the extent of the 'price' column
4403
+ * await table.logExtent("price");
4404
+ * ```
4405
+ */
4406
+ logExtent(column: string): Promise<void>;
4407
+ }
4408
+ //# sourceMappingURL=SimpleTable.d.ts.map