@malloydata/db-snowflake 0.0.382 → 0.0.384
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/dist/index.d.ts +1 -0
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/snowflake_pool_options.d.ts +7 -0
- package/dist/snowflake_pool_options.js +20 -0
- package/dist/snowflake_pool_options.js.map +1 -0
- package/dist/snowflake_pool_options.spec.d.ts +1 -0
- package/dist/snowflake_pool_options.spec.js +42 -0
- package/dist/snowflake_pool_options.spec.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +38 -0
- package/src/snowflake_pool_options.spec.ts +53 -0
- package/src/snowflake_pool_options.ts +21 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -22,15 +22,18 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.SnowflakeConnection = void 0;
|
|
25
|
+
exports.buildPoolOptions = exports.SnowflakeConnection = void 0;
|
|
26
26
|
var snowflake_connection_1 = require("./snowflake_connection");
|
|
27
27
|
Object.defineProperty(exports, "SnowflakeConnection", { enumerable: true, get: function () { return snowflake_connection_1.SnowflakeConnection; } });
|
|
28
|
+
var snowflake_pool_options_1 = require("./snowflake_pool_options");
|
|
29
|
+
Object.defineProperty(exports, "buildPoolOptions", { enumerable: true, get: function () { return snowflake_pool_options_1.buildPoolOptions; } });
|
|
28
30
|
const malloy_1 = require("@malloydata/malloy");
|
|
29
31
|
const snowflake_connection_2 = require("./snowflake_connection");
|
|
32
|
+
const snowflake_pool_options_2 = require("./snowflake_pool_options");
|
|
30
33
|
(0, malloy_1.registerConnectionType)('snowflake', {
|
|
31
34
|
displayName: 'Snowflake',
|
|
32
35
|
factory: async (config) => {
|
|
33
|
-
const { name, is: _, setupSQL, timeoutMs, schemaSampleTimeoutMs, schemaSampleRowLimit, schemaSampleFullScanMaxBytes, ...props } = config;
|
|
36
|
+
const { name, is: _, setupSQL, timeoutMs, schemaSampleTimeoutMs, schemaSampleRowLimit, schemaSampleFullScanMaxBytes, poolMin, poolMax, poolTestOnBorrow, ...props } = config;
|
|
34
37
|
// ConnectionConfig values are trusted to match ConnectionOptions fields
|
|
35
38
|
// because the property definitions below declare matching names/types.
|
|
36
39
|
// The double cast bridges Malloy's generic config to snowflake-sdk's
|
|
@@ -60,6 +63,7 @@ const snowflake_connection_2 = require("./snowflake_connection");
|
|
|
60
63
|
: typeof schemaSampleFullScanMaxBytes === 'string'
|
|
61
64
|
? parseInt(schemaSampleFullScanMaxBytes, 10)
|
|
62
65
|
: undefined,
|
|
66
|
+
poolOptions: (0, snowflake_pool_options_2.buildPoolOptions)({ poolMin, poolMax, poolTestOnBorrow }),
|
|
63
67
|
});
|
|
64
68
|
},
|
|
65
69
|
properties: [
|
|
@@ -107,6 +111,7 @@ const snowflake_connection_2 = require("./snowflake_connection");
|
|
|
107
111
|
displayName: 'Timeout (ms)',
|
|
108
112
|
type: 'number',
|
|
109
113
|
optional: true,
|
|
114
|
+
advanced: true,
|
|
110
115
|
default: 600000,
|
|
111
116
|
},
|
|
112
117
|
{
|
|
@@ -114,6 +119,7 @@ const snowflake_connection_2 = require("./snowflake_connection");
|
|
|
114
119
|
displayName: 'Schema Sample Timeout (ms)',
|
|
115
120
|
type: 'number',
|
|
116
121
|
optional: true,
|
|
122
|
+
advanced: true,
|
|
117
123
|
default: 15000,
|
|
118
124
|
description: 'Timeout for the query that samples variant columns to detect their schema.',
|
|
119
125
|
},
|
|
@@ -122,6 +128,7 @@ const snowflake_connection_2 = require("./snowflake_connection");
|
|
|
122
128
|
displayName: 'Schema Sample Row Limit',
|
|
123
129
|
type: 'number',
|
|
124
130
|
optional: true,
|
|
131
|
+
advanced: true,
|
|
125
132
|
default: 1000,
|
|
126
133
|
description: 'Row limit for the variant schema sample. Ignored for tables small enough to full-scan.',
|
|
127
134
|
},
|
|
@@ -130,6 +137,7 @@ const snowflake_connection_2 = require("./snowflake_connection");
|
|
|
130
137
|
displayName: 'Schema Full-Scan Max Bytes',
|
|
131
138
|
type: 'number',
|
|
132
139
|
optional: true,
|
|
140
|
+
advanced: true,
|
|
133
141
|
description: 'Tables with BYTES at or below this value are full-scanned during variant schema inference instead of sampled. When unset, the connection uses an internal threshold; picking a value here is a policy choice tied to the size-probe behavior.',
|
|
134
142
|
},
|
|
135
143
|
{
|
|
@@ -137,8 +145,33 @@ const snowflake_connection_2 = require("./snowflake_connection");
|
|
|
137
145
|
displayName: 'Setup SQL',
|
|
138
146
|
type: 'text',
|
|
139
147
|
optional: true,
|
|
148
|
+
advanced: true,
|
|
140
149
|
description: 'SQL statements to run when the connection is established',
|
|
141
150
|
},
|
|
151
|
+
{
|
|
152
|
+
name: 'poolMin',
|
|
153
|
+
displayName: 'Pool Min',
|
|
154
|
+
type: 'number',
|
|
155
|
+
optional: true,
|
|
156
|
+
advanced: true,
|
|
157
|
+
description: 'Minimum number of pooled snowflake-sdk connections kept warm. Defaults to 1.',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: 'poolMax',
|
|
161
|
+
displayName: 'Pool Max',
|
|
162
|
+
type: 'number',
|
|
163
|
+
optional: true,
|
|
164
|
+
advanced: true,
|
|
165
|
+
description: 'Maximum number of pooled snowflake-sdk connections. Defaults to 1.',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'poolTestOnBorrow',
|
|
169
|
+
displayName: 'Test On Borrow',
|
|
170
|
+
type: 'boolean',
|
|
171
|
+
optional: true,
|
|
172
|
+
advanced: true,
|
|
173
|
+
description: 'If true, the pool validates each connection when checked out. Defaults to true.',
|
|
174
|
+
},
|
|
142
175
|
],
|
|
143
176
|
});
|
|
144
177
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH,+DAA2D;AAAnD,2HAAA,mBAAmB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH,+DAA2D;AAAnD,2HAAA,mBAAmB,OAAA;AAC3B,mEAA0D;AAAlD,0HAAA,gBAAgB,OAAA;AAExB,+CAA0D;AAG1D,iEAA2D;AAC3D,qEAA0D;AAE1D,IAAA,+BAAsB,EAAC,WAAW,EAAE;IAClC,WAAW,EAAE,WAAW;IACxB,OAAO,EAAE,KAAK,EAAE,MAAwB,EAAE,EAAE;QAC1C,MAAM,EACJ,IAAI,EACJ,EAAE,EAAE,CAAC,EACL,QAAQ,EACR,SAAS,EACT,qBAAqB,EACrB,oBAAoB,EACpB,4BAA4B,EAC5B,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,GAAG,KAAK,EACT,GAAG,MAAM,CAAC;QACX,wEAAwE;QACxE,uEAAuE;QACvE,qEAAqE;QACrE,mEAAmE;QACnE,2BAA2B;QAC3B,MAAM,WAAW,GAAG,KAAqC,CAAC;QAC1D,OAAO,IAAI,0CAAmB,CAAC,IAAI,EAAE;YACnC,WAAW;YACX,QAAQ,EAAE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YAC7D,SAAS,EACP,OAAO,SAAS,KAAK,QAAQ;gBAC3B,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,OAAO,SAAS,KAAK,QAAQ;oBAC7B,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;oBACzB,CAAC,CAAC,SAAS;YACjB,qBAAqB,EACnB,OAAO,qBAAqB,KAAK,QAAQ;gBACvC,CAAC,CAAC,qBAAqB;gBACvB,CAAC,CAAC,OAAO,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;YACd,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,+OAA+O;SAClP;QACD;YACE,IAAI,EAAE,UAAU;YAChB,WAAW,EAAE,WAAW;YACxB,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,0DAA0D;SACxE;QACD;YACE,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,UAAU;YACvB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,8EAA8E;SACjF;QACD;YACE,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,UAAU;YACvB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,oEAAoE;SACvE;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,WAAW,EAAE,gBAAgB;YAC7B,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,iFAAiF;SACpF;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Options as PoolOptions } from 'generic-pool';
|
|
2
|
+
/** Assemble generic-pool options from the registry's pool fields; undefined when none supplied. */
|
|
3
|
+
export declare function buildPoolOptions(config: {
|
|
4
|
+
poolMin?: unknown;
|
|
5
|
+
poolMax?: unknown;
|
|
6
|
+
poolTestOnBorrow?: unknown;
|
|
7
|
+
}): PoolOptions | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Contributors to the Malloy project
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.buildPoolOptions = buildPoolOptions;
|
|
8
|
+
/** Assemble generic-pool options from the registry's pool fields; undefined when none supplied. */
|
|
9
|
+
function buildPoolOptions(config) {
|
|
10
|
+
const opts = {};
|
|
11
|
+
if (typeof config.poolMin === 'number')
|
|
12
|
+
opts.min = config.poolMin;
|
|
13
|
+
if (typeof config.poolMax === 'number')
|
|
14
|
+
opts.max = config.poolMax;
|
|
15
|
+
if (typeof config.poolTestOnBorrow === 'boolean') {
|
|
16
|
+
opts.testOnBorrow = config.poolTestOnBorrow;
|
|
17
|
+
}
|
|
18
|
+
return Object.keys(opts).length > 0 ? opts : undefined;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=snowflake_pool_options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snowflake_pool_options.js","sourceRoot":"","sources":["../src/snowflake_pool_options.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,4CAYC;AAbD,mGAAmG;AACnG,SAAgB,gBAAgB,CAAC,MAIhC;IACC,MAAM,IAAI,GAAgB,EAAE,CAAC;IAC7B,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;QAAE,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC;IAClE,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;QAAE,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC;IAClE,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACjD,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Contributors to the Malloy project
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const snowflake_pool_options_1 = require("./snowflake_pool_options");
|
|
8
|
+
describe('buildPoolOptions', () => {
|
|
9
|
+
it('returns undefined when no pool fields are supplied', () => {
|
|
10
|
+
expect((0, snowflake_pool_options_1.buildPoolOptions)({})).toBeUndefined();
|
|
11
|
+
});
|
|
12
|
+
it('forwards a single supplied field and leaves others absent', () => {
|
|
13
|
+
expect((0, snowflake_pool_options_1.buildPoolOptions)({ poolMax: 20 })).toEqual({ max: 20 });
|
|
14
|
+
});
|
|
15
|
+
it('forwards all three fields when supplied', () => {
|
|
16
|
+
expect((0, snowflake_pool_options_1.buildPoolOptions)({ poolMin: 2, poolMax: 20, poolTestOnBorrow: false })).toEqual({ min: 2, max: 20, testOnBorrow: false });
|
|
17
|
+
});
|
|
18
|
+
it('treats poolTestOnBorrow: false as a real value, not a default', () => {
|
|
19
|
+
// false is falsy; guard against a `||` regression that would drop it.
|
|
20
|
+
expect((0, snowflake_pool_options_1.buildPoolOptions)({ poolTestOnBorrow: false })).toEqual({
|
|
21
|
+
testOnBorrow: false,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
it('treats poolMin: 0 as a real value, not a default', () => {
|
|
25
|
+
// 0 is falsy; guard against a `||` regression that would drop it.
|
|
26
|
+
expect((0, snowflake_pool_options_1.buildPoolOptions)({ poolMin: 0 })).toEqual({ min: 0 });
|
|
27
|
+
});
|
|
28
|
+
it('drops fields with the wrong type rather than coercing them', () => {
|
|
29
|
+
expect((0, snowflake_pool_options_1.buildPoolOptions)({
|
|
30
|
+
poolMin: '2',
|
|
31
|
+
poolMax: null,
|
|
32
|
+
poolTestOnBorrow: 'yes',
|
|
33
|
+
})).toBeUndefined();
|
|
34
|
+
});
|
|
35
|
+
it('keeps valid fields when other fields are wrong-typed', () => {
|
|
36
|
+
expect((0, snowflake_pool_options_1.buildPoolOptions)({
|
|
37
|
+
poolMin: 2,
|
|
38
|
+
poolMax: 'oops',
|
|
39
|
+
})).toEqual({ min: 2 });
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=snowflake_pool_options.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snowflake_pool_options.spec.js","sourceRoot":"","sources":["../src/snowflake_pool_options.spec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,qEAA0D;AAE1D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,CAAC,IAAA,yCAAgB,EAAC,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,CAAC,IAAA,yCAAgB,EAAC,EAAC,OAAO,EAAE,EAAE,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,GAAG,EAAE,EAAE,EAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,CACJ,IAAA,yCAAgB,EAAC,EAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAC,CAAC,CACrE,CAAC,OAAO,CAAC,EAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,sEAAsE;QACtE,MAAM,CAAC,IAAA,yCAAgB,EAAC,EAAC,gBAAgB,EAAE,KAAK,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC1D,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,kEAAkE;QAClE,MAAM,CAAC,IAAA,yCAAgB,EAAC,EAAC,OAAO,EAAE,CAAC,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,GAAG,EAAE,CAAC,EAAC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,CACJ,IAAA,yCAAgB,EAAC;YACf,OAAO,EAAE,GAAG;YACZ,OAAO,EAAE,IAAI;YACb,gBAAgB,EAAE,KAAK;SACxB,CAAC,CACH,CAAC,aAAa,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,CACJ,IAAA,yCAAgB,EAAC;YACf,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,MAAM;SAChB,CAAC,CACH,CAAC,OAAO,CAAC,EAAC,GAAG,EAAE,CAAC,EAAC,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-snowflake",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.384",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"prepublishOnly": "npm run build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@malloydata/malloy": "0.0.
|
|
25
|
+
"@malloydata/malloy": "0.0.384",
|
|
26
26
|
"generic-pool": "^3.9.0",
|
|
27
27
|
"snowflake-sdk": "2.3.1",
|
|
28
28
|
"toml": "^3.0.0"
|
package/src/index.ts
CHANGED
|
@@ -22,11 +22,13 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
export {SnowflakeConnection} from './snowflake_connection';
|
|
25
|
+
export {buildPoolOptions} from './snowflake_pool_options';
|
|
25
26
|
|
|
26
27
|
import {registerConnectionType} from '@malloydata/malloy';
|
|
27
28
|
import type {ConnectionConfig} from '@malloydata/malloy';
|
|
28
29
|
import type {ConnectionOptions} from 'snowflake-sdk';
|
|
29
30
|
import {SnowflakeConnection} from './snowflake_connection';
|
|
31
|
+
import {buildPoolOptions} from './snowflake_pool_options';
|
|
30
32
|
|
|
31
33
|
registerConnectionType('snowflake', {
|
|
32
34
|
displayName: 'Snowflake',
|
|
@@ -39,6 +41,9 @@ registerConnectionType('snowflake', {
|
|
|
39
41
|
schemaSampleTimeoutMs,
|
|
40
42
|
schemaSampleRowLimit,
|
|
41
43
|
schemaSampleFullScanMaxBytes,
|
|
44
|
+
poolMin,
|
|
45
|
+
poolMax,
|
|
46
|
+
poolTestOnBorrow,
|
|
42
47
|
...props
|
|
43
48
|
} = config;
|
|
44
49
|
// ConnectionConfig values are trusted to match ConnectionOptions fields
|
|
@@ -74,6 +79,7 @@ registerConnectionType('snowflake', {
|
|
|
74
79
|
: typeof schemaSampleFullScanMaxBytes === 'string'
|
|
75
80
|
? parseInt(schemaSampleFullScanMaxBytes, 10)
|
|
76
81
|
: undefined,
|
|
82
|
+
poolOptions: buildPoolOptions({poolMin, poolMax, poolTestOnBorrow}),
|
|
77
83
|
});
|
|
78
84
|
},
|
|
79
85
|
properties: [
|
|
@@ -121,6 +127,7 @@ registerConnectionType('snowflake', {
|
|
|
121
127
|
displayName: 'Timeout (ms)',
|
|
122
128
|
type: 'number',
|
|
123
129
|
optional: true,
|
|
130
|
+
advanced: true,
|
|
124
131
|
default: 600000,
|
|
125
132
|
},
|
|
126
133
|
{
|
|
@@ -128,6 +135,7 @@ registerConnectionType('snowflake', {
|
|
|
128
135
|
displayName: 'Schema Sample Timeout (ms)',
|
|
129
136
|
type: 'number',
|
|
130
137
|
optional: true,
|
|
138
|
+
advanced: true,
|
|
131
139
|
default: 15000,
|
|
132
140
|
description:
|
|
133
141
|
'Timeout for the query that samples variant columns to detect their schema.',
|
|
@@ -137,6 +145,7 @@ registerConnectionType('snowflake', {
|
|
|
137
145
|
displayName: 'Schema Sample Row Limit',
|
|
138
146
|
type: 'number',
|
|
139
147
|
optional: true,
|
|
148
|
+
advanced: true,
|
|
140
149
|
default: 1000,
|
|
141
150
|
description:
|
|
142
151
|
'Row limit for the variant schema sample. Ignored for tables small enough to full-scan.',
|
|
@@ -146,6 +155,7 @@ registerConnectionType('snowflake', {
|
|
|
146
155
|
displayName: 'Schema Full-Scan Max Bytes',
|
|
147
156
|
type: 'number',
|
|
148
157
|
optional: true,
|
|
158
|
+
advanced: true,
|
|
149
159
|
description:
|
|
150
160
|
'Tables with BYTES at or below this value are full-scanned during variant schema inference instead of sampled. When unset, the connection uses an internal threshold; picking a value here is a policy choice tied to the size-probe behavior.',
|
|
151
161
|
},
|
|
@@ -154,7 +164,35 @@ registerConnectionType('snowflake', {
|
|
|
154
164
|
displayName: 'Setup SQL',
|
|
155
165
|
type: 'text',
|
|
156
166
|
optional: true,
|
|
167
|
+
advanced: true,
|
|
157
168
|
description: 'SQL statements to run when the connection is established',
|
|
158
169
|
},
|
|
170
|
+
{
|
|
171
|
+
name: 'poolMin',
|
|
172
|
+
displayName: 'Pool Min',
|
|
173
|
+
type: 'number',
|
|
174
|
+
optional: true,
|
|
175
|
+
advanced: true,
|
|
176
|
+
description:
|
|
177
|
+
'Minimum number of pooled snowflake-sdk connections kept warm. Defaults to 1.',
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'poolMax',
|
|
181
|
+
displayName: 'Pool Max',
|
|
182
|
+
type: 'number',
|
|
183
|
+
optional: true,
|
|
184
|
+
advanced: true,
|
|
185
|
+
description:
|
|
186
|
+
'Maximum number of pooled snowflake-sdk connections. Defaults to 1.',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'poolTestOnBorrow',
|
|
190
|
+
displayName: 'Test On Borrow',
|
|
191
|
+
type: 'boolean',
|
|
192
|
+
optional: true,
|
|
193
|
+
advanced: true,
|
|
194
|
+
description:
|
|
195
|
+
'If true, the pool validates each connection when checked out. Defaults to true.',
|
|
196
|
+
},
|
|
159
197
|
],
|
|
160
198
|
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Contributors to the Malloy project
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {buildPoolOptions} from './snowflake_pool_options';
|
|
7
|
+
|
|
8
|
+
describe('buildPoolOptions', () => {
|
|
9
|
+
it('returns undefined when no pool fields are supplied', () => {
|
|
10
|
+
expect(buildPoolOptions({})).toBeUndefined();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('forwards a single supplied field and leaves others absent', () => {
|
|
14
|
+
expect(buildPoolOptions({poolMax: 20})).toEqual({max: 20});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('forwards all three fields when supplied', () => {
|
|
18
|
+
expect(
|
|
19
|
+
buildPoolOptions({poolMin: 2, poolMax: 20, poolTestOnBorrow: false})
|
|
20
|
+
).toEqual({min: 2, max: 20, testOnBorrow: false});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('treats poolTestOnBorrow: false as a real value, not a default', () => {
|
|
24
|
+
// false is falsy; guard against a `||` regression that would drop it.
|
|
25
|
+
expect(buildPoolOptions({poolTestOnBorrow: false})).toEqual({
|
|
26
|
+
testOnBorrow: false,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('treats poolMin: 0 as a real value, not a default', () => {
|
|
31
|
+
// 0 is falsy; guard against a `||` regression that would drop it.
|
|
32
|
+
expect(buildPoolOptions({poolMin: 0})).toEqual({min: 0});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('drops fields with the wrong type rather than coercing them', () => {
|
|
36
|
+
expect(
|
|
37
|
+
buildPoolOptions({
|
|
38
|
+
poolMin: '2',
|
|
39
|
+
poolMax: null,
|
|
40
|
+
poolTestOnBorrow: 'yes',
|
|
41
|
+
})
|
|
42
|
+
).toBeUndefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('keeps valid fields when other fields are wrong-typed', () => {
|
|
46
|
+
expect(
|
|
47
|
+
buildPoolOptions({
|
|
48
|
+
poolMin: 2,
|
|
49
|
+
poolMax: 'oops',
|
|
50
|
+
})
|
|
51
|
+
).toEqual({min: 2});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Contributors to the Malloy project
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {Options as PoolOptions} from 'generic-pool';
|
|
7
|
+
|
|
8
|
+
/** Assemble generic-pool options from the registry's pool fields; undefined when none supplied. */
|
|
9
|
+
export function buildPoolOptions(config: {
|
|
10
|
+
poolMin?: unknown;
|
|
11
|
+
poolMax?: unknown;
|
|
12
|
+
poolTestOnBorrow?: unknown;
|
|
13
|
+
}): PoolOptions | undefined {
|
|
14
|
+
const opts: PoolOptions = {};
|
|
15
|
+
if (typeof config.poolMin === 'number') opts.min = config.poolMin;
|
|
16
|
+
if (typeof config.poolMax === 'number') opts.max = config.poolMax;
|
|
17
|
+
if (typeof config.poolTestOnBorrow === 'boolean') {
|
|
18
|
+
opts.testOnBorrow = config.poolTestOnBorrow;
|
|
19
|
+
}
|
|
20
|
+
return Object.keys(opts).length > 0 ? opts : undefined;
|
|
21
|
+
}
|