From 0a16ab55d41af6275f03e62f02efdc17878ef388 Mon Sep 17 00:00:00 2001 From: John Ed Quinn Date: Tue, 12 Dec 2023 13:12:30 -0800 Subject: [PATCH] Adds literal STRUCT test --- .../eval/internal/PartiQLEngineDefaultTest.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/partiql-eval/src/test/kotlin/org/partiql/eval/internal/PartiQLEngineDefaultTest.kt b/partiql-eval/src/test/kotlin/org/partiql/eval/internal/PartiQLEngineDefaultTest.kt index e57da2baf5..4be2ce10d3 100644 --- a/partiql-eval/src/test/kotlin/org/partiql/eval/internal/PartiQLEngineDefaultTest.kt +++ b/partiql-eval/src/test/kotlin/org/partiql/eval/internal/PartiQLEngineDefaultTest.kt @@ -404,4 +404,35 @@ class PartiQLEngineDefaultTest { ) assertEquals(expected, output) } + + @OptIn(PartiQLValueExperimental::class) + @Test + fun testStruct() { + val source = """ + SELECT VALUE { + 'a': 1, + 'b': NULL, + c : d + } + FROM << + { 'c': 'hello', 'd': 'world' } + >> + """.trimIndent() + val statement = parser.parse(source).root + val session = PartiQLPlanner.Session("q", "u") + val plan = planner.plan(statement, session) + + val prepared = engine.prepare(plan.plan) + val result = engine.execute(prepared) as PartiQLResult.Value + val output = result.value + + val expected: PartiQLValue = bagValue( + structValue( + "a" to int32Value(1), + "b" to nullValue(), + "hello" to stringValue("world") + ) + ) + assertEquals(expected, output) + } }