@malloydata/malloy-tests 0.0.66-dev230807232724
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/README.md +29 -0
- package/bin/dump_malloytest.sh +1 -0
- package/bin/postgres_init.sh +9 -0
- package/bin/postgres_start.sh +2 -0
- package/bin/postgres_stop.sh +2 -0
- package/data/duckdb/README.md +4 -0
- package/data/duckdb/aircraft.parquet +0 -0
- package/data/duckdb/aircraft_models.parquet +0 -0
- package/data/duckdb/airports.parquet +0 -0
- package/data/duckdb/alltypes.parquet +0 -0
- package/data/duckdb/alltypes2.parquet +0 -0
- package/data/duckdb/bq_medicare_test.parquet +0 -0
- package/data/duckdb/carriers.parquet +0 -0
- package/data/duckdb/flights/part.0.parquet +0 -0
- package/data/duckdb/flights/part.1.parquet +0 -0
- package/data/duckdb/flights/part.2.parquet +0 -0
- package/data/duckdb/flights.parquet +0 -0
- package/data/duckdb/flights_partitioned.parquet +0 -0
- package/data/duckdb/ga_sample.parquet +0 -0
- package/data/duckdb/numbers.parquet +0 -0
- package/data/duckdb/state_facts.parquet +0 -0
- package/data/duckdb/test.json +3 -0
- package/data/duckdb/words.parquet +0 -0
- package/data/duckdb/words_bigger.parquet +0 -0
- package/data/postgres/malloytest-postgres.sql.gz +0 -0
- package/data/postgres/state_facts.sql +366 -0
- package/dist/api.spec.d.ts +1 -0
- package/dist/api.spec.js +77 -0
- package/dist/api.spec.js.map +1 -0
- package/dist/databases/all/expr.spec.d.ts +3 -0
- package/dist/databases/all/expr.spec.js +581 -0
- package/dist/databases/all/expr.spec.js.map +1 -0
- package/dist/databases/all/functions.spec.d.ts +2 -0
- package/dist/databases/all/functions.spec.js +784 -0
- package/dist/databases/all/functions.spec.js.map +1 -0
- package/dist/databases/all/index.spec.d.ts +2 -0
- package/dist/databases/all/index.spec.js +154 -0
- package/dist/databases/all/index.spec.js.map +1 -0
- package/dist/databases/all/join.spec.d.ts +2 -0
- package/dist/databases/all/join.spec.js +309 -0
- package/dist/databases/all/join.spec.js.map +1 -0
- package/dist/databases/all/nomodel.spec.d.ts +2 -0
- package/dist/databases/all/nomodel.spec.js +957 -0
- package/dist/databases/all/nomodel.spec.js.map +1 -0
- package/dist/databases/all/orderby.spec.d.ts +2 -0
- package/dist/databases/all/orderby.spec.js +224 -0
- package/dist/databases/all/orderby.spec.js.map +1 -0
- package/dist/databases/all/problems.spec.d.ts +2 -0
- package/dist/databases/all/problems.spec.js +113 -0
- package/dist/databases/all/problems.spec.js.map +1 -0
- package/dist/databases/all/sql_expressions.spec.d.ts +2 -0
- package/dist/databases/all/sql_expressions.spec.js +96 -0
- package/dist/databases/all/sql_expressions.spec.js.map +1 -0
- package/dist/databases/all/time.spec.d.ts +3 -0
- package/dist/databases/all/time.spec.js +647 -0
- package/dist/databases/all/time.spec.js.map +1 -0
- package/dist/databases/bigquery/double_truncation.spec.d.ts +1 -0
- package/dist/databases/bigquery/double_truncation.spec.js +50 -0
- package/dist/databases/bigquery/double_truncation.spec.js.map +1 -0
- package/dist/databases/bigquery/handexpr.spec.d.ts +1 -0
- package/dist/databases/bigquery/handexpr.spec.js +713 -0
- package/dist/databases/bigquery/handexpr.spec.js.map +1 -0
- package/dist/databases/bigquery/injestion_time_partitioning.spec.d.ts +1 -0
- package/dist/databases/bigquery/injestion_time_partitioning.spec.js +235 -0
- package/dist/databases/bigquery/injestion_time_partitioning.spec.js.map +1 -0
- package/dist/databases/bigquery/joined_filters.spec.d.ts +1 -0
- package/dist/databases/bigquery/joined_filters.spec.js +72 -0
- package/dist/databases/bigquery/joined_filters.spec.js.map +1 -0
- package/dist/databases/bigquery/json.spec.d.ts +1 -0
- package/dist/databases/bigquery/json.spec.js +86 -0
- package/dist/databases/bigquery/json.spec.js.map +1 -0
- package/dist/databases/bigquery/malloy_query.spec.d.ts +1 -0
- package/dist/databases/bigquery/malloy_query.spec.js +906 -0
- package/dist/databases/bigquery/malloy_query.spec.js.map +1 -0
- package/dist/databases/bigquery/performance.skipped.spec.d.ts +1 -0
- package/dist/databases/bigquery/performance.skipped.spec.js +70 -0
- package/dist/databases/bigquery/performance.skipped.spec.js.map +1 -0
- package/dist/databases/bigquery/time.spec.d.ts +1 -0
- package/dist/databases/bigquery/time.spec.js +55 -0
- package/dist/databases/bigquery/time.spec.js.map +1 -0
- package/dist/databases/bigquery/wildcard_table_names.spec.d.ts +1 -0
- package/dist/databases/bigquery/wildcard_table_names.spec.js +212 -0
- package/dist/databases/bigquery/wildcard_table_names.spec.js.map +1 -0
- package/dist/databases/bigquery-duckdb/nested_source_table.spec.d.ts +1 -0
- package/dist/databases/bigquery-duckdb/nested_source_table.spec.js +247 -0
- package/dist/databases/bigquery-duckdb/nested_source_table.spec.js.map +1 -0
- package/dist/databases/bigquery-postgres/multi_connection.spec.d.ts +1 -0
- package/dist/databases/bigquery-postgres/multi_connection.spec.js +138 -0
- package/dist/databases/bigquery-postgres/multi_connection.spec.js.map +1 -0
- package/dist/databases/bigquery-postgres/streaming.spec.d.ts +1 -0
- package/dist/databases/bigquery-postgres/streaming.spec.js +88 -0
- package/dist/databases/bigquery-postgres/streaming.spec.js.map +1 -0
- package/dist/databases/duckdb/duckdb.spec.d.ts +1 -0
- package/dist/databases/duckdb/duckdb.spec.js +116 -0
- package/dist/databases/duckdb/duckdb.spec.js.map +1 -0
- package/dist/databases/postgres/postgres.spec.d.ts +1 -0
- package/dist/databases/postgres/postgres.spec.js +137 -0
- package/dist/databases/postgres/postgres.spec.js.map +1 -0
- package/dist/databases/shared/test_list.d.ts +3 -0
- package/dist/databases/shared/test_list.js +24 -0
- package/dist/databases/shared/test_list.js.map +1 -0
- package/dist/dependencies.spec.d.ts +1 -0
- package/dist/dependencies.spec.js +63 -0
- package/dist/dependencies.spec.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/model/utils.spec.d.ts +1 -0
- package/dist/model/utils.spec.js +38 -0
- package/dist/model/utils.spec.js.map +1 -0
- package/dist/models/faa_model.d.ts +5 -0
- package/dist/models/faa_model.js +977 -0
- package/dist/models/faa_model.js.map +1 -0
- package/dist/models/medicare_model.d.ts +4 -0
- package/dist/models/medicare_model.js +243 -0
- package/dist/models/medicare_model.js.map +1 -0
- package/dist/render/render.spec.d.ts +1 -0
- package/dist/render/render.spec.js +551 -0
- package/dist/render/render.spec.js.map +1 -0
- package/dist/runtimes.d.ts +33 -0
- package/dist/runtimes.js +147 -0
- package/dist/runtimes.js.map +1 -0
- package/dist/tags.spec.d.ts +1 -0
- package/dist/tags.spec.js +259 -0
- package/dist/tags.spec.js.map +1 -0
- package/dist/util/db-jest-matchers.d.ts +19 -0
- package/dist/util/db-jest-matchers.js +90 -0
- package/dist/util/db-jest-matchers.js.map +1 -0
- package/dist/util/index.d.ts +16 -0
- package/dist/util/index.js +171 -0
- package/dist/util/index.js.map +1 -0
- package/package.json +35 -0
- package/src/api.spec.ts +84 -0
- package/src/databases/all/expr.spec.ts +704 -0
- package/src/databases/all/functions.spec.ts +1135 -0
- package/src/databases/all/index.spec.ts +178 -0
- package/src/databases/all/join.spec.ts +350 -0
- package/src/databases/all/nomodel.spec.ts +1159 -0
- package/src/databases/all/orderby.spec.ts +268 -0
- package/src/databases/all/problems.spec.ts +121 -0
- package/src/databases/all/sql_expressions.spec.ts +107 -0
- package/src/databases/all/time.spec.ts +793 -0
- package/src/databases/bigquery/double_truncation.spec.ts +51 -0
- package/src/databases/bigquery/handexpr.spec.ts +782 -0
- package/src/databases/bigquery/injestion_time_partitioning.spec.ts +268 -0
- package/src/databases/bigquery/joined_filters.spec.ts +75 -0
- package/src/databases/bigquery/json.spec.ts +95 -0
- package/src/databases/bigquery/malloy_query.spec.ts +1036 -0
- package/src/databases/bigquery/performance.skipped.spec.ts +73 -0
- package/src/databases/bigquery/time.spec.ts +59 -0
- package/src/databases/bigquery/wildcard_table_names.spec.ts +233 -0
- package/src/databases/bigquery-duckdb/nested_source_table.spec.ts +268 -0
- package/src/databases/bigquery-postgres/multi_connection.spec.ts +143 -0
- package/src/databases/bigquery-postgres/streaming.spec.ts +100 -0
- package/src/databases/duckdb/duckdb.spec.ts +131 -0
- package/src/databases/postgres/postgres.spec.ts +167 -0
- package/src/databases/shared/test_list.ts +24 -0
- package/src/dependencies.spec.ts +62 -0
- package/src/index.ts +36 -0
- package/src/model/utils.spec.ts +37 -0
- package/src/models/faa_model.ts +995 -0
- package/src/models/medicare_model.ts +246 -0
- package/src/render/__snapshots__/render.spec.ts.snap +12574 -0
- package/src/render/render.spec.ts +670 -0
- package/src/runtimes.ts +182 -0
- package/src/tags.spec.ts +277 -0
- package/src/util/db-jest-matchers.ts +128 -0
- package/src/util/index.ts +191 -0
- package/tsconfig.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
## Tests
|
|
2
|
+
|
|
3
|
+
By default, tests run against BigQuery, Postgres, and DuckDB.
|
|
4
|
+
|
|
5
|
+
Tests can also be run against a specific database, using the MALLOY_DATABASE or MALLOY_DATABASES environment variable, such as: `MALLOY_DATABASES=bigquery,postgres npm run test`
|
|
6
|
+
|
|
7
|
+
Setting up postgres:
|
|
8
|
+
|
|
9
|
+
# Setup for Postgres Test Data
|
|
10
|
+
|
|
11
|
+
Assumes that postgres has been installed via nix (installs but doesn't configure).
|
|
12
|
+
|
|
13
|
+
ADD to environment: `export PGHOST=localhost`
|
|
14
|
+
|
|
15
|
+
**postgres_init.sh** - builds a database as the current user in .tmp/data/malloytestdb. Starts server runing on localhost:5432
|
|
16
|
+
copies the test data in `malloytest-postgres.sql.gz` into the database.
|
|
17
|
+
|
|
18
|
+
**postgres_start.sh** - starts the postgres server, once it has been installed (use after a reboot, for example)
|
|
19
|
+
|
|
20
|
+
**postgres_stop.sh** - stops the postgres server
|
|
21
|
+
|
|
22
|
+
**state_fact.sql** - example file on how to insert data from json
|
|
23
|
+
|
|
24
|
+
Setting up DuckDB:
|
|
25
|
+
|
|
26
|
+
# Building test database for duckdb
|
|
27
|
+
|
|
28
|
+
1. At top-level, run `npx ts-node scripts/build_duckdb_test_database.ts`
|
|
29
|
+
2. A file called `duckdb_test.db` should be created in the test/data/duckdb folder - tests will automatically look there.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pg_dump -n malloytest -O -x | gzip > ../sql/malloytest-postgres.sql.gz
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#! /bin/bash
|
|
2
|
+
export PGHOST=localhost
|
|
3
|
+
pg_ctl -D .tmp/data/malloytestdb -l .tmp/logfile -o "--unix_socket_directories='$PWD/.tmp'" stop
|
|
4
|
+
rm -rf .tmp
|
|
5
|
+
mkdir .tmp
|
|
6
|
+
initdb -d .tmp/data/malloytestdb --no-locale --encoding=UTF8
|
|
7
|
+
pg_ctl -D .tmp/data/malloytestdb -l .tmp/logfile -o "--unix_socket_directories='$PWD/.tmp'" start
|
|
8
|
+
createdb $USER
|
|
9
|
+
gunzip -c ../data/postgres/malloytest-postgres.sql.gz | psql
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
-- example of how to take a json blob and insert it into a postgres database
|
|
2
|
+
-- keeping around because it might be useful as we add new tables.
|
|
3
|
+
|
|
4
|
+
create type t as (state varchar, aircraft_count int, airport_count int, births int, popular_name varchar);
|
|
5
|
+
create table malloytest.state_facts as (
|
|
6
|
+
select p.*
|
|
7
|
+
from json_populate_recordset(null::t,'[
|
|
8
|
+
{
|
|
9
|
+
"state": "MN",
|
|
10
|
+
"aircraft_count": "83",
|
|
11
|
+
"airport_count": "507",
|
|
12
|
+
"births": "5574819",
|
|
13
|
+
"popular_name": "Ava"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"state": "LA",
|
|
17
|
+
"aircraft_count": "57",
|
|
18
|
+
"airport_count": "500",
|
|
19
|
+
"births": "5551025",
|
|
20
|
+
"popular_name": "Ava"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"state": "IA",
|
|
24
|
+
"aircraft_count": "28",
|
|
25
|
+
"airport_count": "319",
|
|
26
|
+
"births": "4108689",
|
|
27
|
+
"popular_name": "Ava"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"state": "IN",
|
|
31
|
+
"aircraft_count": "62",
|
|
32
|
+
"airport_count": "643",
|
|
33
|
+
"births": "7170553",
|
|
34
|
+
"popular_name": "Emma"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"state": "NC",
|
|
38
|
+
"aircraft_count": "72",
|
|
39
|
+
"airport_count": "400",
|
|
40
|
+
"births": "8440235",
|
|
41
|
+
"popular_name": "Emma"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"state": "AR",
|
|
45
|
+
"aircraft_count": "31",
|
|
46
|
+
"airport_count": "299",
|
|
47
|
+
"births": "3330382",
|
|
48
|
+
"popular_name": "Emma"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"state": "AL",
|
|
52
|
+
"aircraft_count": "58",
|
|
53
|
+
"airport_count": "260",
|
|
54
|
+
"births": "5645599",
|
|
55
|
+
"popular_name": "Emma"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"state": "MT",
|
|
59
|
+
"aircraft_count": "50",
|
|
60
|
+
"airport_count": "259",
|
|
61
|
+
"births": "942521",
|
|
62
|
+
"popular_name": "Emma"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"state": "ME",
|
|
66
|
+
"aircraft_count": "12",
|
|
67
|
+
"airport_count": "164",
|
|
68
|
+
"births": "1383204",
|
|
69
|
+
"popular_name": "Emma"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"state": "VA",
|
|
73
|
+
"aircraft_count": "67",
|
|
74
|
+
"airport_count": "421",
|
|
75
|
+
"births": "6693880",
|
|
76
|
+
"popular_name": "Olivia"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"state": "NE",
|
|
80
|
+
"aircraft_count": "24",
|
|
81
|
+
"airport_count": "308",
|
|
82
|
+
"births": "2255039",
|
|
83
|
+
"popular_name": "Olivia"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"state": "ID",
|
|
87
|
+
"aircraft_count": "36",
|
|
88
|
+
"airport_count": "238",
|
|
89
|
+
"births": "1147445",
|
|
90
|
+
"popular_name": "Olivia"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"state": "UT",
|
|
94
|
+
"aircraft_count": "53",
|
|
95
|
+
"airport_count": "140",
|
|
96
|
+
"births": "2306033",
|
|
97
|
+
"popular_name": "Olivia"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"state": "AK",
|
|
101
|
+
"aircraft_count": "85",
|
|
102
|
+
"airport_count": "608",
|
|
103
|
+
"births": "407106",
|
|
104
|
+
"popular_name": "Sophia"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"state": "WI",
|
|
108
|
+
"aircraft_count": "66",
|
|
109
|
+
"airport_count": "543",
|
|
110
|
+
"births": "6088288",
|
|
111
|
+
"popular_name": "Sophia"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"state": "MI",
|
|
115
|
+
"aircraft_count": "102",
|
|
116
|
+
"airport_count": "489",
|
|
117
|
+
"births": "11643455",
|
|
118
|
+
"popular_name": "Sophia"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"state": "WA",
|
|
122
|
+
"aircraft_count": "114",
|
|
123
|
+
"airport_count": "484",
|
|
124
|
+
"births": "4631964",
|
|
125
|
+
"popular_name": "Sophia"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"state": "OR",
|
|
129
|
+
"aircraft_count": "94",
|
|
130
|
+
"airport_count": "441",
|
|
131
|
+
"births": "2671780",
|
|
132
|
+
"popular_name": "Sophia"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"state": "ND",
|
|
136
|
+
"aircraft_count": "26",
|
|
137
|
+
"airport_count": "436",
|
|
138
|
+
"births": "1059330",
|
|
139
|
+
"popular_name": "Sophia"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"state": "MD",
|
|
143
|
+
"aircraft_count": "30",
|
|
144
|
+
"airport_count": "229",
|
|
145
|
+
"births": "4468717",
|
|
146
|
+
"popular_name": "Sophia"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"state": "SD",
|
|
150
|
+
"aircraft_count": "23",
|
|
151
|
+
"airport_count": "180",
|
|
152
|
+
"births": "1049223",
|
|
153
|
+
"popular_name": "Sophia"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"state": "NH",
|
|
157
|
+
"aircraft_count": "30",
|
|
158
|
+
"airport_count": "112",
|
|
159
|
+
"births": "955057",
|
|
160
|
+
"popular_name": "Sophia"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"state": "VT",
|
|
164
|
+
"aircraft_count": "6",
|
|
165
|
+
"airport_count": "81",
|
|
166
|
+
"births": "545999",
|
|
167
|
+
"popular_name": "Sophia"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"state": "DE",
|
|
171
|
+
"aircraft_count": "118",
|
|
172
|
+
"airport_count": "42",
|
|
173
|
+
"births": "615490",
|
|
174
|
+
"popular_name": "Sophia"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"state": "MS",
|
|
178
|
+
"aircraft_count": "27",
|
|
179
|
+
"airport_count": "243",
|
|
180
|
+
"births": "3969549",
|
|
181
|
+
"popular_name": "Madison"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"state": "SC",
|
|
185
|
+
"aircraft_count": "28",
|
|
186
|
+
"airport_count": "189",
|
|
187
|
+
"births": "4392042",
|
|
188
|
+
"popular_name": "Madison"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"state": "DC",
|
|
192
|
+
"aircraft_count": "6",
|
|
193
|
+
"airport_count": "20",
|
|
194
|
+
"births": "1419047",
|
|
195
|
+
"popular_name": "Madison"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"state": "TX",
|
|
199
|
+
"aircraft_count": "287",
|
|
200
|
+
"airport_count": "1845",
|
|
201
|
+
"births": "21467359",
|
|
202
|
+
"popular_name": "Isabella"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"state": "CA",
|
|
206
|
+
"aircraft_count": "367",
|
|
207
|
+
"airport_count": "984",
|
|
208
|
+
"births": "28810563",
|
|
209
|
+
"popular_name": "Isabella"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"state": "IL",
|
|
213
|
+
"aircraft_count": "111",
|
|
214
|
+
"airport_count": "890",
|
|
215
|
+
"births": "15178876",
|
|
216
|
+
"popular_name": "Isabella"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"state": "FL",
|
|
220
|
+
"aircraft_count": "228",
|
|
221
|
+
"airport_count": "856",
|
|
222
|
+
"births": "9277223",
|
|
223
|
+
"popular_name": "Isabella"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"state": "PA",
|
|
227
|
+
"aircraft_count": "83",
|
|
228
|
+
"airport_count": "804",
|
|
229
|
+
"births": "16661910",
|
|
230
|
+
"popular_name": "Isabella"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"state": "OH",
|
|
234
|
+
"aircraft_count": "106",
|
|
235
|
+
"airport_count": "749",
|
|
236
|
+
"births": "14201526",
|
|
237
|
+
"popular_name": "Isabella"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"state": "NY",
|
|
241
|
+
"aircraft_count": "91",
|
|
242
|
+
"airport_count": "576",
|
|
243
|
+
"births": "23694136",
|
|
244
|
+
"popular_name": "Isabella"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"state": "MO",
|
|
248
|
+
"aircraft_count": "62",
|
|
249
|
+
"airport_count": "537",
|
|
250
|
+
"births": "6792279",
|
|
251
|
+
"popular_name": "Isabella"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"state": "OK",
|
|
255
|
+
"aircraft_count": "99",
|
|
256
|
+
"airport_count": "443",
|
|
257
|
+
"births": "4137117",
|
|
258
|
+
"popular_name": "Isabella"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"state": "GA",
|
|
262
|
+
"aircraft_count": "98",
|
|
263
|
+
"airport_count": "440",
|
|
264
|
+
"births": "8183223",
|
|
265
|
+
"popular_name": "Isabella"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"state": "CO",
|
|
269
|
+
"aircraft_count": "98",
|
|
270
|
+
"airport_count": "425",
|
|
271
|
+
"births": "3424936",
|
|
272
|
+
"popular_name": "Isabella"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"state": "KS",
|
|
276
|
+
"aircraft_count": "63",
|
|
277
|
+
"airport_count": "415",
|
|
278
|
+
"births": "3212573",
|
|
279
|
+
"popular_name": "Isabella"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"state": "NJ",
|
|
283
|
+
"aircraft_count": "47",
|
|
284
|
+
"airport_count": "378",
|
|
285
|
+
"births": "8318769",
|
|
286
|
+
"popular_name": "Isabella"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"state": "AZ",
|
|
290
|
+
"aircraft_count": "98",
|
|
291
|
+
"airport_count": "319",
|
|
292
|
+
"births": "3328182",
|
|
293
|
+
"popular_name": "Isabella"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"state": "TN",
|
|
297
|
+
"aircraft_count": "62",
|
|
298
|
+
"airport_count": "285",
|
|
299
|
+
"births": "6313851",
|
|
300
|
+
"popular_name": "Isabella"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"state": "MA",
|
|
304
|
+
"aircraft_count": "40",
|
|
305
|
+
"airport_count": "225",
|
|
306
|
+
"births": "7576933",
|
|
307
|
+
"popular_name": "Isabella"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"state": "KY",
|
|
311
|
+
"aircraft_count": "26",
|
|
312
|
+
"airport_count": "202",
|
|
313
|
+
"births": "5352594",
|
|
314
|
+
"popular_name": "Isabella"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"state": "NM",
|
|
318
|
+
"aircraft_count": "46",
|
|
319
|
+
"airport_count": "181",
|
|
320
|
+
"births": "1640394",
|
|
321
|
+
"popular_name": "Isabella"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"state": "CT",
|
|
325
|
+
"aircraft_count": "25",
|
|
326
|
+
"airport_count": "153",
|
|
327
|
+
"births": "3361014",
|
|
328
|
+
"popular_name": "Isabella"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"state": "NV",
|
|
332
|
+
"aircraft_count": "55",
|
|
333
|
+
"airport_count": "128",
|
|
334
|
+
"births": "842854",
|
|
335
|
+
"popular_name": "Isabella"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"state": "WV",
|
|
339
|
+
"aircraft_count": "13",
|
|
340
|
+
"airport_count": "116",
|
|
341
|
+
"births": "2962442",
|
|
342
|
+
"popular_name": "Isabella"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"state": "WY",
|
|
346
|
+
"aircraft_count": "15",
|
|
347
|
+
"airport_count": "115",
|
|
348
|
+
"births": "423000",
|
|
349
|
+
"popular_name": "Isabella"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"state": "HI",
|
|
353
|
+
"aircraft_count": "10",
|
|
354
|
+
"airport_count": "52",
|
|
355
|
+
"births": "950538",
|
|
356
|
+
"popular_name": "Isabella"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"state": "RI",
|
|
360
|
+
"aircraft_count": "5",
|
|
361
|
+
"airport_count": "28",
|
|
362
|
+
"births": "1148302",
|
|
363
|
+
"popular_name": "Isabella"
|
|
364
|
+
}
|
|
365
|
+
]') as p
|
|
366
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/api.spec.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2023 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
* a copy of this software and associated documentation files
|
|
8
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
9
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
10
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
11
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
12
|
+
* subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be
|
|
15
|
+
* included in all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
20
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
21
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
22
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
23
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const runtimes_1 = require("./runtimes");
|
|
27
|
+
const runtime = (0, runtimes_1.runtimeFor)('duckdb');
|
|
28
|
+
describe('extendModel', () => {
|
|
29
|
+
test('can run query in extend section', async () => {
|
|
30
|
+
const model = runtime.loadModel(`
|
|
31
|
+
query: q1 is table('malloytest.aircraft')->{
|
|
32
|
+
where: state = 'CA'
|
|
33
|
+
group_by: state
|
|
34
|
+
}
|
|
35
|
+
`);
|
|
36
|
+
const q1 = model.loadQueryByName('q1');
|
|
37
|
+
const oneState = await q1.run();
|
|
38
|
+
expect(oneState.data.path(0, 'state').value).toBe('CA');
|
|
39
|
+
const extended = model.extendModel(`
|
|
40
|
+
query: q2 is table('malloytest.aircraft')->{
|
|
41
|
+
where: state = 'NV'
|
|
42
|
+
group_by: state
|
|
43
|
+
}
|
|
44
|
+
`);
|
|
45
|
+
const q2 = extended.loadQueryByName('q2');
|
|
46
|
+
const twoState = await q2.run();
|
|
47
|
+
expect(twoState.data.path(0, 'state').value).toBe('NV');
|
|
48
|
+
});
|
|
49
|
+
test('can reference query from previous section ', async () => {
|
|
50
|
+
const model = runtime.loadModel(`
|
|
51
|
+
query: q1 is table('malloytest.aircraft')->{
|
|
52
|
+
where: state = 'CA'
|
|
53
|
+
group_by: state
|
|
54
|
+
}
|
|
55
|
+
`);
|
|
56
|
+
const q1 = model.loadQueryByName('q1');
|
|
57
|
+
const oneState = await q1.run();
|
|
58
|
+
expect(oneState.data.path(0, 'state').value).toBe('CA');
|
|
59
|
+
const extended = model.extendModel('query: q2 is ->q1 -> { project: * }');
|
|
60
|
+
const q2 = extended.loadQueryByName('q2');
|
|
61
|
+
const twoState = await q2.run();
|
|
62
|
+
expect(twoState.data.path(0, 'state').value).toBe('CA');
|
|
63
|
+
});
|
|
64
|
+
test('can reference sql from previous section ', async () => {
|
|
65
|
+
const model = runtime.loadModel(`
|
|
66
|
+
sql: q1 is { connection: "duckdb" select: """SELECT 'CA' as state""" }
|
|
67
|
+
`);
|
|
68
|
+
const extended = model.extendModel('query: q2 is from_sql(q1)->{project: *}');
|
|
69
|
+
const q2 = extended.loadQueryByName('q2');
|
|
70
|
+
const twoState = await q2.run();
|
|
71
|
+
expect(twoState.data.path(0, 'state').value).toBe('CA');
|
|
72
|
+
});
|
|
73
|
+
test('returns helpful error message if named query does not exist', async () => {
|
|
74
|
+
await expect(runtime.getQueryByName('', 'Dummy Query')).rejects.toThrow('Given query name does not refer to a named query.');
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=api.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.spec.js","sourceRoot":"","sources":["../src/api.spec.ts"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B;;;;;;;;;;;;;;;;;;;;;GAqBG;;AAEH,yCAAsC;AAEtC,MAAM,OAAO,GAAG,IAAA,qBAAU,EAAC,QAAQ,CAAC,CAAC;AAErC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC;;;;;KAK/B,CAAC,CAAC;QACH,MAAM,EAAE,GAAG,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExD,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC;;;;;KAKlC,CAAC,CAAC;QACH,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC;;;;;KAK/B,CAAC,CAAC;QACH,MAAM,EAAE,GAAG,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExD,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,qCAAqC,CAAC,CAAC;QAC1E,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC;;KAE/B,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAChC,yCAAyC,CAC1C,CAAC;QACF,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC7E,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CACrE,mDAAmD,CACpD,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|