@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.
- package/LICENSE +20 -0
- package/README.md +43 -0
- package/esm/class/Simple.d.ts +66 -0
- package/esm/class/Simple.d.ts.map +1 -0
- package/esm/class/Simple.js +94 -0
- package/esm/class/SimpleDB.d.ts +487 -0
- package/esm/class/SimpleDB.d.ts.map +1 -0
- package/esm/class/SimpleDB.js +807 -0
- package/esm/class/SimpleTable.d.ts +4408 -0
- package/esm/class/SimpleTable.d.ts.map +1 -0
- package/esm/class/SimpleTable.js +5401 -0
- package/esm/helpers/accumulateQuery.d.ts +4 -0
- package/esm/helpers/accumulateQuery.d.ts.map +1 -0
- package/esm/helpers/accumulateQuery.js +15 -0
- package/esm/helpers/camelCase.d.ts +30 -0
- package/esm/helpers/camelCase.d.ts.map +1 -0
- package/esm/helpers/camelCase.js +45 -0
- package/esm/helpers/capitalize.d.ts +28 -0
- package/esm/helpers/capitalize.d.ts.map +1 -0
- package/esm/helpers/capitalize.js +33 -0
- package/esm/helpers/checkVssIndexes.d.ts +2 -0
- package/esm/helpers/checkVssIndexes.d.ts.map +1 -0
- package/esm/helpers/checkVssIndexes.js +16 -0
- package/esm/helpers/cleanCache.d.ts +3 -0
- package/esm/helpers/cleanCache.d.ts.map +1 -0
- package/esm/helpers/cleanCache.js +17 -0
- package/esm/helpers/cleanPath.d.ts +2 -0
- package/esm/helpers/cleanPath.d.ts.map +1 -0
- package/esm/helpers/cleanPath.js +3 -0
- package/esm/helpers/cleanSQL.d.ts +2 -0
- package/esm/helpers/cleanSQL.d.ts.map +1 -0
- package/esm/helpers/cleanSQL.js +24 -0
- package/esm/helpers/concatenateRowQuery.d.ts +2 -0
- package/esm/helpers/concatenateRowQuery.d.ts.map +1 -0
- package/esm/helpers/concatenateRowQuery.js +9 -0
- package/esm/helpers/convertForJS.d.ts +6 -0
- package/esm/helpers/convertForJS.d.ts.map +1 -0
- package/esm/helpers/convertForJS.js +39 -0
- package/esm/helpers/createDirectory.d.ts +2 -0
- package/esm/helpers/createDirectory.d.ts.map +1 -0
- package/esm/helpers/createDirectory.js +10 -0
- package/esm/helpers/csvFormat.d.ts +3 -0
- package/esm/helpers/csvFormat.d.ts.map +1 -0
- package/esm/helpers/csvFormat.js +165 -0
- package/esm/helpers/dataToArrays.d.ts +51 -0
- package/esm/helpers/dataToArrays.d.ts.map +1 -0
- package/esm/helpers/dataToArrays.js +55 -0
- package/esm/helpers/extractTypes.d.ts +6 -0
- package/esm/helpers/extractTypes.d.ts.map +1 -0
- package/esm/helpers/extractTypes.js +11 -0
- package/esm/helpers/findGeoColumn.d.ts +3 -0
- package/esm/helpers/findGeoColumn.d.ts.map +1 -0
- package/esm/helpers/findGeoColumn.js +18 -0
- package/esm/helpers/formatDate.d.ts +34 -0
- package/esm/helpers/formatDate.d.ts.map +1 -0
- package/esm/helpers/formatDate.js +69 -0
- package/esm/helpers/formatNumber.d.ts +46 -0
- package/esm/helpers/formatNumber.d.ts.map +1 -0
- package/esm/helpers/formatNumber.js +122 -0
- package/esm/helpers/getCombinations.d.ts +3 -0
- package/esm/helpers/getCombinations.d.ts.map +1 -0
- package/esm/helpers/getCombinations.js +24 -0
- package/esm/helpers/getExtension.d.ts +2 -0
- package/esm/helpers/getExtension.d.ts.map +1 -0
- package/esm/helpers/getExtension.js +9 -0
- package/esm/helpers/getIdenticalColumns.d.ts +2 -0
- package/esm/helpers/getIdenticalColumns.d.ts.map +1 -0
- package/esm/helpers/getIdenticalColumns.js +3 -0
- package/esm/helpers/getName.d.ts +2 -0
- package/esm/helpers/getName.d.ts.map +1 -0
- package/esm/helpers/getName.js +14 -0
- package/esm/helpers/getProjection.d.ts +3 -0
- package/esm/helpers/getProjection.d.ts.map +1 -0
- package/esm/helpers/getProjection.js +22 -0
- package/esm/helpers/getProjectionParquet.d.ts +3 -0
- package/esm/helpers/getProjectionParquet.d.ts.map +1 -0
- package/esm/helpers/getProjectionParquet.js +24 -0
- package/esm/helpers/index.d.ts +20 -0
- package/esm/helpers/index.d.ts.map +1 -0
- package/esm/helpers/index.js +19 -0
- package/esm/helpers/keepNumericalColumns.d.ts +4 -0
- package/esm/helpers/keepNumericalColumns.d.ts.map +1 -0
- package/esm/helpers/keepNumericalColumns.js +13 -0
- package/esm/helpers/logData.d.ts +6 -0
- package/esm/helpers/logData.d.ts.map +1 -0
- package/esm/helpers/logData.js +48 -0
- package/esm/helpers/mergeOptions.d.ts +28 -0
- package/esm/helpers/mergeOptions.d.ts.map +1 -0
- package/esm/helpers/mergeOptions.js +12 -0
- package/esm/helpers/nestQuery.d.ts +2 -0
- package/esm/helpers/nestQuery.d.ts.map +1 -0
- package/esm/helpers/nestQuery.js +13 -0
- package/esm/helpers/parseDuckDBType.d.ts +2 -0
- package/esm/helpers/parseDuckDBType.d.ts.map +1 -0
- package/esm/helpers/parseDuckDBType.js +38 -0
- package/esm/helpers/parseTypes.d.ts +2 -0
- package/esm/helpers/parseTypes.d.ts.map +1 -0
- package/esm/helpers/parseTypes.js +35 -0
- package/esm/helpers/parseValue.d.ts +2 -0
- package/esm/helpers/parseValue.d.ts.map +1 -0
- package/esm/helpers/parseValue.js +20 -0
- package/esm/helpers/prettyDuration.d.ts +55 -0
- package/esm/helpers/prettyDuration.d.ts.map +1 -0
- package/esm/helpers/prettyDuration.js +145 -0
- package/esm/helpers/printTable.d.ts +47 -0
- package/esm/helpers/printTable.d.ts.map +1 -0
- package/esm/helpers/printTable.js +217 -0
- package/esm/helpers/queryDB.d.ts +19 -0
- package/esm/helpers/queryDB.d.ts.map +1 -0
- package/esm/helpers/queryDB.js +62 -0
- package/esm/helpers/rewind.d.ts +3 -0
- package/esm/helpers/rewind.d.ts.map +1 -0
- package/esm/helpers/rewind.js +1293 -0
- package/esm/helpers/runQuery.d.ts +14 -0
- package/esm/helpers/runQuery.d.ts.map +1 -0
- package/esm/helpers/runQuery.js +26 -0
- package/esm/helpers/setDbProps.d.ts +3 -0
- package/esm/helpers/setDbProps.d.ts.map +1 -0
- package/esm/helpers/setDbProps.js +25 -0
- package/esm/helpers/shouldFlipBeforeExport.d.ts +2 -0
- package/esm/helpers/shouldFlipBeforeExport.d.ts.map +1 -0
- package/esm/helpers/shouldFlipBeforeExport.js +3 -0
- package/esm/helpers/stringToArray.d.ts +2 -0
- package/esm/helpers/stringToArray.d.ts.map +1 -0
- package/esm/helpers/stringToArray.js +11 -0
- package/esm/helpers/stringifyDates.d.ts +5 -0
- package/esm/helpers/stringifyDates.d.ts.map +1 -0
- package/esm/helpers/stringifyDates.js +14 -0
- package/esm/helpers/stringifyDatesInvert.d.ts +5 -0
- package/esm/helpers/stringifyDatesInvert.d.ts.map +1 -0
- package/esm/helpers/stringifyDatesInvert.js +14 -0
- package/esm/helpers/unifyColumns.d.ts +9 -0
- package/esm/helpers/unifyColumns.d.ts.map +1 -0
- package/esm/helpers/unifyColumns.js +21 -0
- package/esm/helpers/unnestQuery.d.ts +2 -0
- package/esm/helpers/unnestQuery.d.ts.map +1 -0
- package/esm/helpers/unnestQuery.js +8 -0
- package/esm/helpers/wrapString.d.ts +35 -0
- package/esm/helpers/wrapString.d.ts.map +1 -0
- package/esm/helpers/wrapString.js +83 -0
- package/esm/helpers/writeDataAsArrays.d.ts +3 -0
- package/esm/helpers/writeDataAsArrays.d.ts.map +1 -0
- package/esm/helpers/writeDataAsArrays.js +13 -0
- package/esm/helpers/writeProjectionsAndIndexes.d.ts +3 -0
- package/esm/helpers/writeProjectionsAndIndexes.d.ts.map +1 -0
- package/esm/helpers/writeProjectionsAndIndexes.js +29 -0
- package/esm/index.d.ts +31 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +30 -0
- package/esm/methods/aggregateGeoQuery.d.ts +5 -0
- package/esm/methods/aggregateGeoQuery.d.ts.map +1 -0
- package/esm/methods/aggregateGeoQuery.js +24 -0
- package/esm/methods/binsQuery.d.ts +5 -0
- package/esm/methods/binsQuery.d.ts.map +1 -0
- package/esm/methods/binsQuery.js +40 -0
- package/esm/methods/bm25.d.ts +17 -0
- package/esm/methods/bm25.d.ts.map +1 -0
- package/esm/methods/bm25.js +48 -0
- package/esm/methods/cache.d.ts +6 -0
- package/esm/methods/cache.d.ts.map +1 -0
- package/esm/methods/cache.js +133 -0
- package/esm/methods/capitalizeQuery.d.ts +2 -0
- package/esm/methods/capitalizeQuery.d.ts.map +1 -0
- package/esm/methods/capitalizeQuery.js +8 -0
- package/esm/methods/cloneColumn.d.ts +4 -0
- package/esm/methods/cloneColumn.d.ts.map +1 -0
- package/esm/methods/cloneColumn.js +13 -0
- package/esm/methods/cloneQuery.d.ts +4 -0
- package/esm/methods/cloneQuery.d.ts.map +1 -0
- package/esm/methods/cloneQuery.js +6 -0
- package/esm/methods/concatenateQuery.d.ts +4 -0
- package/esm/methods/concatenateQuery.d.ts.map +1 -0
- package/esm/methods/concatenateQuery.js +13 -0
- package/esm/methods/convertQuery.d.ts +7 -0
- package/esm/methods/convertQuery.d.ts.map +1 -0
- package/esm/methods/convertQuery.js +78 -0
- package/esm/methods/correlations.d.ts +9 -0
- package/esm/methods/correlations.d.ts.map +1 -0
- package/esm/methods/correlations.js +40 -0
- package/esm/methods/correlationsQuery.d.ts +5 -0
- package/esm/methods/correlationsQuery.d.ts.map +1 -0
- package/esm/methods/correlationsQuery.js +26 -0
- package/esm/methods/createFtsIndex.d.ts +11 -0
- package/esm/methods/createFtsIndex.d.ts.map +1 -0
- package/esm/methods/createFtsIndex.js +28 -0
- package/esm/methods/createVssIndex.d.ts +9 -0
- package/esm/methods/createVssIndex.d.ts.map +1 -0
- package/esm/methods/createVssIndex.js +38 -0
- package/esm/methods/crossJoinQuery.d.ts +4 -0
- package/esm/methods/crossJoinQuery.d.ts.map +1 -0
- package/esm/methods/crossJoinQuery.js +3 -0
- package/esm/methods/distanceQuery.d.ts +6 -0
- package/esm/methods/distanceQuery.d.ts.map +1 -0
- package/esm/methods/distanceQuery.js +42 -0
- package/esm/methods/fill.d.ts +7 -0
- package/esm/methods/fill.d.ts.map +1 -0
- package/esm/methods/fill.js +60 -0
- package/esm/methods/fuzzyClean.d.ts +7 -0
- package/esm/methods/fuzzyClean.d.ts.map +1 -0
- package/esm/methods/fuzzyClean.js +194 -0
- package/esm/methods/fuzzyJoin.d.ts +8 -0
- package/esm/methods/fuzzyJoin.d.ts.map +1 -0
- package/esm/methods/fuzzyJoin.js +57 -0
- package/esm/methods/fuzzyJoinQuery.d.ts +2 -0
- package/esm/methods/fuzzyJoinQuery.d.ts.map +1 -0
- package/esm/methods/fuzzyJoinQuery.js +19 -0
- package/esm/methods/getBottom.d.ts +8 -0
- package/esm/methods/getBottom.d.ts.map +1 -0
- package/esm/methods/getBottom.js +22 -0
- package/esm/methods/getColumns.d.ts +3 -0
- package/esm/methods/getColumns.d.ts.map +1 -0
- package/esm/methods/getColumns.js +15 -0
- package/esm/methods/getDescription.d.ts +9 -0
- package/esm/methods/getDescription.d.ts.map +1 -0
- package/esm/methods/getDescription.js +20 -0
- package/esm/methods/getFirstRow.d.ts +7 -0
- package/esm/methods/getFirstRow.d.ts.map +1 -0
- package/esm/methods/getFirstRow.js +15 -0
- package/esm/methods/getGeoData.d.ts +17 -0
- package/esm/methods/getGeoData.d.ts.map +1 -0
- package/esm/methods/getGeoData.js +41 -0
- package/esm/methods/getLastRow.d.ts +7 -0
- package/esm/methods/getLastRow.d.ts.map +1 -0
- package/esm/methods/getLastRow.js +19 -0
- package/esm/methods/getMax.d.ts +3 -0
- package/esm/methods/getMax.d.ts.map +1 -0
- package/esm/methods/getMax.js +18 -0
- package/esm/methods/getMean.d.ts +5 -0
- package/esm/methods/getMean.d.ts.map +1 -0
- package/esm/methods/getMean.js +17 -0
- package/esm/methods/getMedian.d.ts +5 -0
- package/esm/methods/getMedian.d.ts.map +1 -0
- package/esm/methods/getMedian.js +17 -0
- package/esm/methods/getMin.d.ts +3 -0
- package/esm/methods/getMin.d.ts.map +1 -0
- package/esm/methods/getMin.js +18 -0
- package/esm/methods/getNbCharacters.d.ts +3 -0
- package/esm/methods/getNbCharacters.d.ts.map +1 -0
- package/esm/methods/getNbCharacters.js +15 -0
- package/esm/methods/getNbRows.d.ts +3 -0
- package/esm/methods/getNbRows.d.ts.map +1 -0
- package/esm/methods/getNbRows.js +15 -0
- package/esm/methods/getQuantile.d.ts +5 -0
- package/esm/methods/getQuantile.d.ts.map +1 -0
- package/esm/methods/getQuantile.js +17 -0
- package/esm/methods/getSkew.d.ts +5 -0
- package/esm/methods/getSkew.d.ts.map +1 -0
- package/esm/methods/getSkew.js +17 -0
- package/esm/methods/getStdDev.d.ts +5 -0
- package/esm/methods/getStdDev.d.ts.map +1 -0
- package/esm/methods/getStdDev.js +17 -0
- package/esm/methods/getSum.d.ts +3 -0
- package/esm/methods/getSum.d.ts.map +1 -0
- package/esm/methods/getSum.js +15 -0
- package/esm/methods/getTableNames.d.ts +3 -0
- package/esm/methods/getTableNames.d.ts.map +1 -0
- package/esm/methods/getTableNames.js +15 -0
- package/esm/methods/getTop.d.ts +7 -0
- package/esm/methods/getTop.d.ts.map +1 -0
- package/esm/methods/getTop.js +14 -0
- package/esm/methods/getTypes.d.ts +5 -0
- package/esm/methods/getTypes.d.ts.map +1 -0
- package/esm/methods/getTypes.js +13 -0
- package/esm/methods/getUniques.d.ts +3 -0
- package/esm/methods/getUniques.d.ts.map +1 -0
- package/esm/methods/getUniques.js +15 -0
- package/esm/methods/getValues.d.ts +3 -0
- package/esm/methods/getValues.d.ts.map +1 -0
- package/esm/methods/getValues.js +15 -0
- package/esm/methods/getVar.d.ts +5 -0
- package/esm/methods/getVar.d.ts.map +1 -0
- package/esm/methods/getVar.js +17 -0
- package/esm/methods/insertRowsQuery.d.ts +4 -0
- package/esm/methods/insertRowsQuery.d.ts.map +1 -0
- package/esm/methods/insertRowsQuery.js +11 -0
- package/esm/methods/join.d.ts +7 -0
- package/esm/methods/join.d.ts.map +1 -0
- package/esm/methods/join.js +63 -0
- package/esm/methods/joinGeo.d.ts +10 -0
- package/esm/methods/joinGeo.d.ts.map +1 -0
- package/esm/methods/joinGeo.js +76 -0
- package/esm/methods/joinGeoQuery.d.ts +2 -0
- package/esm/methods/joinGeoQuery.d.ts.map +1 -0
- package/esm/methods/joinGeoQuery.js +55 -0
- package/esm/methods/joinQuery.d.ts +2 -0
- package/esm/methods/joinQuery.d.ts.map +1 -0
- package/esm/methods/joinQuery.js +21 -0
- package/esm/methods/keepQuery.d.ts +4 -0
- package/esm/methods/keepQuery.d.ts.map +1 -0
- package/esm/methods/keepQuery.js +15 -0
- package/esm/methods/linearRegressionQuery.d.ts +5 -0
- package/esm/methods/linearRegressionQuery.d.ts.map +1 -0
- package/esm/methods/linearRegressionQuery.js +37 -0
- package/esm/methods/linearRegressions.d.ts +9 -0
- package/esm/methods/linearRegressions.d.ts.map +1 -0
- package/esm/methods/linearRegressions.js +43 -0
- package/esm/methods/loadArray.d.ts +5 -0
- package/esm/methods/loadArray.d.ts.map +1 -0
- package/esm/methods/loadArray.js +78 -0
- package/esm/methods/loadDataQuery.d.ts +23 -0
- package/esm/methods/loadDataQuery.d.ts.map +1 -0
- package/esm/methods/loadDataQuery.js +77 -0
- package/esm/methods/lowerQuery.d.ts +2 -0
- package/esm/methods/lowerQuery.d.ts.map +1 -0
- package/esm/methods/lowerQuery.js +7 -0
- package/esm/methods/normalizeQuery.d.ts +5 -0
- package/esm/methods/normalizeQuery.d.ts.map +1 -0
- package/esm/methods/normalizeQuery.js +22 -0
- package/esm/methods/normalizeString.d.ts +5 -0
- package/esm/methods/normalizeString.d.ts.map +1 -0
- package/esm/methods/normalizeString.js +26 -0
- package/esm/methods/outliersIQRQuery.d.ts +4 -0
- package/esm/methods/outliersIQRQuery.d.ts.map +1 -0
- package/esm/methods/outliersIQRQuery.js +31 -0
- package/esm/methods/proportionsHorizontalQuery.d.ts +5 -0
- package/esm/methods/proportionsHorizontalQuery.d.ts.map +1 -0
- package/esm/methods/proportionsHorizontalQuery.js +15 -0
- package/esm/methods/proportionsVerticalQuery.d.ts +5 -0
- package/esm/methods/proportionsVerticalQuery.d.ts.map +1 -0
- package/esm/methods/proportionsVerticalQuery.js +19 -0
- package/esm/methods/quantilesQuery.d.ts +4 -0
- package/esm/methods/quantilesQuery.d.ts.map +1 -0
- package/esm/methods/quantilesQuery.js +12 -0
- package/esm/methods/ranksQuery.d.ts +6 -0
- package/esm/methods/ranksQuery.d.ts.map +1 -0
- package/esm/methods/ranksQuery.js +12 -0
- package/esm/methods/removeDuplicatesQuery.d.ts +4 -0
- package/esm/methods/removeDuplicatesQuery.d.ts.map +1 -0
- package/esm/methods/removeDuplicatesQuery.js +12 -0
- package/esm/methods/removeMissing.d.ts +7 -0
- package/esm/methods/removeMissing.d.ts.map +1 -0
- package/esm/methods/removeMissing.js +21 -0
- package/esm/methods/removeMissingQuery.d.ts +7 -0
- package/esm/methods/removeMissingQuery.d.ts.map +1 -0
- package/esm/methods/removeMissingQuery.js +43 -0
- package/esm/methods/removeQuery.d.ts +4 -0
- package/esm/methods/removeQuery.d.ts.map +1 -0
- package/esm/methods/removeQuery.js +15 -0
- package/esm/methods/renameColumnQuery.d.ts +2 -0
- package/esm/methods/renameColumnQuery.d.ts.map +1 -0
- package/esm/methods/renameColumnQuery.js +7 -0
- package/esm/methods/replaceNullsQuery.d.ts +2 -0
- package/esm/methods/replaceNullsQuery.d.ts.map +1 -0
- package/esm/methods/replaceNullsQuery.js +10 -0
- package/esm/methods/replaceQuery.d.ts +5 -0
- package/esm/methods/replaceQuery.d.ts.map +1 -0
- package/esm/methods/replaceQuery.js +24 -0
- package/esm/methods/rollingQuery.d.ts +5 -0
- package/esm/methods/rollingQuery.d.ts.map +1 -0
- package/esm/methods/rollingQuery.js +33 -0
- package/esm/methods/roundQuery.d.ts +5 -0
- package/esm/methods/roundQuery.d.ts.map +1 -0
- package/esm/methods/roundQuery.js +16 -0
- package/esm/methods/selectRowsQuery.d.ts +5 -0
- package/esm/methods/selectRowsQuery.d.ts.map +1 -0
- package/esm/methods/selectRowsQuery.js +3 -0
- package/esm/methods/sortQuery.d.ts +8 -0
- package/esm/methods/sortQuery.d.ts.map +1 -0
- package/esm/methods/sortQuery.js +18 -0
- package/esm/methods/splitSpread.d.ts +5 -0
- package/esm/methods/splitSpread.d.ts.map +1 -0
- package/esm/methods/splitSpread.js +61 -0
- package/esm/methods/summarize.d.ts +13 -0
- package/esm/methods/summarize.d.ts.map +1 -0
- package/esm/methods/summarize.js +60 -0
- package/esm/methods/summarizeQuery.d.ts +7 -0
- package/esm/methods/summarizeQuery.d.ts.map +1 -0
- package/esm/methods/summarizeQuery.js +112 -0
- package/esm/methods/trimQuery.d.ts +5 -0
- package/esm/methods/trimQuery.d.ts.map +1 -0
- package/esm/methods/trimQuery.js +29 -0
- package/esm/methods/truncateQuery.d.ts +2 -0
- package/esm/methods/truncateQuery.d.ts.map +1 -0
- package/esm/methods/truncateQuery.js +3 -0
- package/esm/methods/upperQuery.d.ts +2 -0
- package/esm/methods/upperQuery.d.ts.map +1 -0
- package/esm/methods/upperQuery.js +7 -0
- package/esm/methods/writeDataQuery.d.ts +5 -0
- package/esm/methods/writeDataQuery.d.ts.map +1 -0
- package/esm/methods/writeDataQuery.js +44 -0
- package/esm/methods/writeGeoDataQuery.d.ts +4 -0
- package/esm/methods/writeGeoDataQuery.d.ts.map +1 -0
- package/esm/methods/writeGeoDataQuery.js +16 -0
- package/esm/methods/zScoreQuery.d.ts +5 -0
- package/esm/methods/zScoreQuery.d.ts.map +1 -0
- package/esm/methods/zScoreQuery.js +23 -0
- package/esm/package.json +3 -0
- package/package.json +27 -0
- package/script/class/Simple.d.ts +66 -0
- package/script/class/Simple.d.ts.map +1 -0
- package/script/class/Simple.js +97 -0
- package/script/class/SimpleDB.d.ts +487 -0
- package/script/class/SimpleDB.d.ts.map +1 -0
- package/script/class/SimpleDB.js +813 -0
- package/script/class/SimpleTable.d.ts +4408 -0
- package/script/class/SimpleTable.d.ts.map +1 -0
- package/script/class/SimpleTable.js +5407 -0
- package/script/helpers/accumulateQuery.d.ts +4 -0
- package/script/helpers/accumulateQuery.d.ts.map +1 -0
- package/script/helpers/accumulateQuery.js +21 -0
- package/script/helpers/camelCase.d.ts +30 -0
- package/script/helpers/camelCase.d.ts.map +1 -0
- package/script/helpers/camelCase.js +51 -0
- package/script/helpers/capitalize.d.ts +28 -0
- package/script/helpers/capitalize.d.ts.map +1 -0
- package/script/helpers/capitalize.js +36 -0
- package/script/helpers/checkVssIndexes.d.ts +2 -0
- package/script/helpers/checkVssIndexes.d.ts.map +1 -0
- package/script/helpers/checkVssIndexes.js +19 -0
- package/script/helpers/cleanCache.d.ts +3 -0
- package/script/helpers/cleanCache.d.ts.map +1 -0
- package/script/helpers/cleanCache.js +20 -0
- package/script/helpers/cleanPath.d.ts +2 -0
- package/script/helpers/cleanPath.d.ts.map +1 -0
- package/script/helpers/cleanPath.js +6 -0
- package/script/helpers/cleanSQL.d.ts +2 -0
- package/script/helpers/cleanSQL.d.ts.map +1 -0
- package/script/helpers/cleanSQL.js +27 -0
- package/script/helpers/concatenateRowQuery.d.ts +2 -0
- package/script/helpers/concatenateRowQuery.d.ts.map +1 -0
- package/script/helpers/concatenateRowQuery.js +12 -0
- package/script/helpers/convertForJS.d.ts +6 -0
- package/script/helpers/convertForJS.d.ts.map +1 -0
- package/script/helpers/convertForJS.js +42 -0
- package/script/helpers/createDirectory.d.ts +2 -0
- package/script/helpers/createDirectory.d.ts.map +1 -0
- package/script/helpers/createDirectory.js +13 -0
- package/script/helpers/csvFormat.d.ts +3 -0
- package/script/helpers/csvFormat.d.ts.map +1 -0
- package/script/helpers/csvFormat.js +168 -0
- package/script/helpers/dataToArrays.d.ts +51 -0
- package/script/helpers/dataToArrays.d.ts.map +1 -0
- package/script/helpers/dataToArrays.js +58 -0
- package/script/helpers/extractTypes.d.ts +6 -0
- package/script/helpers/extractTypes.d.ts.map +1 -0
- package/script/helpers/extractTypes.js +14 -0
- package/script/helpers/findGeoColumn.d.ts +3 -0
- package/script/helpers/findGeoColumn.d.ts.map +1 -0
- package/script/helpers/findGeoColumn.js +21 -0
- package/script/helpers/formatDate.d.ts +34 -0
- package/script/helpers/formatDate.d.ts.map +1 -0
- package/script/helpers/formatDate.js +72 -0
- package/script/helpers/formatNumber.d.ts +46 -0
- package/script/helpers/formatNumber.d.ts.map +1 -0
- package/script/helpers/formatNumber.js +125 -0
- package/script/helpers/getCombinations.d.ts +3 -0
- package/script/helpers/getCombinations.d.ts.map +1 -0
- package/script/helpers/getCombinations.js +26 -0
- package/script/helpers/getExtension.d.ts +2 -0
- package/script/helpers/getExtension.d.ts.map +1 -0
- package/script/helpers/getExtension.js +12 -0
- package/script/helpers/getIdenticalColumns.d.ts +2 -0
- package/script/helpers/getIdenticalColumns.d.ts.map +1 -0
- package/script/helpers/getIdenticalColumns.js +6 -0
- package/script/helpers/getName.d.ts +2 -0
- package/script/helpers/getName.d.ts.map +1 -0
- package/script/helpers/getName.js +17 -0
- package/script/helpers/getProjection.d.ts +3 -0
- package/script/helpers/getProjection.d.ts.map +1 -0
- package/script/helpers/getProjection.js +28 -0
- package/script/helpers/getProjectionParquet.d.ts +3 -0
- package/script/helpers/getProjectionParquet.d.ts.map +1 -0
- package/script/helpers/getProjectionParquet.js +30 -0
- package/script/helpers/index.d.ts +20 -0
- package/script/helpers/index.d.ts.map +1 -0
- package/script/helpers/index.js +30 -0
- package/script/helpers/keepNumericalColumns.d.ts +4 -0
- package/script/helpers/keepNumericalColumns.d.ts.map +1 -0
- package/script/helpers/keepNumericalColumns.js +16 -0
- package/script/helpers/logData.d.ts +6 -0
- package/script/helpers/logData.d.ts.map +1 -0
- package/script/helpers/logData.js +54 -0
- package/script/helpers/mergeOptions.d.ts +28 -0
- package/script/helpers/mergeOptions.d.ts.map +1 -0
- package/script/helpers/mergeOptions.js +15 -0
- package/script/helpers/nestQuery.d.ts +2 -0
- package/script/helpers/nestQuery.d.ts.map +1 -0
- package/script/helpers/nestQuery.js +19 -0
- package/script/helpers/parseDuckDBType.d.ts +2 -0
- package/script/helpers/parseDuckDBType.d.ts.map +1 -0
- package/script/helpers/parseDuckDBType.js +41 -0
- package/script/helpers/parseTypes.d.ts +2 -0
- package/script/helpers/parseTypes.d.ts.map +1 -0
- package/script/helpers/parseTypes.js +38 -0
- package/script/helpers/parseValue.d.ts +2 -0
- package/script/helpers/parseValue.d.ts.map +1 -0
- package/script/helpers/parseValue.js +23 -0
- package/script/helpers/prettyDuration.d.ts +55 -0
- package/script/helpers/prettyDuration.d.ts.map +1 -0
- package/script/helpers/prettyDuration.js +148 -0
- package/script/helpers/printTable.d.ts +47 -0
- package/script/helpers/printTable.d.ts.map +1 -0
- package/script/helpers/printTable.js +223 -0
- package/script/helpers/queryDB.d.ts +19 -0
- package/script/helpers/queryDB.d.ts.map +1 -0
- package/script/helpers/queryDB.js +68 -0
- package/script/helpers/rewind.d.ts +3 -0
- package/script/helpers/rewind.d.ts.map +1 -0
- package/script/helpers/rewind.js +1295 -0
- package/script/helpers/runQuery.d.ts +14 -0
- package/script/helpers/runQuery.d.ts.map +1 -0
- package/script/helpers/runQuery.js +32 -0
- package/script/helpers/setDbProps.d.ts +3 -0
- package/script/helpers/setDbProps.d.ts.map +1 -0
- package/script/helpers/setDbProps.js +28 -0
- package/script/helpers/shouldFlipBeforeExport.d.ts +2 -0
- package/script/helpers/shouldFlipBeforeExport.d.ts.map +1 -0
- package/script/helpers/shouldFlipBeforeExport.js +6 -0
- package/script/helpers/stringToArray.d.ts +2 -0
- package/script/helpers/stringToArray.d.ts.map +1 -0
- package/script/helpers/stringToArray.js +14 -0
- package/script/helpers/stringifyDates.d.ts +5 -0
- package/script/helpers/stringifyDates.d.ts.map +1 -0
- package/script/helpers/stringifyDates.js +17 -0
- package/script/helpers/stringifyDatesInvert.d.ts +5 -0
- package/script/helpers/stringifyDatesInvert.d.ts.map +1 -0
- package/script/helpers/stringifyDatesInvert.js +17 -0
- package/script/helpers/unifyColumns.d.ts +9 -0
- package/script/helpers/unifyColumns.d.ts.map +1 -0
- package/script/helpers/unifyColumns.js +24 -0
- package/script/helpers/unnestQuery.d.ts +2 -0
- package/script/helpers/unnestQuery.d.ts.map +1 -0
- package/script/helpers/unnestQuery.js +11 -0
- package/script/helpers/wrapString.d.ts +35 -0
- package/script/helpers/wrapString.d.ts.map +1 -0
- package/script/helpers/wrapString.js +86 -0
- package/script/helpers/writeDataAsArrays.d.ts +3 -0
- package/script/helpers/writeDataAsArrays.d.ts.map +1 -0
- package/script/helpers/writeDataAsArrays.js +19 -0
- package/script/helpers/writeProjectionsAndIndexes.d.ts +3 -0
- package/script/helpers/writeProjectionsAndIndexes.d.ts.map +1 -0
- package/script/helpers/writeProjectionsAndIndexes.js +32 -0
- package/script/index.d.ts +31 -0
- package/script/index.d.ts.map +1 -0
- package/script/index.js +38 -0
- package/script/methods/aggregateGeoQuery.d.ts +5 -0
- package/script/methods/aggregateGeoQuery.d.ts.map +1 -0
- package/script/methods/aggregateGeoQuery.js +30 -0
- package/script/methods/binsQuery.d.ts +5 -0
- package/script/methods/binsQuery.d.ts.map +1 -0
- package/script/methods/binsQuery.js +43 -0
- package/script/methods/bm25.d.ts +17 -0
- package/script/methods/bm25.d.ts.map +1 -0
- package/script/methods/bm25.js +54 -0
- package/script/methods/cache.d.ts +6 -0
- package/script/methods/cache.d.ts.map +1 -0
- package/script/methods/cache.js +139 -0
- package/script/methods/capitalizeQuery.d.ts +2 -0
- package/script/methods/capitalizeQuery.d.ts.map +1 -0
- package/script/methods/capitalizeQuery.js +11 -0
- package/script/methods/cloneColumn.d.ts +4 -0
- package/script/methods/cloneColumn.d.ts.map +1 -0
- package/script/methods/cloneColumn.js +16 -0
- package/script/methods/cloneQuery.d.ts +4 -0
- package/script/methods/cloneQuery.d.ts.map +1 -0
- package/script/methods/cloneQuery.js +9 -0
- package/script/methods/concatenateQuery.d.ts +4 -0
- package/script/methods/concatenateQuery.d.ts.map +1 -0
- package/script/methods/concatenateQuery.js +16 -0
- package/script/methods/convertQuery.d.ts +7 -0
- package/script/methods/convertQuery.d.ts.map +1 -0
- package/script/methods/convertQuery.js +84 -0
- package/script/methods/correlations.d.ts +9 -0
- package/script/methods/correlations.d.ts.map +1 -0
- package/script/methods/correlations.js +46 -0
- package/script/methods/correlationsQuery.d.ts +5 -0
- package/script/methods/correlationsQuery.d.ts.map +1 -0
- package/script/methods/correlationsQuery.js +32 -0
- package/script/methods/createFtsIndex.d.ts +11 -0
- package/script/methods/createFtsIndex.d.ts.map +1 -0
- package/script/methods/createFtsIndex.js +34 -0
- package/script/methods/createVssIndex.d.ts +9 -0
- package/script/methods/createVssIndex.d.ts.map +1 -0
- package/script/methods/createVssIndex.js +44 -0
- package/script/methods/crossJoinQuery.d.ts +4 -0
- package/script/methods/crossJoinQuery.d.ts.map +1 -0
- package/script/methods/crossJoinQuery.js +6 -0
- package/script/methods/distanceQuery.d.ts +6 -0
- package/script/methods/distanceQuery.d.ts.map +1 -0
- package/script/methods/distanceQuery.js +45 -0
- package/script/methods/fill.d.ts +7 -0
- package/script/methods/fill.d.ts.map +1 -0
- package/script/methods/fill.js +66 -0
- package/script/methods/fuzzyClean.d.ts +7 -0
- package/script/methods/fuzzyClean.d.ts.map +1 -0
- package/script/methods/fuzzyClean.js +200 -0
- package/script/methods/fuzzyJoin.d.ts +8 -0
- package/script/methods/fuzzyJoin.d.ts.map +1 -0
- package/script/methods/fuzzyJoin.js +63 -0
- package/script/methods/fuzzyJoinQuery.d.ts +2 -0
- package/script/methods/fuzzyJoinQuery.d.ts.map +1 -0
- package/script/methods/fuzzyJoinQuery.js +22 -0
- package/script/methods/getBottom.d.ts +8 -0
- package/script/methods/getBottom.d.ts.map +1 -0
- package/script/methods/getBottom.js +28 -0
- package/script/methods/getColumns.d.ts +3 -0
- package/script/methods/getColumns.d.ts.map +1 -0
- package/script/methods/getColumns.js +21 -0
- package/script/methods/getDescription.d.ts +9 -0
- package/script/methods/getDescription.d.ts.map +1 -0
- package/script/methods/getDescription.js +23 -0
- package/script/methods/getFirstRow.d.ts +7 -0
- package/script/methods/getFirstRow.d.ts.map +1 -0
- package/script/methods/getFirstRow.js +21 -0
- package/script/methods/getGeoData.d.ts +17 -0
- package/script/methods/getGeoData.d.ts.map +1 -0
- package/script/methods/getGeoData.js +47 -0
- package/script/methods/getLastRow.d.ts +7 -0
- package/script/methods/getLastRow.d.ts.map +1 -0
- package/script/methods/getLastRow.js +25 -0
- package/script/methods/getMax.d.ts +3 -0
- package/script/methods/getMax.d.ts.map +1 -0
- package/script/methods/getMax.js +24 -0
- package/script/methods/getMean.d.ts +5 -0
- package/script/methods/getMean.d.ts.map +1 -0
- package/script/methods/getMean.js +23 -0
- package/script/methods/getMedian.d.ts +5 -0
- package/script/methods/getMedian.d.ts.map +1 -0
- package/script/methods/getMedian.js +23 -0
- package/script/methods/getMin.d.ts +3 -0
- package/script/methods/getMin.d.ts.map +1 -0
- package/script/methods/getMin.js +24 -0
- package/script/methods/getNbCharacters.d.ts +3 -0
- package/script/methods/getNbCharacters.d.ts.map +1 -0
- package/script/methods/getNbCharacters.js +21 -0
- package/script/methods/getNbRows.d.ts +3 -0
- package/script/methods/getNbRows.d.ts.map +1 -0
- package/script/methods/getNbRows.js +21 -0
- package/script/methods/getQuantile.d.ts +5 -0
- package/script/methods/getQuantile.d.ts.map +1 -0
- package/script/methods/getQuantile.js +23 -0
- package/script/methods/getSkew.d.ts +5 -0
- package/script/methods/getSkew.d.ts.map +1 -0
- package/script/methods/getSkew.js +23 -0
- package/script/methods/getStdDev.d.ts +5 -0
- package/script/methods/getStdDev.d.ts.map +1 -0
- package/script/methods/getStdDev.js +23 -0
- package/script/methods/getSum.d.ts +3 -0
- package/script/methods/getSum.d.ts.map +1 -0
- package/script/methods/getSum.js +21 -0
- package/script/methods/getTableNames.d.ts +3 -0
- package/script/methods/getTableNames.d.ts.map +1 -0
- package/script/methods/getTableNames.js +21 -0
- package/script/methods/getTop.d.ts +7 -0
- package/script/methods/getTop.d.ts.map +1 -0
- package/script/methods/getTop.js +20 -0
- package/script/methods/getTypes.d.ts +5 -0
- package/script/methods/getTypes.d.ts.map +1 -0
- package/script/methods/getTypes.js +19 -0
- package/script/methods/getUniques.d.ts +3 -0
- package/script/methods/getUniques.d.ts.map +1 -0
- package/script/methods/getUniques.js +21 -0
- package/script/methods/getValues.d.ts +3 -0
- package/script/methods/getValues.d.ts.map +1 -0
- package/script/methods/getValues.js +21 -0
- package/script/methods/getVar.d.ts +5 -0
- package/script/methods/getVar.d.ts.map +1 -0
- package/script/methods/getVar.js +23 -0
- package/script/methods/insertRowsQuery.d.ts +4 -0
- package/script/methods/insertRowsQuery.d.ts.map +1 -0
- package/script/methods/insertRowsQuery.js +17 -0
- package/script/methods/join.d.ts +7 -0
- package/script/methods/join.d.ts.map +1 -0
- package/script/methods/join.js +69 -0
- package/script/methods/joinGeo.d.ts +10 -0
- package/script/methods/joinGeo.d.ts.map +1 -0
- package/script/methods/joinGeo.js +82 -0
- package/script/methods/joinGeoQuery.d.ts +2 -0
- package/script/methods/joinGeoQuery.d.ts.map +1 -0
- package/script/methods/joinGeoQuery.js +58 -0
- package/script/methods/joinQuery.d.ts +2 -0
- package/script/methods/joinQuery.d.ts.map +1 -0
- package/script/methods/joinQuery.js +24 -0
- package/script/methods/keepQuery.d.ts +4 -0
- package/script/methods/keepQuery.d.ts.map +1 -0
- package/script/methods/keepQuery.js +21 -0
- package/script/methods/linearRegressionQuery.d.ts +5 -0
- package/script/methods/linearRegressionQuery.d.ts.map +1 -0
- package/script/methods/linearRegressionQuery.js +43 -0
- package/script/methods/linearRegressions.d.ts +9 -0
- package/script/methods/linearRegressions.d.ts.map +1 -0
- package/script/methods/linearRegressions.js +49 -0
- package/script/methods/loadArray.d.ts +5 -0
- package/script/methods/loadArray.d.ts.map +1 -0
- package/script/methods/loadArray.js +84 -0
- package/script/methods/loadDataQuery.d.ts +23 -0
- package/script/methods/loadDataQuery.d.ts.map +1 -0
- package/script/methods/loadDataQuery.js +83 -0
- package/script/methods/lowerQuery.d.ts +2 -0
- package/script/methods/lowerQuery.d.ts.map +1 -0
- package/script/methods/lowerQuery.js +10 -0
- package/script/methods/normalizeQuery.d.ts +5 -0
- package/script/methods/normalizeQuery.d.ts.map +1 -0
- package/script/methods/normalizeQuery.js +28 -0
- package/script/methods/normalizeString.d.ts +5 -0
- package/script/methods/normalizeString.d.ts.map +1 -0
- package/script/methods/normalizeString.js +32 -0
- package/script/methods/outliersIQRQuery.d.ts +4 -0
- package/script/methods/outliersIQRQuery.d.ts.map +1 -0
- package/script/methods/outliersIQRQuery.js +37 -0
- package/script/methods/proportionsHorizontalQuery.d.ts +5 -0
- package/script/methods/proportionsHorizontalQuery.d.ts.map +1 -0
- package/script/methods/proportionsHorizontalQuery.js +18 -0
- package/script/methods/proportionsVerticalQuery.d.ts +5 -0
- package/script/methods/proportionsVerticalQuery.d.ts.map +1 -0
- package/script/methods/proportionsVerticalQuery.js +25 -0
- package/script/methods/quantilesQuery.d.ts +4 -0
- package/script/methods/quantilesQuery.d.ts.map +1 -0
- package/script/methods/quantilesQuery.js +18 -0
- package/script/methods/ranksQuery.d.ts +6 -0
- package/script/methods/ranksQuery.d.ts.map +1 -0
- package/script/methods/ranksQuery.js +18 -0
- package/script/methods/removeDuplicatesQuery.d.ts +4 -0
- package/script/methods/removeDuplicatesQuery.d.ts.map +1 -0
- package/script/methods/removeDuplicatesQuery.js +18 -0
- package/script/methods/removeMissing.d.ts +7 -0
- package/script/methods/removeMissing.d.ts.map +1 -0
- package/script/methods/removeMissing.js +27 -0
- package/script/methods/removeMissingQuery.d.ts +7 -0
- package/script/methods/removeMissingQuery.d.ts.map +1 -0
- package/script/methods/removeMissingQuery.js +46 -0
- package/script/methods/removeQuery.d.ts +4 -0
- package/script/methods/removeQuery.d.ts.map +1 -0
- package/script/methods/removeQuery.js +21 -0
- package/script/methods/renameColumnQuery.d.ts +2 -0
- package/script/methods/renameColumnQuery.d.ts.map +1 -0
- package/script/methods/renameColumnQuery.js +10 -0
- package/script/methods/replaceNullsQuery.d.ts +2 -0
- package/script/methods/replaceNullsQuery.d.ts.map +1 -0
- package/script/methods/replaceNullsQuery.js +16 -0
- package/script/methods/replaceQuery.d.ts +5 -0
- package/script/methods/replaceQuery.d.ts.map +1 -0
- package/script/methods/replaceQuery.js +27 -0
- package/script/methods/rollingQuery.d.ts +5 -0
- package/script/methods/rollingQuery.d.ts.map +1 -0
- package/script/methods/rollingQuery.js +39 -0
- package/script/methods/roundQuery.d.ts +5 -0
- package/script/methods/roundQuery.d.ts.map +1 -0
- package/script/methods/roundQuery.js +19 -0
- package/script/methods/selectRowsQuery.d.ts +5 -0
- package/script/methods/selectRowsQuery.d.ts.map +1 -0
- package/script/methods/selectRowsQuery.js +6 -0
- package/script/methods/sortQuery.d.ts +8 -0
- package/script/methods/sortQuery.d.ts.map +1 -0
- package/script/methods/sortQuery.js +21 -0
- package/script/methods/splitSpread.d.ts +5 -0
- package/script/methods/splitSpread.d.ts.map +1 -0
- package/script/methods/splitSpread.js +67 -0
- package/script/methods/summarize.d.ts +13 -0
- package/script/methods/summarize.d.ts.map +1 -0
- package/script/methods/summarize.js +66 -0
- package/script/methods/summarizeQuery.d.ts +7 -0
- package/script/methods/summarizeQuery.d.ts.map +1 -0
- package/script/methods/summarizeQuery.js +115 -0
- package/script/methods/trimQuery.d.ts +5 -0
- package/script/methods/trimQuery.d.ts.map +1 -0
- package/script/methods/trimQuery.js +32 -0
- package/script/methods/truncateQuery.d.ts +2 -0
- package/script/methods/truncateQuery.d.ts.map +1 -0
- package/script/methods/truncateQuery.js +6 -0
- package/script/methods/upperQuery.d.ts +2 -0
- package/script/methods/upperQuery.d.ts.map +1 -0
- package/script/methods/upperQuery.js +10 -0
- package/script/methods/writeDataQuery.d.ts +5 -0
- package/script/methods/writeDataQuery.d.ts.map +1 -0
- package/script/methods/writeDataQuery.js +50 -0
- package/script/methods/writeGeoDataQuery.d.ts +4 -0
- package/script/methods/writeGeoDataQuery.d.ts.map +1 -0
- package/script/methods/writeGeoDataQuery.js +22 -0
- package/script/methods/zScoreQuery.d.ts +5 -0
- package/script/methods/zScoreQuery.d.ts.map +1 -0
- package/script/methods/zScoreQuery.js +29 -0
- package/script/package.json +3 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = bm25;
|
|
7
|
+
const camelCase_js_1 = __importDefault(require("../helpers/camelCase.js"));
|
|
8
|
+
const queryDB_js_1 = __importDefault(require("../helpers/queryDB.js"));
|
|
9
|
+
const mergeOptions_js_1 = __importDefault(require("../helpers/mergeOptions.js"));
|
|
10
|
+
async function bm25(simpleTable, text, columnId, columnText, nbResults, options = {}) {
|
|
11
|
+
// This uses the fts extension
|
|
12
|
+
// https://duckdb.org/docs/stable/core_extensions/full_text_search
|
|
13
|
+
await simpleTable.createFtsIndex(columnId, columnText, {
|
|
14
|
+
stemmer: options.stemmer,
|
|
15
|
+
stopwords: options.stopwords,
|
|
16
|
+
ignore: options.ignore,
|
|
17
|
+
stripAccents: options.stripAccents,
|
|
18
|
+
lower: options.lower,
|
|
19
|
+
overwrite: options.overwriteIndex,
|
|
20
|
+
verbose: options.verbose,
|
|
21
|
+
});
|
|
22
|
+
const minScoreCondition = typeof options.minScore === "number"
|
|
23
|
+
? ` AND score >= ${options.minScore}`
|
|
24
|
+
: "";
|
|
25
|
+
const selectClause = typeof options.scoreColumn === "string"
|
|
26
|
+
? `* EXCLUDE(score), score AS "${options.scoreColumn}"`
|
|
27
|
+
: `* EXCLUDE(score)`;
|
|
28
|
+
await (0, queryDB_js_1.default)(simpleTable, `CREATE OR REPLACE TABLE "${options.outputTable ?? simpleTable.name}" AS SELECT ${selectClause} FROM (SELECT *, fts_main_${(0, camelCase_js_1.default)(simpleTable.name)}.match_bm25(${columnId}, '${text.replace(/'/g, "''")}'${typeof options.k === "number" ? `, k := ${options.k}` : ""}${typeof options.b === "number" ? `, b := ${options.b}` : ""}${options.conjunctive === true ? `, conjunctive := 1` : ""}) AS score FROM "${simpleTable.name}") sq WHERE score NOT NULL${minScoreCondition} ORDER BY score DESC LIMIT ${nbResults};`, (0, mergeOptions_js_1.default)(simpleTable, {
|
|
29
|
+
table: simpleTable.name,
|
|
30
|
+
method: "bm25",
|
|
31
|
+
parameters: {
|
|
32
|
+
text,
|
|
33
|
+
columnId,
|
|
34
|
+
columnText,
|
|
35
|
+
nbResults,
|
|
36
|
+
minScore: options.minScore,
|
|
37
|
+
scoreColumn: options.scoreColumn,
|
|
38
|
+
k: options.k,
|
|
39
|
+
b: options.b,
|
|
40
|
+
stemmer: options.stemmer,
|
|
41
|
+
stopwords: options.stopwords,
|
|
42
|
+
ignore: options.ignore,
|
|
43
|
+
stripAccents: options.stripAccents,
|
|
44
|
+
lower: options.lower,
|
|
45
|
+
table: options.outputTable ?? simpleTable.name,
|
|
46
|
+
},
|
|
47
|
+
}));
|
|
48
|
+
if (typeof options.outputTable === "string") {
|
|
49
|
+
return simpleTable.sdb.newTable(options.outputTable, structuredClone(simpleTable.projections));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return simpleTable;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/methods/cache.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAcvD,wBAA8B,KAAK,CACjC,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EACxB,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,iBA2HlD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = cache;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
9
|
+
const formatDate_js_1 = __importDefault(require("../helpers/formatDate.js"));
|
|
10
|
+
const prettyDuration_js_1 = __importDefault(require("../helpers/prettyDuration.js"));
|
|
11
|
+
async function cache(table, run, options = {}) {
|
|
12
|
+
options.verbose &&
|
|
13
|
+
console.log(`\ncache() for ${table.name}`);
|
|
14
|
+
const cachePath = "./.sda-cache";
|
|
15
|
+
if (!(0, node_fs_1.existsSync)(cachePath)) {
|
|
16
|
+
(0, node_fs_1.mkdirSync)(cachePath);
|
|
17
|
+
}
|
|
18
|
+
const cacheSourcesPath = `${cachePath}/sources.json`;
|
|
19
|
+
let cacheSources = {};
|
|
20
|
+
if ((0, node_fs_1.existsSync)(cacheSourcesPath)) {
|
|
21
|
+
cacheSources = JSON.parse((0, node_fs_1.readFileSync)(cacheSourcesPath, "utf-8"));
|
|
22
|
+
}
|
|
23
|
+
const functionBody = run.toString();
|
|
24
|
+
const hash = node_crypto_1.default
|
|
25
|
+
.createHash("sha256")
|
|
26
|
+
.update(table.name + options.toString() + functionBody)
|
|
27
|
+
.digest("hex");
|
|
28
|
+
const id = `${table.name}.${hash}`;
|
|
29
|
+
const cache = cacheSources[id];
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
if (cache === undefined) {
|
|
32
|
+
options.verbose &&
|
|
33
|
+
console.log(`Nothing in cache. Running and storing in cache.`);
|
|
34
|
+
await runAndWrite(table, run, cacheSources, cacheSourcesPath, cachePath, id);
|
|
35
|
+
}
|
|
36
|
+
else if (cache &&
|
|
37
|
+
typeof options.ttl === "number" &&
|
|
38
|
+
now - cache.creation > options.ttl * 1000) {
|
|
39
|
+
options.verbose &&
|
|
40
|
+
console.log(`Found in cache.\nttl of ${(0, prettyDuration_js_1.default)(0, { end: options.ttl * 1000 })} has expired.\nThe creation date is ${(0, formatDate_js_1.default)(new Date(cache.creation), "Month DD, YYYY, at HH:MM period")}.\nIt's is ${(0, prettyDuration_js_1.default)(cache.creation, { end: now })} ago.\nRunning and storing in cache.`);
|
|
41
|
+
await runAndWrite(table, run, cacheSources, cacheSourcesPath, cachePath, id);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
options.verbose &&
|
|
45
|
+
console.log(`Found in cache.`);
|
|
46
|
+
if (typeof options.ttl === "number") {
|
|
47
|
+
const ttlLimit = new Date(cache.creation + options.ttl * 1000);
|
|
48
|
+
(options.verbose) &&
|
|
49
|
+
console.log(`ttl of ${(0, prettyDuration_js_1.default)(0, { end: options.ttl * 1000 })} has not expired.\nThe creation date is ${(0, formatDate_js_1.default)(new Date(cache.creation), "Month DD, YYYY, at HH:MM period")}.\nThere are ${(0, prettyDuration_js_1.default)(now, { end: ttlLimit })} left.`);
|
|
50
|
+
}
|
|
51
|
+
if (cache.file === null) {
|
|
52
|
+
console.log("No data in cache. Nothing to load.");
|
|
53
|
+
}
|
|
54
|
+
else if (cache.geo) {
|
|
55
|
+
const start = Date.now();
|
|
56
|
+
await table.loadGeoData(cache.file);
|
|
57
|
+
if (table.sdb.cacheSourcesUsed.indexOf(id) < 0) {
|
|
58
|
+
table.sdb.cacheSourcesUsed.push(id);
|
|
59
|
+
}
|
|
60
|
+
const end = Date.now();
|
|
61
|
+
const duration = end - start;
|
|
62
|
+
if (options.verbose) {
|
|
63
|
+
console.log(`Data loaded in ${(0, prettyDuration_js_1.default)(start, { end })}.\nRunning computations previously took ${(0, prettyDuration_js_1.default)(0, { end: cache.duration })}.\nYou saved ${(0, prettyDuration_js_1.default)(duration, { end: cache.duration })}.\n`);
|
|
64
|
+
table.sdb.cacheTimeSaved += cache.duration - duration;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const start = Date.now();
|
|
69
|
+
await table.loadData(cache.file);
|
|
70
|
+
if (table.sdb.cacheSourcesUsed.indexOf(id) < 0) {
|
|
71
|
+
table.sdb.cacheSourcesUsed.push(id);
|
|
72
|
+
}
|
|
73
|
+
const end = Date.now();
|
|
74
|
+
const duration = end - start;
|
|
75
|
+
if (options.verbose) {
|
|
76
|
+
console.log(`Data loaded in ${(0, prettyDuration_js_1.default)(start, { end })}.\nRunning computations previously took ${(0, prettyDuration_js_1.default)(0, { end: cache.duration })}.\nYou saved ${(0, prettyDuration_js_1.default)(duration, { end: cache.duration })}.\n`);
|
|
77
|
+
table.sdb.cacheTimeSaved += cache.duration - duration;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function runAndWrite(table, run, cacheSources, cacheSourcesPath, cachePath, id) {
|
|
83
|
+
const start = Date.now();
|
|
84
|
+
await run();
|
|
85
|
+
const end = Date.now();
|
|
86
|
+
const duration = end - start;
|
|
87
|
+
table.sdb.cacheVerbose &&
|
|
88
|
+
console.log(`Computations done in ${(0, prettyDuration_js_1.default)(start, { end })}.`);
|
|
89
|
+
if (!(await table.sdb.hasTable(table.name))) {
|
|
90
|
+
console.log(`No data in table ${table.name}. Nothing stored in cache.`);
|
|
91
|
+
cacheSources[id] = {
|
|
92
|
+
creation: Date.now(),
|
|
93
|
+
duration,
|
|
94
|
+
file: null,
|
|
95
|
+
geo: false,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const types = await table.getTypes();
|
|
100
|
+
const geometriesColumns = Object.values(types).filter((d) => d === "GEOMETRY").length;
|
|
101
|
+
if (geometriesColumns > 0) {
|
|
102
|
+
const file = `${cachePath}/${id}.geoparquet`;
|
|
103
|
+
const writeStart = Date.now();
|
|
104
|
+
await table.writeGeoData(file);
|
|
105
|
+
cacheSources[id] = {
|
|
106
|
+
creation: Date.now(),
|
|
107
|
+
duration,
|
|
108
|
+
file,
|
|
109
|
+
geo: true,
|
|
110
|
+
};
|
|
111
|
+
const writeEnd = Date.now();
|
|
112
|
+
table.sdb.cacheVerbose &&
|
|
113
|
+
console.log(`Wrote in cache in ${(0, prettyDuration_js_1.default)(writeStart, { end: writeEnd })}.\n`);
|
|
114
|
+
table.sdb.cacheTimeWriting += writeEnd - writeStart;
|
|
115
|
+
if (table.sdb.cacheSourcesUsed.indexOf(id) < 0) {
|
|
116
|
+
table.sdb.cacheSourcesUsed.push(id);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const file = `${cachePath}/${id}.parquet`;
|
|
121
|
+
const writeStart = Date.now();
|
|
122
|
+
await table.writeData(file);
|
|
123
|
+
const writeEnd = Date.now();
|
|
124
|
+
table.sdb.cacheVerbose &&
|
|
125
|
+
console.log(`Wrote in cache in ${(0, prettyDuration_js_1.default)(writeStart, { end: writeEnd })}.\n`);
|
|
126
|
+
table.sdb.cacheTimeWriting += writeEnd - writeStart;
|
|
127
|
+
cacheSources[id] = {
|
|
128
|
+
creation: Date.now(),
|
|
129
|
+
duration,
|
|
130
|
+
file,
|
|
131
|
+
geo: false,
|
|
132
|
+
};
|
|
133
|
+
if (table.sdb.cacheSourcesUsed.indexOf(id) < 0) {
|
|
134
|
+
table.sdb.cacheSourcesUsed.push(id);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
(0, node_fs_1.writeFileSync)(cacheSourcesPath, JSON.stringify(cacheSources));
|
|
139
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capitalizeQuery.d.ts","sourceRoot":"","sources":["../../src/methods/capitalizeQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UASvE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = capitalizeQuery;
|
|
4
|
+
function capitalizeQuery(table, columns) {
|
|
5
|
+
let query = "";
|
|
6
|
+
for (const column of columns) {
|
|
7
|
+
query +=
|
|
8
|
+
`\nUPDATE "${table}" SET "${column}" = CONCAT(UPPER(LEFT("${column}", 1)), LOWER(RIGHT("${column}", LENGTH("${column}")-1)));`;
|
|
9
|
+
}
|
|
10
|
+
return query;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloneColumn.d.ts","sourceRoot":"","sources":["../../src/methods/cloneColumn.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,UAejC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = cloneColumnQuery;
|
|
4
|
+
function cloneColumnQuery(table, originalColumn, newColumn, types) {
|
|
5
|
+
let query = "";
|
|
6
|
+
const originalColumnType = types[originalColumn];
|
|
7
|
+
if (originalColumnType) {
|
|
8
|
+
query +=
|
|
9
|
+
`ALTER TABLE "${table}" ADD COLUMN "${newColumn}" ${originalColumnType};
|
|
10
|
+
UPDATE "${table}" SET "${newColumn}" = "${originalColumn}"`;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
throw new Error(`Can't find type of ${originalColumn}`);
|
|
14
|
+
}
|
|
15
|
+
return query;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloneQuery.d.ts","sourceRoot":"","sources":["../../src/methods/cloneQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB,UASP"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = cloneQuery;
|
|
4
|
+
function cloneQuery(table, newTable, columns, options = {}) {
|
|
5
|
+
const selectClause = columns.length > 0
|
|
6
|
+
? columns.map((col) => `"${col}"`).join(", ")
|
|
7
|
+
: "*";
|
|
8
|
+
return `CREATE OR REPLACE TABLE "${newTable}" AS SELECT ${selectClause} FROM "${table}"${options.conditions ? ` WHERE ${options.conditions}` : ""}`;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concatenateQuery.d.ts","sourceRoot":"","sources":["../../src/methods/concatenateQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,UAehC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = concatenateQuery;
|
|
4
|
+
function concatenateQuery(table, columns, newColumn, options) {
|
|
5
|
+
let query = `ALTER TABLE "${table}" ADD "${newColumn}" VARCHAR;
|
|
6
|
+
UPDATE "${table}" SET "${newColumn}" = `;
|
|
7
|
+
if (typeof options.separator === "string") {
|
|
8
|
+
query += `CONCAT_WS('${options.separator}', ${columns
|
|
9
|
+
.map((d) => `"${d}"`)
|
|
10
|
+
.join(", ")})`;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
query += `CONCAT(${columns.map((d) => `"${d}"`).join(", ")})`;
|
|
14
|
+
}
|
|
15
|
+
return query;
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export default function convertQuery(table: string, columns: string[], columnsTypes: ("integer" | "float" | "number" | "string" | "date" | "time" | "datetime" | "datetimeTz" | "bigint" | "double" | "varchar" | "timestamp" | "timestamp with time zone" | "boolean")[], allColumns: string[], allTypes: {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}, options: {
|
|
4
|
+
datetimeFormat?: string;
|
|
5
|
+
try?: boolean;
|
|
6
|
+
}): string;
|
|
7
|
+
//# sourceMappingURL=convertQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertQuery.d.ts","sourceRoot":"","sources":["../../src/methods/convertQuery.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,EACjB,YAAY,EAAE,CACV,SAAS,GACT,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,0BAA0B,GAC1B,SAAS,CACZ,EAAE,EACH,UAAU,EAAE,MAAM,EAAE,EACpB,QAAQ,EAAE;IACR,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,EACD,OAAO,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,UAiFpD"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = convertQuery;
|
|
7
|
+
const parseTypes_js_1 = __importDefault(require("../helpers/parseTypes.js"));
|
|
8
|
+
function convertQuery(table, columns, columnsTypes, allColumns, allTypes, options) {
|
|
9
|
+
let query = "";
|
|
10
|
+
// First, we clean if needed
|
|
11
|
+
for (const column of allColumns) {
|
|
12
|
+
const indexOf = columns.indexOf(column);
|
|
13
|
+
if (indexOf >= 0) {
|
|
14
|
+
const expectedType = (0, parseTypes_js_1.default)(columnsTypes[indexOf]);
|
|
15
|
+
const currentType = allTypes[column];
|
|
16
|
+
const stringToNumber = currentType === "VARCHAR" &&
|
|
17
|
+
["DOUBLE", "BIGINT"].includes(expectedType);
|
|
18
|
+
if (stringToNumber) {
|
|
19
|
+
query +=
|
|
20
|
+
`UPDATE "${table}" SET "${column}" = REPLACE("${column}", ',', '');\n`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
query += `CREATE OR REPLACE TABLE "${table}" AS SELECT`;
|
|
25
|
+
const cast = options.try ? "TRY_CAST" : "CAST";
|
|
26
|
+
for (const column of allColumns) {
|
|
27
|
+
const indexOf = columns.indexOf(column);
|
|
28
|
+
if (indexOf === -1) {
|
|
29
|
+
query += ` "${column}",`;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const expectedType = (0, parseTypes_js_1.default)(columnsTypes[indexOf]);
|
|
33
|
+
const currentType = allTypes[column];
|
|
34
|
+
const datetimeFormatExist = typeof options.datetimeFormat === "string";
|
|
35
|
+
const stringToDate = currentType === "VARCHAR" &&
|
|
36
|
+
(expectedType.includes("TIME") || expectedType.includes("DATE"));
|
|
37
|
+
const dateToString = (currentType.includes("DATE") ||
|
|
38
|
+
currentType.includes("TIME")) &&
|
|
39
|
+
expectedType === "VARCHAR";
|
|
40
|
+
const timeToMs = currentType.includes("TIME") &&
|
|
41
|
+
["DOUBLE", "BIGINT"].includes(expectedType);
|
|
42
|
+
const dateToMs = currentType.includes("DATE") &&
|
|
43
|
+
["DOUBLE", "BIGINT"].includes(expectedType);
|
|
44
|
+
const msToTime = ["DOUBLE", "BIGINT"].includes(currentType) &&
|
|
45
|
+
expectedType === "TIME";
|
|
46
|
+
const msToDate = ["DOUBLE", "BIGINT"].includes(currentType) &&
|
|
47
|
+
expectedType.includes("DATE");
|
|
48
|
+
const msToTimestamp = ["DOUBLE", "BIGINT"].includes(currentType) &&
|
|
49
|
+
expectedType.includes("TIMESTAMP");
|
|
50
|
+
if (datetimeFormatExist && stringToDate) {
|
|
51
|
+
query +=
|
|
52
|
+
` strptime("${column}", '${options.datetimeFormat}') AS "${column}",`;
|
|
53
|
+
}
|
|
54
|
+
else if (datetimeFormatExist && dateToString) {
|
|
55
|
+
query +=
|
|
56
|
+
` strftime("${column}", '${options.datetimeFormat}') AS "${column}",`;
|
|
57
|
+
}
|
|
58
|
+
else if (timeToMs) {
|
|
59
|
+
query += ` date_part('epoch', "${column}") * 1000 AS "${column}",`;
|
|
60
|
+
}
|
|
61
|
+
else if (dateToMs) {
|
|
62
|
+
query += ` epoch("${column}") * 1000 AS "${column}",`;
|
|
63
|
+
}
|
|
64
|
+
else if (msToTime) {
|
|
65
|
+
query +=
|
|
66
|
+
` TIME '00:00:00' + to_milliseconds("${column}") AS "${column}",`;
|
|
67
|
+
}
|
|
68
|
+
else if (msToDate) {
|
|
69
|
+
query +=
|
|
70
|
+
` DATE '1970-01-01' + to_milliseconds("${column}") AS "${column}",`;
|
|
71
|
+
}
|
|
72
|
+
else if (msToTimestamp) {
|
|
73
|
+
query +=
|
|
74
|
+
` TIMESTAMP '1970-01-01 00:00:00' + to_milliseconds("${column}") AS "${column}",`;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
query += ` ${cast}("${columns[indexOf]}" AS ${(0, parseTypes_js_1.default)(columnsTypes[indexOf])}) AS "${columns[indexOf]}",`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
query = query.slice(0, query.length - 1);
|
|
82
|
+
query += ` FROM "${table}"`;
|
|
83
|
+
return query;
|
|
84
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type SimpleTable from "../class/SimpleTable.js";
|
|
2
|
+
export default function correlations(SimpleTable: SimpleTable, options?: {
|
|
3
|
+
x?: string;
|
|
4
|
+
y?: string;
|
|
5
|
+
categories?: string | string[];
|
|
6
|
+
decimals?: number;
|
|
7
|
+
outputTable?: string | boolean;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=correlations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlations.d.ts","sourceRoot":"","sources":["../../src/methods/correlations.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD,wBAA8B,YAAY,CACxC,WAAW,EAAE,WAAW,EACxB,OAAO,GAAE;IACP,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B,iBA2CP"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = correlations;
|
|
7
|
+
const getCombinations_js_1 = __importDefault(require("../helpers/getCombinations.js"));
|
|
8
|
+
const keepNumericalColumns_js_1 = __importDefault(require("../helpers/keepNumericalColumns.js"));
|
|
9
|
+
const mergeOptions_js_1 = __importDefault(require("../helpers/mergeOptions.js"));
|
|
10
|
+
const queryDB_js_1 = __importDefault(require("../helpers/queryDB.js"));
|
|
11
|
+
const correlationsQuery_js_1 = __importDefault(require("./correlationsQuery.js"));
|
|
12
|
+
async function correlations(SimpleTable, options = {}) {
|
|
13
|
+
const outputTable = typeof options.outputTable === "string"
|
|
14
|
+
? options.outputTable
|
|
15
|
+
: SimpleTable.name;
|
|
16
|
+
let combinations = [];
|
|
17
|
+
if (!options.x && !options.y) {
|
|
18
|
+
const types = await SimpleTable.getTypes();
|
|
19
|
+
const columns = (0, keepNumericalColumns_js_1.default)(types);
|
|
20
|
+
combinations = (0, getCombinations_js_1.default)(columns, 2);
|
|
21
|
+
}
|
|
22
|
+
else if (options.x && !options.y) {
|
|
23
|
+
const types = await SimpleTable.getTypes();
|
|
24
|
+
const columns = (0, keepNumericalColumns_js_1.default)(types);
|
|
25
|
+
combinations = [];
|
|
26
|
+
for (const col of columns) {
|
|
27
|
+
if (col !== options.x) {
|
|
28
|
+
combinations.push([options.x, col]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (options.x && options.y) {
|
|
33
|
+
combinations = [[options.x, options.y]];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw new Error("No combinations of x and y");
|
|
37
|
+
}
|
|
38
|
+
await (0, queryDB_js_1.default)(SimpleTable, (0, correlationsQuery_js_1.default)(SimpleTable.name, outputTable, combinations, options), (0, mergeOptions_js_1.default)(SimpleTable, {
|
|
39
|
+
table: outputTable,
|
|
40
|
+
method: "correlations()",
|
|
41
|
+
parameters: {
|
|
42
|
+
options,
|
|
43
|
+
"combinations (computed)": combinations,
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlationsQuery.d.ts","sourceRoot":"","sources":["../../src/methods/correlationsQuery.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAChC,OAAO,EAAE;IACP,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,UAgCF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = correlationsQuery;
|
|
7
|
+
const stringToArray_js_1 = __importDefault(require("../helpers/stringToArray.js"));
|
|
8
|
+
function correlationsQuery(table, outputTable, combinations, options) {
|
|
9
|
+
const categories = options.categories
|
|
10
|
+
? (0, stringToArray_js_1.default)(options.categories)
|
|
11
|
+
: [];
|
|
12
|
+
const groupBy = categories.length === 0
|
|
13
|
+
? ""
|
|
14
|
+
: ` GROUP BY ${categories.map((d) => `"${d}"`).join(",")}`;
|
|
15
|
+
let query = `CREATE OR REPLACE TABLE "${outputTable}" AS`;
|
|
16
|
+
let firstValue = true;
|
|
17
|
+
for (const comb of combinations) {
|
|
18
|
+
if (firstValue) {
|
|
19
|
+
firstValue = false;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
query += "\nUNION";
|
|
23
|
+
}
|
|
24
|
+
const tempQuery = typeof options.decimals === "number"
|
|
25
|
+
? `ROUND(corr("${comb[0]}", "${comb[1]}"), ${options.decimals})`
|
|
26
|
+
: `corr("${comb[0]}", "${comb[1]}")`;
|
|
27
|
+
query += `\nSELECT ${categories.length > 0
|
|
28
|
+
? `${categories.map((d) => `"${d}"`).join(",")}, `
|
|
29
|
+
: ""}'${comb[0]}' AS x, '${comb[1]}' AS y, ${tempQuery} as "corr" FROM "${table}"${groupBy}`;
|
|
30
|
+
}
|
|
31
|
+
return query;
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type SimpleTable from "../class/SimpleTable.js";
|
|
2
|
+
export default function createFtsIndex(simpleTable: SimpleTable, columnId: string, columnText: string, options?: {
|
|
3
|
+
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";
|
|
4
|
+
stopwords?: string;
|
|
5
|
+
ignore?: string;
|
|
6
|
+
stripAccents?: boolean;
|
|
7
|
+
lower?: boolean;
|
|
8
|
+
overwrite?: boolean;
|
|
9
|
+
verbose?: boolean;
|
|
10
|
+
}): Promise<SimpleTable>;
|
|
11
|
+
//# sourceMappingURL=createFtsIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFtsIndex.d.ts","sourceRoot":"","sources":["../../src/methods/createFtsIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD,wBAA8B,cAAc,CAC1C,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,OAAO,CAAC,EACJ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,OAAO,GACP,WAAW,GACX,YAAY,GACZ,OAAO,GACP,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,UAAU,GACV,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,OAAO,GACP,SAAS,GACT,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACd,wBAkDP"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = createFtsIndex;
|
|
7
|
+
const camelCase_js_1 = __importDefault(require("../helpers/camelCase.js"));
|
|
8
|
+
async function createFtsIndex(simpleTable, columnId, columnText, options = {}) {
|
|
9
|
+
const indexName = `fts_index_${(0, camelCase_js_1.default)(simpleTable.name)}`;
|
|
10
|
+
const indexExists = simpleTable.indexes.includes(indexName);
|
|
11
|
+
if (indexExists && options.overwrite) {
|
|
12
|
+
options.verbose &&
|
|
13
|
+
console.log(`\nDropping existing FTS index on "${columnText}" column...`);
|
|
14
|
+
await simpleTable.sdb.customQuery(`PRAGMA drop_fts_index("${simpleTable.name}");`);
|
|
15
|
+
options.verbose && console.log("FTS index dropped.");
|
|
16
|
+
}
|
|
17
|
+
if (!indexExists || options.overwrite) {
|
|
18
|
+
options.verbose &&
|
|
19
|
+
console.log(`\nCreating FTS index on "${columnText}" column...`);
|
|
20
|
+
await simpleTable.sdb.customQuery(`PRAGMA create_fts_index("${simpleTable.name}", "${columnId}", "${columnText}"${options.stemmer ? `, stemmer = '${options.stemmer}'` : ""}${options.stopwords ? `, stopwords = '${options.stopwords}'` : ""}${options.ignore ? `, ignore = '${options.ignore}'` : ""}${typeof options.stripAccents === "boolean"
|
|
21
|
+
? `, strip_accents = ${options.stripAccents ? 1 : 0}`
|
|
22
|
+
: ""}${typeof options.lower === "boolean"
|
|
23
|
+
? `, lower = ${options.lower ? 1 : 0}`
|
|
24
|
+
: ""});`);
|
|
25
|
+
if (!simpleTable.indexes.includes(indexName)) {
|
|
26
|
+
simpleTable.indexes.push(indexName);
|
|
27
|
+
}
|
|
28
|
+
options.verbose && console.log("FTS index created successfully.");
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
options.verbose && console.log("FTS index already exists.");
|
|
32
|
+
}
|
|
33
|
+
return simpleTable;
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type SimpleTable from "../class/SimpleTable.js";
|
|
2
|
+
export default function createVssIndex(simpleTable: SimpleTable, column: string, options?: {
|
|
3
|
+
overwrite?: boolean;
|
|
4
|
+
verbose?: boolean;
|
|
5
|
+
efConstruction?: number;
|
|
6
|
+
efSearch?: number;
|
|
7
|
+
M?: number;
|
|
8
|
+
}): Promise<SimpleTable>;
|
|
9
|
+
//# sourceMappingURL=createVssIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createVssIndex.d.ts","sourceRoot":"","sources":["../../src/methods/createVssIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD,wBAA8B,cAAc,CAC1C,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IACP,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,CAAC,EAAE,MAAM,CAAC;CACP,wBAyDP"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = createVssIndex;
|
|
7
|
+
const camelCase_js_1 = __importDefault(require("../helpers/camelCase.js"));
|
|
8
|
+
async function createVssIndex(simpleTable, column, options = {}) {
|
|
9
|
+
const indexName = `vss_cosine_index_${(0, camelCase_js_1.default)(simpleTable.name)}`;
|
|
10
|
+
const indexExists = simpleTable.indexes.includes(indexName);
|
|
11
|
+
if (indexExists && options.overwrite) {
|
|
12
|
+
options.verbose &&
|
|
13
|
+
console.log(`\nDropping existing VSS index on "${column}" column...`);
|
|
14
|
+
await simpleTable.sdb.customQuery(`DROP INDEX IF EXISTS ${indexName};`);
|
|
15
|
+
options.verbose && console.log("VSS index dropped.");
|
|
16
|
+
}
|
|
17
|
+
if (!indexExists || options.overwrite) {
|
|
18
|
+
options.verbose &&
|
|
19
|
+
console.log(`\nCreating VSS index on "${column}" column...`);
|
|
20
|
+
// Build the WITH clause with all options
|
|
21
|
+
const withOptions = ["metric = 'cosine'"];
|
|
22
|
+
if (options.efConstruction !== undefined) {
|
|
23
|
+
withOptions.push(`ef_construction = ${options.efConstruction}`);
|
|
24
|
+
}
|
|
25
|
+
if (options.efSearch !== undefined) {
|
|
26
|
+
withOptions.push(`ef_search = ${options.efSearch}`);
|
|
27
|
+
}
|
|
28
|
+
if (options.M !== undefined) {
|
|
29
|
+
withOptions.push(`M = ${options.M}`);
|
|
30
|
+
}
|
|
31
|
+
await simpleTable.sdb.customQuery(`INSTALL vss; LOAD vss;${simpleTable.sdb.file !== ":memory:"
|
|
32
|
+
? "\nSET hnsw_enable_experimental_persistence=true;"
|
|
33
|
+
: ""}
|
|
34
|
+
CREATE INDEX ${indexName} ON "${simpleTable.name}" USING HNSW ("${column}") WITH (${withOptions.join(", ")});`);
|
|
35
|
+
if (!simpleTable.indexes.includes(indexName)) {
|
|
36
|
+
simpleTable.indexes.push(indexName);
|
|
37
|
+
}
|
|
38
|
+
options.verbose && console.log("VSS index created successfully.");
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
options.verbose && console.log("VSS index already exists.");
|
|
42
|
+
}
|
|
43
|
+
return simpleTable;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crossJoinQuery.d.ts","sourceRoot":"","sources":["../../src/methods/crossJoinQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B,UAKP"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = crossJoinQuery;
|
|
4
|
+
function crossJoinQuery(table, rightTable, options = {}) {
|
|
5
|
+
return `CREATE OR REPLACE TABLE "${options.outputTable ?? table}" AS SELECT "${table}".*, "${rightTable}".* FROM "${table}" CROSS JOIN "${rightTable}";`;
|
|
6
|
+
}
|