Skip to content

Commit 3ce2e24

Browse files
committed
Added a custom HyperLogLog test for Snowflake. This test is similar to BigQuery, but the two estimators return different values, reflecting the probabalistic nature of the algorithm. Thus we provide standalone tests for each.
Signed-off-by: Jason Smart <jlsmart@meta.com>
1 parent aca05a2 commit 3ce2e24

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
/* eslint-disable no-console */
9+
10+
import {RuntimeList} from '../../runtimes';
11+
import {describeIfDatabaseAvailable} from '../../util';
12+
import '../../util/db-jest-matchers';
13+
14+
const [describe, databases] = describeIfDatabaseAvailable(['snowflake']);
15+
const runtimes = new RuntimeList(databases);
16+
17+
describe.each(runtimes.runtimeList)(
18+
'Snowflake dialect functions - %s',
19+
20+
(databaseName, runtime) => {
21+
if (runtime === undefined) {
22+
throw new Error("Couldn't build runtime");
23+
}
24+
it(`hyperloglog combine`, async () => {
25+
await expect(`run: bigquery.table('malloytest.airports')->{
26+
aggregate: code_hll is hll_accumulate(code)
27+
} -> {
28+
aggregate: code_count is hll_estimate(hll_combine(code_hll))
29+
}
30+
`).malloyResultMatches(runtime, {code_count: 19812});
31+
});
32+
}
33+
);

0 commit comments

Comments
 (0)