@malloydata/malloy-tests 0.0.279 → 0.0.281
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/package.json
CHANGED
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@jest/globals": "^29.4.3",
|
|
24
|
-
"@malloydata/db-bigquery": "0.0.
|
|
25
|
-
"@malloydata/db-duckdb": "0.0.
|
|
26
|
-
"@malloydata/db-postgres": "0.0.
|
|
27
|
-
"@malloydata/db-snowflake": "0.0.
|
|
28
|
-
"@malloydata/db-trino": "0.0.
|
|
29
|
-
"@malloydata/malloy": "0.0.
|
|
30
|
-
"@malloydata/malloy-tag": "0.0.
|
|
31
|
-
"@malloydata/render": "0.0.
|
|
24
|
+
"@malloydata/db-bigquery": "0.0.281",
|
|
25
|
+
"@malloydata/db-duckdb": "0.0.281",
|
|
26
|
+
"@malloydata/db-postgres": "0.0.281",
|
|
27
|
+
"@malloydata/db-snowflake": "0.0.281",
|
|
28
|
+
"@malloydata/db-trino": "0.0.281",
|
|
29
|
+
"@malloydata/malloy": "0.0.281",
|
|
30
|
+
"@malloydata/malloy-tag": "0.0.281",
|
|
31
|
+
"@malloydata/render": "0.0.281",
|
|
32
32
|
"events": "^3.3.0",
|
|
33
33
|
"jsdom": "^22.1.0",
|
|
34
34
|
"luxon": "^2.4.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"@types/jsdom": "^21.1.1",
|
|
39
39
|
"@types/luxon": "^2.4.0"
|
|
40
40
|
},
|
|
41
|
-
"version": "0.0.
|
|
41
|
+
"version": "0.0.281"
|
|
42
42
|
}
|
|
@@ -591,54 +591,60 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
591
591
|
});
|
|
592
592
|
});
|
|
593
593
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
594
|
+
it('${view_name.dimension_name} - one path', async () => {
|
|
595
|
+
await expect(`
|
|
596
|
+
##! experimental { sql_functions }
|
|
597
|
+
source: a0 is ${databaseName}.table('malloytest.aircraft_models')
|
|
598
|
+
source: a is ${databaseName}.table('malloytest.aircraft_models') extend {
|
|
599
|
+
where: aircraft_model_code ? '0270202'
|
|
600
|
+
join_one: a0 on aircraft_model_code = a0.aircraft_model_code
|
|
601
|
+
}
|
|
602
602
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
await expect(query.run()).rejects.toThrow(
|
|
609
|
-
"'.' paths are not yet supported in sql interpolations, found ${a.manufacturer}"
|
|
610
|
-
);
|
|
603
|
+
run: a -> {
|
|
604
|
+
group_by: string_1 is sql_string("UPPER(\${a0.manufacturer})")
|
|
605
|
+
}
|
|
606
|
+
`).malloyResultMatches(expressionModel, {
|
|
607
|
+
string_1: 'AHRENS AIRCRAFT CORP.',
|
|
611
608
|
});
|
|
609
|
+
});
|
|
612
610
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
611
|
+
it('${view_name.dimension_name} - multiple paths', async () => {
|
|
612
|
+
await expect(`
|
|
613
|
+
##! experimental { sql_functions }
|
|
614
|
+
source: a0 is ${databaseName}.table('malloytest.aircraft_models')
|
|
615
|
+
source: a is ${databaseName}.table('malloytest.aircraft_models') extend {
|
|
616
|
+
where: aircraft_model_code ? '0270202'
|
|
617
|
+
join_one: a0 on aircraft_model_code = a0.aircraft_model_code
|
|
618
|
+
}
|
|
618
619
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
await expect(query.run()).rejects.toThrow(
|
|
625
|
-
"'.' paths are not yet supported in sql interpolations, found (${a.seats}, ${a.seats}, ${a.total_seats})"
|
|
626
|
-
);
|
|
620
|
+
run: a -> {
|
|
621
|
+
group_by: number_1 is sql_number("\${seats} + \${a0.seats}")
|
|
622
|
+
}
|
|
623
|
+
`).malloyResultMatches(expressionModel, {
|
|
624
|
+
number_1: 58,
|
|
627
625
|
});
|
|
626
|
+
});
|
|
628
627
|
|
|
629
|
-
|
|
628
|
+
describe('[not yet supported]', () => {
|
|
629
|
+
// See ${...} documentation for lookml here for guidance on remaining work:
|
|
630
|
+
// https://cloud.google.com/looker/docs/reference/param-field-sql#sql_for_dimensions
|
|
631
|
+
it('${SQL_TABLE_NAME}', async () => {
|
|
630
632
|
const query = await expressionModel.loadQuery(
|
|
631
633
|
`
|
|
632
634
|
##! experimental { sql_functions }
|
|
633
|
-
source:
|
|
635
|
+
source: a0 is ${databaseName}.table('malloytest.aircraft_models')
|
|
636
|
+
source: a is ${databaseName}.table('malloytest.aircraft_models') extend {
|
|
637
|
+
where: aircraft_model_code ? '0270202'
|
|
638
|
+
join_one: a0 on aircraft_model_code = a0.aircraft_model_code
|
|
639
|
+
}
|
|
634
640
|
|
|
635
641
|
run: a -> {
|
|
636
|
-
|
|
637
|
-
|
|
642
|
+
group_by: number_1 is sql_number("\${a0.SQL_TABLE_NAME}.seats")
|
|
643
|
+
}
|
|
638
644
|
`
|
|
639
645
|
);
|
|
640
646
|
await expect(query.run()).rejects.toThrow(
|
|
641
|
-
"'
|
|
647
|
+
"Invalid interpolation: 'SQL_TABLE_NAME' is not defined"
|
|
642
648
|
);
|
|
643
649
|
});
|
|
644
650
|
});
|
|
@@ -459,6 +459,25 @@ expressionModels.forEach((x, databaseName) => {
|
|
|
459
459
|
expect(result.data.path(3, 'r').value).toBe(3);
|
|
460
460
|
});
|
|
461
461
|
|
|
462
|
+
it(`dense_rank is supported - ${databaseName}`, async () => {
|
|
463
|
+
const result = await expressionModel
|
|
464
|
+
.loadQuery(
|
|
465
|
+
` run: state_facts -> {
|
|
466
|
+
group_by:
|
|
467
|
+
first_letter is substr(state, 1, 1)
|
|
468
|
+
aggregate: state_count is count()
|
|
469
|
+
calculate: r is dense_rank() {order_by: state_count desc}
|
|
470
|
+
}`
|
|
471
|
+
)
|
|
472
|
+
.run();
|
|
473
|
+
// console.log(result.sql);
|
|
474
|
+
// console.log(result.data);
|
|
475
|
+
expect(result.data.path(0, 'r').value).toBe(1);
|
|
476
|
+
expect(result.data.path(1, 'r').value).toBe(1);
|
|
477
|
+
expect(result.data.path(2, 'r').value).toBe(2);
|
|
478
|
+
expect(result.data.path(3, 'r').value).toBe(2);
|
|
479
|
+
});
|
|
480
|
+
|
|
462
481
|
it(`works using unary minus in calculate block - ${databaseName}`, async () => {
|
|
463
482
|
const result = await expressionModel
|
|
464
483
|
.loadQuery(
|
|
@@ -1777,6 +1796,42 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
1777
1796
|
},
|
|
1778
1797
|
]);
|
|
1779
1798
|
});
|
|
1799
|
+
// TODO remove the need for the `##! unsafe_complex_select_query` compiler flag
|
|
1800
|
+
it('can be used in a select in a composite source', async () => {
|
|
1801
|
+
await expect(`
|
|
1802
|
+
##! experimental { function_order_by partition_by composite_sources }
|
|
1803
|
+
##! unsafe_complex_select_query
|
|
1804
|
+
source: state_facts_composite is compose(state_facts, state_facts)
|
|
1805
|
+
run: state_facts_composite -> {
|
|
1806
|
+
select: state, births, popular_name
|
|
1807
|
+
calculate: prev_births_by_name is lag(births) {
|
|
1808
|
+
partition_by: popular_name
|
|
1809
|
+
order_by: births desc
|
|
1810
|
+
}
|
|
1811
|
+
order_by: births desc
|
|
1812
|
+
limit: 3
|
|
1813
|
+
}
|
|
1814
|
+
`).malloyResultMatches(expressionModel, [
|
|
1815
|
+
{
|
|
1816
|
+
state: 'CA',
|
|
1817
|
+
births: 28810563,
|
|
1818
|
+
popular_name: 'Isabella',
|
|
1819
|
+
prev_births_by_name: null,
|
|
1820
|
+
},
|
|
1821
|
+
{
|
|
1822
|
+
state: 'NY',
|
|
1823
|
+
births: 23694136,
|
|
1824
|
+
popular_name: 'Isabella',
|
|
1825
|
+
prev_births_by_name: 28810563,
|
|
1826
|
+
},
|
|
1827
|
+
{
|
|
1828
|
+
state: 'TX',
|
|
1829
|
+
births: 21467359,
|
|
1830
|
+
popular_name: 'Isabella',
|
|
1831
|
+
prev_births_by_name: 23694136,
|
|
1832
|
+
},
|
|
1833
|
+
]);
|
|
1834
|
+
});
|
|
1780
1835
|
});
|
|
1781
1836
|
});
|
|
1782
1837
|
|
|
@@ -345,6 +345,15 @@ describe.each(runtimes.runtimeList)(
|
|
|
345
345
|
}
|
|
346
346
|
`).malloyResultMatches(runtime, {some_words: ['hello', 'world']});
|
|
347
347
|
});
|
|
348
|
+
it('runs array_agg', async () => {
|
|
349
|
+
const onetwo = `${databaseName}.sql('SELECT 1 as "n" UNION ALL SELECT 2 UNION ALL SELECT 1')`;
|
|
350
|
+
await expect(`##! experimental
|
|
351
|
+
run: ${onetwo}->{aggregate: alln is array_agg(n) {order_by: n desc }}
|
|
352
|
+
`).matchesRows(runtime, {alln: [2, 1, 1]});
|
|
353
|
+
await expect(`##! experimental
|
|
354
|
+
run: ${onetwo}->{aggregate: alln is array_agg_distinct(n) {order_by:n asc}}
|
|
355
|
+
`).matchesRows(runtime, {alln: [1, 2]});
|
|
356
|
+
});
|
|
348
357
|
it.when(presto)('runs array_average', async () => {
|
|
349
358
|
await expect(
|
|
350
359
|
`run: ${nums}->{select: tavg is array_average(nums)}`
|