@malloydata/malloy-tests 0.0.225-dev250102225314 → 0.0.225-dev250106171109
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/config/core.config.json +8 -0
- package/package.json +8 -8
- package/src/{api.spec.ts → core/api.spec.ts} +2 -2
- package/src/{events.spec.ts → core/events.spec.ts} +2 -2
- package/src/{experimental-dialects.spec.ts → core/experimental-dialects.spec.ts} +2 -2
- package/src/{jestMatcher.spec.ts → core/jestMatcher.spec.ts} +2 -2
- package/src/{databases/multi-connection → core}/multi_connection.spec.ts +2 -2
- package/src/{databases/streaming → core}/streaming.spec.ts +2 -2
- package/src/{tags.spec.ts → core/tags.spec.ts} +1 -1
- package/src/databases/bigquery/malloy_query.spec.ts +1 -10
- package/src/databases/duckdb/nested_source_table.spec.ts +226 -0
- /package/src/{dependencies.spec.ts → core/dependencies.spec.ts} +0 -0
- /package/src/{model → core}/sql_source.spec.ts +0 -0
- /package/src/databases/{bigquery-duckdb → bigquery}/nested_source_table.spec.ts +0 -0
- /package/src/databases/{duckdb → duckdb-all}/duckdb.spec.ts +0 -0
- /package/src/databases/{duckdb → duckdb-all}/materialization.spec.ts +0 -0
package/package.json
CHANGED
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@jest/globals": "^29.4.3",
|
|
24
|
-
"@malloydata/db-bigquery": "^0.0.225-
|
|
25
|
-
"@malloydata/db-duckdb": "^0.0.225-
|
|
26
|
-
"@malloydata/db-postgres": "^0.0.225-
|
|
27
|
-
"@malloydata/db-snowflake": "^0.0.225-
|
|
28
|
-
"@malloydata/db-trino": "^0.0.225-
|
|
29
|
-
"@malloydata/malloy": "^0.0.225-
|
|
30
|
-
"@malloydata/render": "^0.0.225-
|
|
24
|
+
"@malloydata/db-bigquery": "^0.0.225-dev250106171109",
|
|
25
|
+
"@malloydata/db-duckdb": "^0.0.225-dev250106171109",
|
|
26
|
+
"@malloydata/db-postgres": "^0.0.225-dev250106171109",
|
|
27
|
+
"@malloydata/db-snowflake": "^0.0.225-dev250106171109",
|
|
28
|
+
"@malloydata/db-trino": "^0.0.225-dev250106171109",
|
|
29
|
+
"@malloydata/malloy": "^0.0.225-dev250106171109",
|
|
30
|
+
"@malloydata/render": "^0.0.225-dev250106171109",
|
|
31
31
|
"events": "^3.3.0",
|
|
32
32
|
"jsdom": "^22.1.0",
|
|
33
33
|
"luxon": "^2.4.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"@types/jsdom": "^21.1.1",
|
|
38
38
|
"@types/luxon": "^2.4.0"
|
|
39
39
|
},
|
|
40
|
-
"version": "0.0.225-
|
|
40
|
+
"version": "0.0.225-dev250106171109"
|
|
41
41
|
}
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import {runtimeFor} from '
|
|
26
|
-
import '
|
|
25
|
+
import {runtimeFor} from '../runtimes';
|
|
26
|
+
import '../util/db-jest-matchers';
|
|
27
27
|
|
|
28
28
|
const runtime = runtimeFor('duckdb');
|
|
29
29
|
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {runtimeFor} from '
|
|
9
|
-
import '
|
|
8
|
+
import {runtimeFor} from '../runtimes';
|
|
9
|
+
import '../util/db-jest-matchers';
|
|
10
10
|
|
|
11
11
|
const runtime = runtimeFor('duckdb');
|
|
12
12
|
|
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
SQLSourceDef,
|
|
29
29
|
registerDialect,
|
|
30
30
|
} from '@malloydata/malloy';
|
|
31
|
-
import {testRuntimeFor} from '
|
|
32
|
-
import '
|
|
31
|
+
import {testRuntimeFor} from '../runtimes';
|
|
32
|
+
import '../util/db-jest-matchers';
|
|
33
33
|
import {DuckDBConnection} from '@malloydata/db-duckdb';
|
|
34
34
|
|
|
35
35
|
const envDatabases = (
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import {runtimeFor} from '
|
|
26
|
-
import '
|
|
25
|
+
import {runtimeFor} from '../runtimes';
|
|
26
|
+
import '../util/db-jest-matchers';
|
|
27
27
|
|
|
28
28
|
const runtime = runtimeFor('duckdb');
|
|
29
29
|
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
|
|
27
27
|
import * as malloy from '@malloydata/malloy';
|
|
28
28
|
import {EmptyURLReader} from '@malloydata/malloy';
|
|
29
|
-
import {DuckDBTestConnection, PostgresTestConnection} from '
|
|
30
|
-
import {describeIfDatabaseAvailable} from '
|
|
29
|
+
import {DuckDBTestConnection, PostgresTestConnection} from '../runtimes';
|
|
30
|
+
import {describeIfDatabaseAvailable} from '../util';
|
|
31
31
|
|
|
32
32
|
const [, databases] = describeIfDatabaseAvailable(['duckdb', 'postgres']);
|
|
33
33
|
|
|
@@ -27,8 +27,8 @@ import {
|
|
|
27
27
|
JSONWriter,
|
|
28
28
|
WriteStream,
|
|
29
29
|
} from '@malloydata/malloy';
|
|
30
|
-
import {RuntimeList} from '
|
|
31
|
-
import {describeIfDatabaseAvailable} from '
|
|
30
|
+
import {RuntimeList} from '../runtimes';
|
|
31
|
+
import {describeIfDatabaseAvailable} from '../util';
|
|
32
32
|
|
|
33
33
|
class StringAccumulator implements WriteStream {
|
|
34
34
|
public accumulatedValue = '';
|
|
@@ -32,7 +32,7 @@ import '../../util/db-jest-matchers';
|
|
|
32
32
|
const runtimeList = new RuntimeList(['bigquery']);
|
|
33
33
|
const runtime = runtimeList.runtimeMap.get('bigquery');
|
|
34
34
|
if (runtime === undefined) {
|
|
35
|
-
throw new Error(
|
|
35
|
+
throw new Error('BigQuery runtime not found');
|
|
36
36
|
}
|
|
37
37
|
const bq = runtime.connection as BigQueryTestConnection;
|
|
38
38
|
|
|
@@ -750,15 +750,6 @@ describe('airport_tests', () => {
|
|
|
750
750
|
`).malloyResultMatches(model, {'pipe_turtle.total_airports': 1845});
|
|
751
751
|
});
|
|
752
752
|
|
|
753
|
-
it(`hyperloglog combine`, async () => {
|
|
754
|
-
await expect(`run: bigquery.table('malloytest.airports')->{
|
|
755
|
-
aggregate: code_hll is hll_accumulate(code)
|
|
756
|
-
} -> {
|
|
757
|
-
aggregate: code_count is hll_estimate(hll_combine(code_hll))
|
|
758
|
-
}
|
|
759
|
-
`).malloyResultMatches(runtime, {code_count: 19799});
|
|
760
|
-
});
|
|
761
|
-
|
|
762
753
|
it.skip('crossjoined turtles', async () => {
|
|
763
754
|
// const result = await runQuery(model,`
|
|
764
755
|
// explore airports
|
|
@@ -0,0 +1,226 @@
|
|
|
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
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
/* eslint-disable no-console */
|
|
26
|
+
|
|
27
|
+
import '../../util/db-jest-matchers';
|
|
28
|
+
import {RuntimeList} from '../../runtimes';
|
|
29
|
+
import {describeIfDatabaseAvailable} from '../../util';
|
|
30
|
+
|
|
31
|
+
// No prebuilt shared model, each test is complete. Makes debugging easier.
|
|
32
|
+
|
|
33
|
+
const [describe, databases] = describeIfDatabaseAvailable([
|
|
34
|
+
'bigquery',
|
|
35
|
+
'duckdb',
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
function modelText(databaseName: string) {
|
|
39
|
+
return `
|
|
40
|
+
source: ga_sessions is ${databaseName}.table('malloytest.ga_sample') extend {
|
|
41
|
+
|
|
42
|
+
measure:
|
|
43
|
+
user_count is count(fullVisitorId)
|
|
44
|
+
session_count is count()
|
|
45
|
+
total_visits is totals.visits.sum()
|
|
46
|
+
total_hits is totals.hits.sum()
|
|
47
|
+
total_page_views is totals.pageviews.sum()
|
|
48
|
+
t2 is totals.pageviews.sum()
|
|
49
|
+
total_productRevenue is hits.product.productRevenue.sum()
|
|
50
|
+
hits_count is hits.count()
|
|
51
|
+
sold_count is hits.count() { where: hits.product.productQuantity > 0 }
|
|
52
|
+
|
|
53
|
+
view: by_source is {
|
|
54
|
+
where: trafficSource.\`source\` != '(direct)'
|
|
55
|
+
group_by: trafficSource.\`source\`
|
|
56
|
+
aggregate: hits_count
|
|
57
|
+
limit: 10
|
|
58
|
+
}
|
|
59
|
+
view: by_adContent_bar_chart is {
|
|
60
|
+
group_by: device.browser
|
|
61
|
+
aggregate: user_count
|
|
62
|
+
group_by: device.deviceCategory
|
|
63
|
+
}
|
|
64
|
+
view: by_region is {
|
|
65
|
+
where: geoNetwork.region !~ '%demo%'
|
|
66
|
+
group_by: geoNetwork.region
|
|
67
|
+
aggregate: user_count
|
|
68
|
+
limit: 10
|
|
69
|
+
}
|
|
70
|
+
view: by_device is {
|
|
71
|
+
group_by: device.browser
|
|
72
|
+
aggregate: user_count
|
|
73
|
+
group_by: device.deviceCategory
|
|
74
|
+
}
|
|
75
|
+
view: by_category is {
|
|
76
|
+
group_by: category is hits.product.v2ProductCategory
|
|
77
|
+
aggregate: total_productRevenue
|
|
78
|
+
aggregate: sold_count
|
|
79
|
+
limit: 10
|
|
80
|
+
}
|
|
81
|
+
view: by_hour_of_day is {
|
|
82
|
+
// group_by: gsession_hour is hour(start_time::timestamp)
|
|
83
|
+
aggregate: session_count
|
|
84
|
+
order_by: 1
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
view: page_load_times is {
|
|
88
|
+
group_by: hits.page.pageTitle
|
|
89
|
+
aggregate: hit_count is hits.count()
|
|
90
|
+
nest: load_bar_chart is {
|
|
91
|
+
group_by: hit_seconds is floor(hits.latencyTracking.pageLoadTime / 2) * 2
|
|
92
|
+
aggregate: hits_count
|
|
93
|
+
}
|
|
94
|
+
limit: 10
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
view: by_page_title is { where: totals.transactionRevenue > 0
|
|
98
|
+
group_by: hits.page.pageTitle
|
|
99
|
+
aggregate: hits_count
|
|
100
|
+
aggregate: sold_count
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
view: by_all is {
|
|
104
|
+
nest: by_source
|
|
105
|
+
nest: by_adContent_bar_chart
|
|
106
|
+
nest: by_region
|
|
107
|
+
nest: by_category
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
view: search_index is {
|
|
111
|
+
index: *, hits.*, customDimensions.* totals.*, trafficSource.*, hits.product.*
|
|
112
|
+
sample: 1%
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
query: sessions_dashboard is ga_sessions -> {
|
|
117
|
+
nest:
|
|
118
|
+
by_region
|
|
119
|
+
by_device
|
|
120
|
+
by_source
|
|
121
|
+
by_category is {
|
|
122
|
+
group_by: category is hits.product.v2ProductCategory
|
|
123
|
+
aggregate: total_productRevenue
|
|
124
|
+
aggregate: sold_count
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const runtimes = new RuntimeList(databases);
|
|
131
|
+
describe.each(runtimes.runtimeList)(
|
|
132
|
+
'Nested Source Table - %s',
|
|
133
|
+
(databaseName, runtime) => {
|
|
134
|
+
const gaModel = runtime.loadModel(modelText(databaseName));
|
|
135
|
+
test(`repeated child of record - ${databaseName}`, async () => {
|
|
136
|
+
await expect('run: ga_sessions->by_page_title').malloyResultMatches(
|
|
137
|
+
gaModel,
|
|
138
|
+
{pageTitle: 'Shopping Cart'}
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Tests intermittently fail and lloyd said
|
|
143
|
+
// "I bet it has to do with my sampling test on indexing. Intermittently
|
|
144
|
+
// getting different results. I'd comment out the test and I'll take a
|
|
145
|
+
// look at it when I get back." and that seems reasonable.
|
|
146
|
+
// "search_index" is the test that failed, but a skipped both
|
|
147
|
+
// this one and "manual index". Here's the errror:
|
|
148
|
+
// * Nested Source Table › search_index - duckdb
|
|
149
|
+
//
|
|
150
|
+
// expect(received).toBe(expected) // Object.is equality
|
|
151
|
+
//
|
|
152
|
+
// Expected: "Organic Search"
|
|
153
|
+
// Received: "Referral"
|
|
154
|
+
test(`search_index - ${databaseName}`, async () => {
|
|
155
|
+
await expect(`
|
|
156
|
+
run: ga_sessions->search_index -> {
|
|
157
|
+
where: fieldName != null
|
|
158
|
+
select: *
|
|
159
|
+
order_by: fieldName, weight desc
|
|
160
|
+
limit: 10
|
|
161
|
+
}
|
|
162
|
+
`).malloyResultMatches(gaModel, {
|
|
163
|
+
// fieldName: 'channelGrouping',
|
|
164
|
+
// fieldValue: 'Organic Search',
|
|
165
|
+
// weight: 10,
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test(`manual index - ${databaseName}`, async () => {
|
|
170
|
+
let sampleSize = '10';
|
|
171
|
+
if (databaseName === 'bigquery') {
|
|
172
|
+
sampleSize = 'false';
|
|
173
|
+
}
|
|
174
|
+
await expect(`
|
|
175
|
+
run: ${databaseName}.table('malloytest.ga_sample')-> {
|
|
176
|
+
index: *
|
|
177
|
+
sample: ${sampleSize}
|
|
178
|
+
}
|
|
179
|
+
-> {
|
|
180
|
+
aggregate: field_count is count(fieldName)
|
|
181
|
+
nest: top_fields is {
|
|
182
|
+
group_by: fieldName
|
|
183
|
+
aggregate: row_count is count()
|
|
184
|
+
limit: 100
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
`).malloyResultMatches(runtime, {
|
|
188
|
+
// 'top_fields.fieldName': 'channelGrouping',
|
|
189
|
+
// 'top_fields.fieldValue': 'Organic Search',
|
|
190
|
+
// 'top_fields.weight': 18,
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test(`autobin - ${databaseName}`, async () => {
|
|
195
|
+
await expect(`
|
|
196
|
+
source: airports is ${databaseName}.table('malloytest.airports') extend {
|
|
197
|
+
measure: airport_count is count()
|
|
198
|
+
view: by_elevation is {
|
|
199
|
+
aggregate: bin_size is NULLIF((max(elevation) - min(elevation))/30,0)
|
|
200
|
+
nest: data is {
|
|
201
|
+
group_by: elevation
|
|
202
|
+
aggregate: row_count is count()
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
-> {
|
|
206
|
+
group_by: elevation is floor(data.elevation/bin_size)*bin_size + bin_size/2
|
|
207
|
+
aggregate: airport_count is data.row_count.sum()
|
|
208
|
+
order_by: elevation
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
run: airports -> {
|
|
213
|
+
group_by: state is state
|
|
214
|
+
aggregate: airport_count
|
|
215
|
+
nest: by_elevation_bar_chart is by_elevation
|
|
216
|
+
}
|
|
217
|
+
`).malloyResultMatches(runtime, {
|
|
218
|
+
// don't know what to expect ...
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
afterAll(async () => {
|
|
225
|
+
await runtimes.closeAll();
|
|
226
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|