@malloydata/db-snowflake 0.0.327 → 0.0.328
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.
|
@@ -59,31 +59,15 @@ const malloy = __importStar(require("@malloydata/malloy"));
|
|
|
59
59
|
const test_1 = require("@malloydata/malloy/test");
|
|
60
60
|
require("@malloydata/malloy/test/matchers");
|
|
61
61
|
const snowflake_connection_1 = require("./snowflake_connection");
|
|
62
|
-
const url_1 = require("url");
|
|
63
|
-
const util = __importStar(require("util"));
|
|
64
|
-
const fs = __importStar(require("fs"));
|
|
65
62
|
const snowflake_executor_1 = require("./snowflake_executor");
|
|
66
63
|
describe('db:Snowflake', () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
conn = new snowflake_connection_1.SnowflakeConnection('snowflake', {
|
|
73
|
-
connOptions: connOptions,
|
|
74
|
-
queryOptions: { rowLimit: 1000 },
|
|
75
|
-
});
|
|
76
|
-
const files = {
|
|
77
|
-
readURL: async (url) => {
|
|
78
|
-
const filePath = (0, url_1.fileURLToPath)(url);
|
|
79
|
-
return await util.promisify(fs.readFile)(filePath, 'utf8');
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
runtime = new malloy.Runtime({
|
|
83
|
-
urlReader: files,
|
|
84
|
-
connection: conn,
|
|
85
|
-
});
|
|
64
|
+
const connOptions = snowflake_executor_1.SnowflakeExecutor.getConnectionOptionsFromEnv() ||
|
|
65
|
+
snowflake_executor_1.SnowflakeExecutor.getConnectionOptionsFromToml();
|
|
66
|
+
const conn = new snowflake_connection_1.SnowflakeConnection('snowflake', {
|
|
67
|
+
connOptions: connOptions,
|
|
68
|
+
queryOptions: { rowLimit: 1000 },
|
|
86
69
|
});
|
|
70
|
+
const runtime = (0, test_1.createTestRuntime)(conn);
|
|
87
71
|
afterAll(async () => {
|
|
88
72
|
await conn.close();
|
|
89
73
|
});
|
|
@@ -191,15 +175,12 @@ describe('db:Snowflake', () => {
|
|
|
191
175
|
describe('numeric value reading', () => {
|
|
192
176
|
const connOptions = snowflake_executor_1.SnowflakeExecutor.getConnectionOptionsFromEnv() ||
|
|
193
177
|
snowflake_executor_1.SnowflakeExecutor.getConnectionOptionsFromToml();
|
|
194
|
-
const connection = new snowflake_connection_1.SnowflakeConnection('
|
|
178
|
+
const connection = new snowflake_connection_1.SnowflakeConnection('snowflake_numeric_tests', {
|
|
195
179
|
connOptions: connOptions,
|
|
196
180
|
queryOptions: { rowLimit: 1000 },
|
|
197
181
|
});
|
|
198
|
-
const runtime =
|
|
199
|
-
|
|
200
|
-
connection,
|
|
201
|
-
});
|
|
202
|
-
const testModel = (0, test_1.wrapTestModel)(runtime, '');
|
|
182
|
+
const runtime = (0, test_1.createTestRuntime)(connection);
|
|
183
|
+
const testModel = (0, test_1.mkTestModel)(runtime, {});
|
|
203
184
|
afterAll(async () => {
|
|
204
185
|
await connection.close();
|
|
205
186
|
});
|
|
@@ -207,6 +188,12 @@ describe('numeric value reading', () => {
|
|
|
207
188
|
it.each(['INTEGER', 'BIGINT', 'NUMBER(38,0)'])('reads %s correctly', async (sqlType) => {
|
|
208
189
|
await expect(`run: snowflake.sql("SELECT 10::${sqlType} as d")`).toMatchResult(testModel, { D: 10 });
|
|
209
190
|
});
|
|
191
|
+
it('preserves precision for literal integers > 2^53', async () => {
|
|
192
|
+
const largeInt = BigInt('9007199254740993'); // 2^53 + 1
|
|
193
|
+
await expect(`
|
|
194
|
+
run: snowflake.sql("select 1 as n") -> { select: d is ${largeInt} }
|
|
195
|
+
`).toMatchResult(testModel, { d: largeInt });
|
|
196
|
+
});
|
|
210
197
|
});
|
|
211
198
|
describe('float types', () => {
|
|
212
199
|
it.each(['FLOAT', 'DOUBLE', 'NUMBER(10,2)'])('reads %s correctly', async (sqlType) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snowflake_connection.spec.js","sourceRoot":"","sources":["../src/snowflake_connection.spec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,EAAC,EAAE;YACd,MAAM,MAAM,CACV,oCAAoC,OAAO,SAAS,CACrD,CAAC,aAAa,CAAC,SAAS,EAAE,EAAC,CAAC,EAAE,IAAI,EAAC,CAAC,CAAC;QACxC,CAAC,CACF,CAAC;IACJ,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.328",
|
|
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.328",
|
|
26
26
|
"generic-pool": "^3.9.0",
|
|
27
27
|
"snowflake-sdk": "2.3.1",
|
|
28
28
|
"toml": "^3.0.0"
|
|
@@ -22,37 +22,20 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import * as malloy from '@malloydata/malloy';
|
|
25
|
-
import {
|
|
25
|
+
import {createTestRuntime, mkTestModel} from '@malloydata/malloy/test';
|
|
26
26
|
import '@malloydata/malloy/test/matchers';
|
|
27
27
|
import {SnowflakeConnection} from './snowflake_connection';
|
|
28
|
-
import {fileURLToPath} from 'url';
|
|
29
|
-
import * as util from 'util';
|
|
30
|
-
import * as fs from 'fs';
|
|
31
28
|
import {SnowflakeExecutor} from './snowflake_executor';
|
|
32
29
|
|
|
33
30
|
describe('db:Snowflake', () => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
SnowflakeExecutor.getConnectionOptionsFromToml();
|
|
41
|
-
conn = new SnowflakeConnection('snowflake', {
|
|
42
|
-
connOptions: connOptions,
|
|
43
|
-
queryOptions: {rowLimit: 1000},
|
|
44
|
-
});
|
|
45
|
-
const files = {
|
|
46
|
-
readURL: async (url: URL) => {
|
|
47
|
-
const filePath = fileURLToPath(url);
|
|
48
|
-
return await util.promisify(fs.readFile)(filePath, 'utf8');
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
runtime = new malloy.Runtime({
|
|
52
|
-
urlReader: files,
|
|
53
|
-
connection: conn,
|
|
54
|
-
});
|
|
31
|
+
const connOptions =
|
|
32
|
+
SnowflakeExecutor.getConnectionOptionsFromEnv() ||
|
|
33
|
+
SnowflakeExecutor.getConnectionOptionsFromToml();
|
|
34
|
+
const conn = new SnowflakeConnection('snowflake', {
|
|
35
|
+
connOptions: connOptions,
|
|
36
|
+
queryOptions: {rowLimit: 1000},
|
|
55
37
|
});
|
|
38
|
+
const runtime = createTestRuntime(conn);
|
|
56
39
|
|
|
57
40
|
afterAll(async () => {
|
|
58
41
|
await conn.close();
|
|
@@ -174,15 +157,12 @@ describe('numeric value reading', () => {
|
|
|
174
157
|
const connOptions =
|
|
175
158
|
SnowflakeExecutor.getConnectionOptionsFromEnv() ||
|
|
176
159
|
SnowflakeExecutor.getConnectionOptionsFromToml();
|
|
177
|
-
const connection = new SnowflakeConnection('
|
|
160
|
+
const connection = new SnowflakeConnection('snowflake_numeric_tests', {
|
|
178
161
|
connOptions: connOptions,
|
|
179
162
|
queryOptions: {rowLimit: 1000},
|
|
180
163
|
});
|
|
181
|
-
const runtime =
|
|
182
|
-
|
|
183
|
-
connection,
|
|
184
|
-
});
|
|
185
|
-
const testModel = wrapTestModel(runtime, '');
|
|
164
|
+
const runtime = createTestRuntime(connection);
|
|
165
|
+
const testModel = mkTestModel(runtime, {});
|
|
186
166
|
|
|
187
167
|
afterAll(async () => {
|
|
188
168
|
await connection.close();
|
|
@@ -197,6 +177,13 @@ describe('numeric value reading', () => {
|
|
|
197
177
|
).toMatchResult(testModel, {D: 10});
|
|
198
178
|
}
|
|
199
179
|
);
|
|
180
|
+
|
|
181
|
+
it('preserves precision for literal integers > 2^53', async () => {
|
|
182
|
+
const largeInt = BigInt('9007199254740993'); // 2^53 + 1
|
|
183
|
+
await expect(`
|
|
184
|
+
run: snowflake.sql("select 1 as n") -> { select: d is ${largeInt} }
|
|
185
|
+
`).toMatchResult(testModel, {d: largeInt});
|
|
186
|
+
});
|
|
200
187
|
});
|
|
201
188
|
|
|
202
189
|
describe('float types', () => {
|