@cubejs-backend/crate-driver 1.7.2 → 1.7.3
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.
|
@@ -6,5 +6,16 @@
|
|
|
6
6
|
import { PostgresDriver, PgClient } from '@cubejs-backend/postgres-driver';
|
|
7
7
|
export declare class CrateDriver extends PostgresDriver {
|
|
8
8
|
protected prepareConnection(conn: PgClient, _options: any): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* CrateDB's Postgres-wire protocol does not accept bound parameters inside a
|
|
11
|
+
* `CREATE TABLE AS` statement -- it fails with "Requested parameter index
|
|
12
|
+
* exceeds the number of parameters: 0".
|
|
13
|
+
*
|
|
14
|
+
* The ParameterDescription message works for the most common use cases except for DDL statements
|
|
15
|
+
* https://cratedb.com/docs/crate/reference/en/latest/interfaces/postgres.html#extended-query
|
|
16
|
+
*/
|
|
17
|
+
loadPreAggregationIntoTable(preAggregationTableName: string, loadSql: string, params: unknown[], options: any): Promise<any>;
|
|
18
|
+
protected static inlineParams(sql: string, params: unknown[]): string;
|
|
19
|
+
protected static formatParam(value: unknown): string;
|
|
9
20
|
}
|
|
10
21
|
//# sourceMappingURL=CrateDriver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrateDriver.d.ts","sourceRoot":"","sources":["../../src/CrateDriver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3E,qBAAa,WAAY,SAAQ,cAAc;cAC7B,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"CrateDriver.d.ts","sourceRoot":"","sources":["../../src/CrateDriver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3E,qBAAa,WAAY,SAAQ,cAAc;cAC7B,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG;IAQ/D;;;;;;;OAOG;IACU,2BAA2B,CACtC,uBAAuB,EAAE,MAAM,EAC/B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,EAAE,EACjB,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,GAAG,CAAC;IAiBf,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM;IAWrE,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;CAmBrD"}
|
package/dist/src/CrateDriver.js
CHANGED
|
@@ -14,6 +14,47 @@ class CrateDriver extends postgres_driver_1.PostgresDriver {
|
|
|
14
14
|
// await conn.query(`SET statement_timeout TO ${options.executionTimeout}`);
|
|
15
15
|
await this.loadUserDefinedTypes(conn);
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* CrateDB's Postgres-wire protocol does not accept bound parameters inside a
|
|
19
|
+
* `CREATE TABLE AS` statement -- it fails with "Requested parameter index
|
|
20
|
+
* exceeds the number of parameters: 0".
|
|
21
|
+
*
|
|
22
|
+
* The ParameterDescription message works for the most common use cases except for DDL statements
|
|
23
|
+
* https://cratedb.com/docs/crate/reference/en/latest/interfaces/postgres.html#extended-query
|
|
24
|
+
*/
|
|
25
|
+
async loadPreAggregationIntoTable(preAggregationTableName, loadSql, params, options) {
|
|
26
|
+
const result = await super.loadPreAggregationIntoTable(preAggregationTableName, CrateDriver.inlineParams(loadSql, params), [], options);
|
|
27
|
+
// CrateDB is eventually consistent: rows written by the `CREATE TABLE AS`
|
|
28
|
+
// above are not visible to subsequent reads until the table is refreshed.
|
|
29
|
+
// Refresh so the freshly materialized pre-aggregation is immediately readable.
|
|
30
|
+
// See https://cratedb.com/docs/crate/reference/en/latest/general/dql/refresh.html
|
|
31
|
+
await this.query(`REFRESH TABLE ${preAggregationTableName}`, []);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
static inlineParams(sql, params) {
|
|
35
|
+
if (!params || params.length === 0) {
|
|
36
|
+
return sql;
|
|
37
|
+
}
|
|
38
|
+
return sql.replace(/\$(\d+)/g, (match, index) => {
|
|
39
|
+
const param = params[parseInt(index, 10) - 1];
|
|
40
|
+
return param === undefined ? match : CrateDriver.formatParam(param);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
static formatParam(value) {
|
|
44
|
+
if (value === null) {
|
|
45
|
+
return 'NULL';
|
|
46
|
+
}
|
|
47
|
+
if (typeof value === 'number') {
|
|
48
|
+
return `${value}`;
|
|
49
|
+
}
|
|
50
|
+
if (typeof value === 'boolean') {
|
|
51
|
+
return value ? 'TRUE' : 'FALSE';
|
|
52
|
+
}
|
|
53
|
+
if (value instanceof Date) {
|
|
54
|
+
return `'${value.toISOString()}'`;
|
|
55
|
+
}
|
|
56
|
+
return `'${String(value).replace(/'/g, '\'\'')}'`;
|
|
57
|
+
}
|
|
17
58
|
}
|
|
18
59
|
exports.CrateDriver = CrateDriver;
|
|
19
60
|
//# sourceMappingURL=CrateDriver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrateDriver.js","sourceRoot":"","sources":["../../src/CrateDriver.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,qEAA2E;AAE3E,MAAa,WAAY,SAAQ,gCAAc;IACnC,KAAK,CAAC,iBAAiB,CAAC,IAAc,EAAE,QAAa;QAC7D,4EAA4E;QAC5E,6EAA6E;QAC7E,4EAA4E;QAE5E,MAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"CrateDriver.js","sourceRoot":"","sources":["../../src/CrateDriver.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,qEAA2E;AAE3E,MAAa,WAAY,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YAC7B,OAAO,GAAG,KAAK,EAAE,CAAC;SACnB;QAED,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;YAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;SACjC;QAED,IAAI,KAAK,YAAY,IAAI,EAAE;YACzB,OAAO,IAAI,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC;SACnC;QAED,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC;IACpD,CAAC;CACF;AArED,kCAqEC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@cubejs-backend/crate-driver",
|
|
3
3
|
"description": "Cube.js Crate database driver",
|
|
4
4
|
"author": "Cube Dev, Inc.",
|
|
5
|
-
"version": "1.7.
|
|
5
|
+
"version": "1.7.3",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/cube-js/cube.git",
|
|
@@ -24,17 +24,18 @@
|
|
|
24
24
|
"test": "yarn integration",
|
|
25
25
|
"integration": "npm run integration:crate",
|
|
26
26
|
"integration:crate": "jest --verbose dist/test",
|
|
27
|
+
"unit": "jest --forceExit --verbose dist/test/CrateDriver.unit.test.js",
|
|
27
28
|
"lint": "eslint src/* --ext .ts",
|
|
28
29
|
"lint:fix": "eslint --fix src/* --ext .ts"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@cubejs-backend/postgres-driver": "1.7.
|
|
32
|
-
"@cubejs-backend/shared": "1.7.
|
|
32
|
+
"@cubejs-backend/postgres-driver": "1.7.3",
|
|
33
|
+
"@cubejs-backend/shared": "1.7.3"
|
|
33
34
|
},
|
|
34
35
|
"license": "Apache-2.0",
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@cubejs-backend/linter": "1.7.
|
|
37
|
-
"@cubejs-backend/testing-shared": "1.7.
|
|
37
|
+
"@cubejs-backend/linter": "1.7.3",
|
|
38
|
+
"@cubejs-backend/testing-shared": "1.7.3",
|
|
38
39
|
"testcontainers": "^10.28.0",
|
|
39
40
|
"typescript": "~5.2.2"
|
|
40
41
|
},
|
|
@@ -47,5 +48,5 @@
|
|
|
47
48
|
"eslintConfig": {
|
|
48
49
|
"extends": "../cubejs-linter"
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b8cfde8a2b0af0445fb8e3d9443ab1873b515e59"
|
|
51
52
|
}
|