-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f23f1d
commit e3793a2
Showing
3 changed files
with
62 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {RuntimeList, allDatabases} from '../../runtimes'; | ||
import {databasesFromEnvironmentOr} from '../../util'; | ||
import '../../util/db-jest-matchers'; | ||
|
||
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases)); | ||
|
||
describe.each(runtimes.runtimeList)( | ||
'composite fields %s', | ||
(databaseName, runtime) => { | ||
describe('simple arrays', () => { | ||
const evens = 'duckdb.sql("SELECT [2,4] as evens")'; | ||
test('array literal', async () => { | ||
await expect(` | ||
# test.debug | ||
run: duckdb.sql("SELECT 1 AS row") -> { select: odds is [1,3] } | ||
`).malloyResultMatches(runtime, {odds: [1, 3]}); | ||
}); | ||
test('array-un-nest', async () => { | ||
await expect(` | ||
run: ${evens}->{ select: n is evens.each } | ||
`).malloyResultMatches(runtime, [{n: 2}, {n: 4}]); | ||
}); | ||
test('array columns can be passed to functions', async () => { | ||
await expect( | ||
`run: ${evens}->{ select: two is len!number(evens); } ` | ||
).malloyResultMatches(runtime, {two: 2}); | ||
}); | ||
test('array columns can be selected', async () => { | ||
await expect(`run: ${evens}->{ select: evens }`).malloyResultMatches( | ||
runtime, | ||
{evens: [2, 4]} | ||
); | ||
}); | ||
}); | ||
describe('record', () => { | ||
const record = 'duckdb.sql("SELECT {s: 0, m: 1, l:2, xl: 3} as record")'; | ||
test('record can be selected', async () => { | ||
await expect( | ||
` | ||
run: ${record} -> { select: record }` | ||
).malloyResultMatches(runtime, { | ||
'record/s': 0, | ||
'record/m': 1, | ||
'record/l': 2, | ||
'record/xl': 3, | ||
}); | ||
}); | ||
}); | ||
} | ||
); |