@devrev/meerkat-node 0.0.101 → 0.0.104
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/cube-to-sql/cube-to-sql.js +1 -1
- package/cube-to-sql/cube-to-sql.js.map +1 -1
- package/cube-to-sql-with-resolution/cube-to-sql-with-resolution.js +2 -2
- package/cube-to-sql-with-resolution/cube-to-sql-with-resolution.js.map +1 -1
- package/package.json +3 -3
- package/src/cube-to-sql-with-resolution/cube-to-sql-with-resolution.d.ts +2 -1
|
@@ -19,7 +19,7 @@ const cubeQueryToSQL = async ({ query, tableSchemas, contextParams })=>{
|
|
|
19
19
|
sql: baseFilterParamsSQL
|
|
20
20
|
});
|
|
21
21
|
}));
|
|
22
|
-
const updatedTableSchema =
|
|
22
|
+
const updatedTableSchema = (0, _meerkatcore.getCombinedTableSchema)(updatedTableSchemas, query);
|
|
23
23
|
const ast = (0, _meerkatcore.cubeToDuckdbAST)(query, updatedTableSchema);
|
|
24
24
|
if (!ast) {
|
|
25
25
|
throw new Error('Could not generate AST');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../meerkat-node/src/cube-to-sql/cube-to-sql.ts"],"sourcesContent":["import {\n BASE_TABLE_NAME,\n ContextParams,\n Query,\n TableSchema,\n applyFilterParamsToBaseSQL,\n applyProjectionToSQLQuery,\n astDeserializerQuery,\n cubeToDuckdbAST,\n deserializeQuery,\n detectApplyContextParamsToBaseSQL,\n getCombinedTableSchema,\n getFilterParamsSQL,\n getFinalBaseSQL,\n} from '@devrev/meerkat-core';\nimport { duckdbExec } from '../duckdb-exec';\n\nexport interface CubeQueryToSQLParams {\n query: Query;\n tableSchemas: TableSchema[];\n contextParams?: ContextParams;\n}\n\nexport const cubeQueryToSQL = async ({\n query,\n tableSchemas,\n contextParams,\n}: CubeQueryToSQLParams) => {\n const updatedTableSchemas: TableSchema[] = await Promise.all(\n tableSchemas.map(async (schema: TableSchema) => {\n const baseFilterParamsSQL = await getFinalBaseSQL({\n query,\n tableSchema: schema,\n getQueryOutput: duckdbExec,\n });\n return {\n ...schema,\n sql: baseFilterParamsSQL,\n };\n })\n );\n\n const updatedTableSchema =
|
|
1
|
+
{"version":3,"sources":["../../../meerkat-node/src/cube-to-sql/cube-to-sql.ts"],"sourcesContent":["import {\n BASE_TABLE_NAME,\n ContextParams,\n Query,\n TableSchema,\n applyFilterParamsToBaseSQL,\n applyProjectionToSQLQuery,\n astDeserializerQuery,\n cubeToDuckdbAST,\n deserializeQuery,\n detectApplyContextParamsToBaseSQL,\n getCombinedTableSchema,\n getFilterParamsSQL,\n getFinalBaseSQL,\n} from '@devrev/meerkat-core';\nimport { duckdbExec } from '../duckdb-exec';\n\nexport interface CubeQueryToSQLParams {\n query: Query;\n tableSchemas: TableSchema[];\n contextParams?: ContextParams;\n}\n\nexport const cubeQueryToSQL = async ({\n query,\n tableSchemas,\n contextParams,\n}: CubeQueryToSQLParams) => {\n const updatedTableSchemas: TableSchema[] = await Promise.all(\n tableSchemas.map(async (schema: TableSchema) => {\n const baseFilterParamsSQL = await getFinalBaseSQL({\n query,\n tableSchema: schema,\n getQueryOutput: duckdbExec,\n });\n return {\n ...schema,\n sql: baseFilterParamsSQL,\n };\n })\n );\n\n const updatedTableSchema = getCombinedTableSchema(updatedTableSchemas, query);\n\n const ast = cubeToDuckdbAST(query, updatedTableSchema);\n if (!ast) {\n throw new Error('Could not generate AST');\n }\n\n const queryTemp = astDeserializerQuery(ast);\n\n const queryOutput = (await duckdbExec(queryTemp)) as Record<string, string>[];\n const preBaseQuery = deserializeQuery(queryOutput);\n\n const filterParamsSQL = await getFilterParamsSQL({\n query,\n tableSchema: updatedTableSchema,\n getQueryOutput: duckdbExec,\n });\n\n const filterParamQuery = applyFilterParamsToBaseSQL(\n updatedTableSchema.sql,\n filterParamsSQL\n );\n\n /**\n * Replace CONTEXT_PARAMS with context params\n */\n const baseQuery = detectApplyContextParamsToBaseSQL(\n filterParamQuery,\n contextParams || {}\n );\n\n /**\n * Replace BASE_TABLE_NAME with cube query\n */\n const replaceBaseTableName = preBaseQuery.replace(\n BASE_TABLE_NAME,\n `(${baseQuery}) AS ${updatedTableSchema.name}`\n );\n\n /**\n * Add measures to the query\n */\n const measures = query.measures;\n const dimensions = query.dimensions || [];\n const finalQuery = applyProjectionToSQLQuery(\n dimensions,\n measures,\n updatedTableSchema,\n replaceBaseTableName\n );\n\n return finalQuery;\n};\n"],"names":["cubeQueryToSQL","query","tableSchemas","contextParams","updatedTableSchemas","Promise","all","map","schema","baseFilterParamsSQL","getFinalBaseSQL","tableSchema","getQueryOutput","duckdbExec","sql","updatedTableSchema","getCombinedTableSchema","ast","cubeToDuckdbAST","Error","queryTemp","astDeserializerQuery","queryOutput","preBaseQuery","deserializeQuery","filterParamsSQL","getFilterParamsSQL","filterParamQuery","applyFilterParamsToBaseSQL","baseQuery","detectApplyContextParamsToBaseSQL","replaceBaseTableName","replace","BASE_TABLE_NAME","name","measures","dimensions","finalQuery","applyProjectionToSQLQuery"],"mappings":";+BAuBaA;;;eAAAA;;;;6BATN;4BACoB;AAQpB,MAAMA,iBAAiB,OAAO,EACnCC,KAAK,EACLC,YAAY,EACZC,aAAa,EACQ;IACrB,MAAMC,sBAAqC,MAAMC,QAAQC,GAAG,CAC1DJ,aAAaK,GAAG,CAAC,OAAOC;QACtB,MAAMC,sBAAsB,MAAMC,IAAAA,4BAAe,EAAC;YAChDT;YACAU,aAAaH;YACbI,gBAAgBC,sBAAU;QAC5B;QACA,OAAO,eACFL;YACHM,KAAKL;;IAET;IAGF,MAAMM,qBAAqBC,IAAAA,mCAAsB,EAACZ,qBAAqBH;IAEvE,MAAMgB,MAAMC,IAAAA,4BAAe,EAACjB,OAAOc;IACnC,IAAI,CAACE,KAAK;QACR,MAAM,IAAIE,MAAM;IAClB;IAEA,MAAMC,YAAYC,IAAAA,iCAAoB,EAACJ;IAEvC,MAAMK,cAAe,MAAMT,IAAAA,sBAAU,EAACO;IACtC,MAAMG,eAAeC,IAAAA,6BAAgB,EAACF;IAEtC,MAAMG,kBAAkB,MAAMC,IAAAA,+BAAkB,EAAC;QAC/CzB;QACAU,aAAaI;QACbH,gBAAgBC,sBAAU;IAC5B;IAEA,MAAMc,mBAAmBC,IAAAA,uCAA0B,EACjDb,mBAAmBD,GAAG,EACtBW;IAGF;;GAEC,GACD,MAAMI,YAAYC,IAAAA,8CAAiC,EACjDH,kBACAxB,iBAAiB,CAAC;IAGpB;;GAEC,GACD,MAAM4B,uBAAuBR,aAAaS,OAAO,CAC/CC,4BAAe,EACf,CAAC,CAAC,EAAEJ,UAAU,KAAK,EAAEd,mBAAmBmB,IAAI,CAAC,CAAC;IAGhD;;GAEC,GACD,MAAMC,WAAWlC,MAAMkC,QAAQ;IAC/B,MAAMC,aAAanC,MAAMmC,UAAU,IAAI,EAAE;IACzC,MAAMC,aAAaC,IAAAA,sCAAyB,EAC1CF,YACAD,UACApB,oBACAgB;IAGF,OAAOM;AACT"}
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "cubeQueryToSQLWithResolution", {
|
|
|
7
7
|
});
|
|
8
8
|
const _meerkatcore = require("@devrev/meerkat-core");
|
|
9
9
|
const _cubetosql = require("../cube-to-sql/cube-to-sql");
|
|
10
|
-
const cubeQueryToSQLWithResolution = async ({ query, tableSchemas, resolutionConfig, contextParams })=>{
|
|
10
|
+
const cubeQueryToSQLWithResolution = async ({ query, tableSchemas, resolutionConfig, columnProjections, contextParams })=>{
|
|
11
11
|
const baseSql = await (0, _cubetosql.cubeQueryToSQL)({
|
|
12
12
|
query,
|
|
13
13
|
tableSchemas,
|
|
@@ -23,7 +23,7 @@ const cubeQueryToSQLWithResolution = async ({ query, tableSchemas, resolutionCon
|
|
|
23
23
|
const resolveParams = {
|
|
24
24
|
query: {
|
|
25
25
|
measures: [],
|
|
26
|
-
dimensions: (0, _meerkatcore.generateResolvedDimensions)(query, resolutionConfig),
|
|
26
|
+
dimensions: (0, _meerkatcore.generateResolvedDimensions)(query, resolutionConfig, columnProjections),
|
|
27
27
|
joinPaths: (0, _meerkatcore.generateResolutionJoinPaths)(resolutionConfig, tableSchemas)
|
|
28
28
|
},
|
|
29
29
|
tableSchemas: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../meerkat-node/src/cube-to-sql-with-resolution/cube-to-sql-with-resolution.ts"],"sourcesContent":["import {\n ContextParams,\n createBaseTableSchema,\n generateResolutionJoinPaths,\n generateResolutionSchemas,\n generateResolvedDimensions,\n Query,\n ResolutionConfig,\n TableSchema,\n} from '@devrev/meerkat-core';\nimport {\n cubeQueryToSQL,\n CubeQueryToSQLParams,\n} from '../cube-to-sql/cube-to-sql';\n\nexport interface CubeQueryToSQLWithResolutionParams {\n query: Query;\n tableSchemas: TableSchema[];\n resolutionConfig: ResolutionConfig;\n contextParams?: ContextParams;\n}\n\nexport const cubeQueryToSQLWithResolution = async ({\n query,\n tableSchemas,\n resolutionConfig,\n contextParams,\n}: CubeQueryToSQLWithResolutionParams) => {\n const baseSql = await cubeQueryToSQL({\n query,\n tableSchemas,\n contextParams,\n });\n\n if (resolutionConfig.columnConfigs.length === 0) {\n // If no resolution is needed, return the base SQL.\n return baseSql;\n }\n\n // Create a table schema for the base query.\n const baseTable: TableSchema = createBaseTableSchema(\n baseSql,\n tableSchemas,\n resolutionConfig,\n query.measures,\n query.dimensions\n );\n\n const resolutionSchemas: TableSchema[] = generateResolutionSchemas(\n resolutionConfig,\n tableSchemas\n );\n\n const resolveParams: CubeQueryToSQLParams = {\n query: {\n measures: [],\n dimensions: generateResolvedDimensions(query
|
|
1
|
+
{"version":3,"sources":["../../../meerkat-node/src/cube-to-sql-with-resolution/cube-to-sql-with-resolution.ts"],"sourcesContent":["import {\n ContextParams,\n createBaseTableSchema,\n generateResolutionJoinPaths,\n generateResolutionSchemas,\n generateResolvedDimensions,\n Query,\n ResolutionConfig,\n TableSchema,\n} from '@devrev/meerkat-core';\nimport {\n cubeQueryToSQL,\n CubeQueryToSQLParams,\n} from '../cube-to-sql/cube-to-sql';\n\nexport interface CubeQueryToSQLWithResolutionParams {\n query: Query;\n tableSchemas: TableSchema[];\n resolutionConfig: ResolutionConfig;\n columnProjections?: string[];\n contextParams?: ContextParams;\n}\n\nexport const cubeQueryToSQLWithResolution = async ({\n query,\n tableSchemas,\n resolutionConfig,\n columnProjections,\n contextParams,\n}: CubeQueryToSQLWithResolutionParams) => {\n const baseSql = await cubeQueryToSQL({\n query,\n tableSchemas,\n contextParams,\n });\n\n if (resolutionConfig.columnConfigs.length === 0) {\n // If no resolution is needed, return the base SQL.\n return baseSql;\n }\n\n // Create a table schema for the base query.\n const baseTable: TableSchema = createBaseTableSchema(\n baseSql,\n tableSchemas,\n resolutionConfig,\n query.measures,\n query.dimensions\n );\n\n const resolutionSchemas: TableSchema[] = generateResolutionSchemas(\n resolutionConfig,\n tableSchemas\n );\n\n const resolveParams: CubeQueryToSQLParams = {\n query: {\n measures: [],\n dimensions: generateResolvedDimensions(\n query,\n resolutionConfig,\n columnProjections\n ),\n joinPaths: generateResolutionJoinPaths(resolutionConfig, tableSchemas),\n },\n tableSchemas: [baseTable, ...resolutionSchemas],\n };\n const sql = await cubeQueryToSQL(resolveParams);\n\n return sql;\n};\n"],"names":["cubeQueryToSQLWithResolution","query","tableSchemas","resolutionConfig","columnProjections","contextParams","baseSql","cubeQueryToSQL","columnConfigs","length","baseTable","createBaseTableSchema","measures","dimensions","resolutionSchemas","generateResolutionSchemas","resolveParams","generateResolvedDimensions","joinPaths","generateResolutionJoinPaths","sql"],"mappings":";+BAuBaA;;;eAAAA;;;6BAdN;2BAIA;AAUA,MAAMA,+BAA+B,OAAO,EACjDC,KAAK,EACLC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,aAAa,EACsB;IACnC,MAAMC,UAAU,MAAMC,IAAAA,yBAAc,EAAC;QACnCN;QACAC;QACAG;IACF;IAEA,IAAIF,iBAAiBK,aAAa,CAACC,MAAM,KAAK,GAAG;QAC/C,mDAAmD;QACnD,OAAOH;IACT;IAEA,4CAA4C;IAC5C,MAAMI,YAAyBC,IAAAA,kCAAqB,EAClDL,SACAJ,cACAC,kBACAF,MAAMW,QAAQ,EACdX,MAAMY,UAAU;IAGlB,MAAMC,oBAAmCC,IAAAA,sCAAyB,EAChEZ,kBACAD;IAGF,MAAMc,gBAAsC;QAC1Cf,OAAO;YACLW,UAAU,EAAE;YACZC,YAAYI,IAAAA,uCAA0B,EACpChB,OACAE,kBACAC;YAEFc,WAAWC,IAAAA,wCAA2B,EAAChB,kBAAkBD;QAC3D;QACAA,cAAc;YAACQ;eAAcI;SAAkB;IACjD;IACA,MAAMM,MAAM,MAAMb,IAAAA,yBAAc,EAACS;IAEjC,OAAOI;AACT"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devrev/meerkat-node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.104",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@swc/helpers": "~0.5.0",
|
|
6
6
|
"@devrev/meerkat-core": "*",
|
|
7
|
-
"axios": "^1.
|
|
7
|
+
"axios": "^1.12.0",
|
|
8
8
|
"lodash": "^4.17.21",
|
|
9
|
-
"duckdb": "^1.
|
|
9
|
+
"duckdb": "^1.3.4"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"release": "semantic-release"
|
|
@@ -3,6 +3,7 @@ export interface CubeQueryToSQLWithResolutionParams {
|
|
|
3
3
|
query: Query;
|
|
4
4
|
tableSchemas: TableSchema[];
|
|
5
5
|
resolutionConfig: ResolutionConfig;
|
|
6
|
+
columnProjections?: string[];
|
|
6
7
|
contextParams?: ContextParams;
|
|
7
8
|
}
|
|
8
|
-
export declare const cubeQueryToSQLWithResolution: ({ query, tableSchemas, resolutionConfig, contextParams, }: CubeQueryToSQLWithResolutionParams) => Promise<string>;
|
|
9
|
+
export declare const cubeQueryToSQLWithResolution: ({ query, tableSchemas, resolutionConfig, columnProjections, contextParams, }: CubeQueryToSQLWithResolutionParams) => Promise<string>;
|