@malloydata/malloy-tests 0.0.105-dev231127184813 → 0.0.105-dev231127225419

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const runtimes_1 = require("../runtimes");
26
+ const render_1 = require("@malloydata/render");
27
+ const duckdb = (0, runtimes_1.runtimeFor)('duckdb');
28
+ describe('drill query', () => {
29
+ const model = `
30
+ source: carriers is duckdb.table('test/data/duckdb/carriers.parquet') extend {
31
+ primary_key: code
32
+ measure: carrier_count is count()
33
+ }
34
+ source: flights is duckdb.table('test/data/duckdb/flights/part.*.parquet') extend {
35
+ primary_key: id2
36
+ // rename some fields as from their physical names
37
+ rename: \`Origin Code\` is origin
38
+ measure: flight_count is count()
39
+ join_one: carriers with carrier
40
+
41
+ view: top_carriers is {
42
+ group_by: carriers.nickname
43
+ aggregate:
44
+ flight_count
45
+ limit: 1
46
+ }
47
+
48
+ view: over_time is {
49
+ group_by: dep_month is month(dep_time)
50
+ aggregate: flight_count
51
+ limit: 1
52
+ }
53
+
54
+ view: by_origin is {
55
+ group_by: \`Origin Code\`
56
+ aggregate: flight_count
57
+ limit: 1
58
+ }
59
+ }
60
+ query: top_carriers is flights -> top_carriers
61
+ query: over_time is flights -> over_time
62
+ query: by_origin is flights -> by_origin
63
+ `;
64
+ test('can handle joined-in table fields', async () => {
65
+ const result = duckdb
66
+ .loadModel(model)
67
+ .loadQueryByName('top_carriers')
68
+ .run();
69
+ const table = (await result).data;
70
+ const expDrillQuery = 'run: flights -> { \n' +
71
+ ' where: \n' +
72
+ " carriers.nickname = 'Southwest'\n" +
73
+ ' \n' +
74
+ '} + {select: *}\n';
75
+ const row = table.row(0);
76
+ expect((0, render_1.getDrillQuery)(row).drillQuery).toEqual(expDrillQuery);
77
+ });
78
+ test('can handle expression fields', async () => {
79
+ const result = duckdb.loadModel(model).loadQueryByName('over_time').run();
80
+ const table = (await result).data;
81
+ const expDrillQuery = 'run: flights -> { \n where: \n ' +
82
+ 'dep_month = 8\n \n} + {select: *}\n';
83
+ const row = table.row(0);
84
+ expect((0, render_1.getDrillQuery)(row).drillQuery).toEqual(expDrillQuery);
85
+ });
86
+ test('can handle renamed and multi-word field names', async () => {
87
+ const result = duckdb.loadModel(model).loadQueryByName('by_origin').run();
88
+ const table = (await result).data;
89
+ const expDrillQuery = 'run: flights -> { \n where: \n ' +
90
+ "`Origin Code` = 'ATL'\n \n} + {select: *}\n";
91
+ const row = table.row(0);
92
+ expect((0, render_1.getDrillQuery)(row).drillQuery).toEqual(expDrillQuery);
93
+ });
94
+ });
95
+ //# sourceMappingURL=drill.spec.js.map
@@ -0,0 +1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EAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1E,MAAM,KAAK,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC;QAClC,MAAM,aAAa,GACjB,qCAAqC;YACrC,8CAA8C,CAAC;QACjD,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,IAAA,sBAAa,EAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@jest/globals": "^29.4.3",
21
- "@malloydata/db-bigquery": "^0.0.105-dev231127184813",
22
- "@malloydata/db-duckdb": "^0.0.105-dev231127184813",
23
- "@malloydata/db-postgres": "^0.0.105-dev231127184813",
24
- "@malloydata/malloy": "^0.0.105-dev231127184813",
25
- "@malloydata/render": "^0.0.105-dev231127184813",
21
+ "@malloydata/db-bigquery": "^0.0.105-dev231127225419",
22
+ "@malloydata/db-duckdb": "^0.0.105-dev231127225419",
23
+ "@malloydata/db-postgres": "^0.0.105-dev231127225419",
24
+ "@malloydata/malloy": "^0.0.105-dev231127225419",
25
+ "@malloydata/render": "^0.0.105-dev231127225419",
26
26
  "jsdom": "^22.1.0",
27
27
  "luxon": "^2.4.0",
28
28
  "madge": "^6.0.0"
@@ -31,5 +31,5 @@
31
31
  "@types/jsdom": "^21.1.1",
32
32
  "@types/luxon": "^2.4.0"
33
33
  },
34
- "version": "0.0.105-dev231127184813"
34
+ "version": "0.0.105-dev231127225419"
35
35
  }
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining
5
+ * a copy of this software and associated documentation files
6
+ * (the "Software"), to deal in the Software without restriction,
7
+ * including without limitation the rights to use, copy, modify, merge,
8
+ * publish, distribute, sublicense, and/or sell copies of the Software,
9
+ * and to permit persons to whom the Software is furnished to do so,
10
+ * subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be
13
+ * included in all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ import {runtimeFor} from '../runtimes';
25
+ import {getDrillQuery} from '@malloydata/render';
26
+
27
+ const duckdb = runtimeFor('duckdb');
28
+
29
+ describe('drill query', () => {
30
+ const model = `
31
+ source: carriers is duckdb.table('test/data/duckdb/carriers.parquet') extend {
32
+ primary_key: code
33
+ measure: carrier_count is count()
34
+ }
35
+ source: flights is duckdb.table('test/data/duckdb/flights/part.*.parquet') extend {
36
+ primary_key: id2
37
+ // rename some fields as from their physical names
38
+ rename: \`Origin Code\` is origin
39
+ measure: flight_count is count()
40
+ join_one: carriers with carrier
41
+
42
+ view: top_carriers is {
43
+ group_by: carriers.nickname
44
+ aggregate:
45
+ flight_count
46
+ limit: 1
47
+ }
48
+
49
+ view: over_time is {
50
+ group_by: dep_month is month(dep_time)
51
+ aggregate: flight_count
52
+ limit: 1
53
+ }
54
+
55
+ view: by_origin is {
56
+ group_by: \`Origin Code\`
57
+ aggregate: flight_count
58
+ limit: 1
59
+ }
60
+ }
61
+ query: top_carriers is flights -> top_carriers
62
+ query: over_time is flights -> over_time
63
+ query: by_origin is flights -> by_origin
64
+ `;
65
+ test('can handle joined-in table fields', async () => {
66
+ const result = duckdb
67
+ .loadModel(model)
68
+ .loadQueryByName('top_carriers')
69
+ .run();
70
+ const table = (await result).data;
71
+ const expDrillQuery =
72
+ 'run: flights -> { \n' +
73
+ ' where: \n' +
74
+ " carriers.nickname = 'Southwest'\n" +
75
+ ' \n' +
76
+ '} + {select: *}\n';
77
+ const row = table.row(0);
78
+ expect(getDrillQuery(row).drillQuery).toEqual(expDrillQuery);
79
+ });
80
+
81
+ test('can handle expression fields', async () => {
82
+ const result = duckdb.loadModel(model).loadQueryByName('over_time').run();
83
+ const table = (await result).data;
84
+ const expDrillQuery =
85
+ 'run: flights -> { \n where: \n ' +
86
+ 'dep_month = 8\n \n} + {select: *}\n';
87
+ const row = table.row(0);
88
+ expect(getDrillQuery(row).drillQuery).toEqual(expDrillQuery);
89
+ });
90
+
91
+ test('can handle renamed and multi-word field names', async () => {
92
+ const result = duckdb.loadModel(model).loadQueryByName('by_origin').run();
93
+ const table = (await result).data;
94
+ const expDrillQuery =
95
+ 'run: flights -> { \n where: \n ' +
96
+ "`Origin Code` = 'ATL'\n \n} + {select: *}\n";
97
+ const row = table.row(0);
98
+ expect(getDrillQuery(row).drillQuery).toEqual(expDrillQuery);
99
+ });
100
+ });