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 dd1da13ff4..4b11622b37 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 @@ -7,11 +7,13 @@ import org.partiql.parser.PartiQLParserBuilder import org.partiql.planner.PartiQLPlanner import org.partiql.planner.PartiQLPlannerBuilder import org.partiql.value.BagValue +import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental import org.partiql.value.bagValue import org.partiql.value.boolValue import org.partiql.value.int32Value import org.partiql.value.nullValue +import org.partiql.value.stringValue import org.partiql.value.structValue import kotlin.test.assertEquals @@ -98,4 +100,39 @@ class PartiQLEngineDefaultTest { val expected = bagValue(sequenceOf(structValue(sequenceOf("a" to int32Value(1), "b" to nullValue())))) 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( + sequenceOf( + structValue( + sequenceOf( + "a" to int32Value(1), + "b" to nullValue(), + "hello" to stringValue("world") + ) + ) + ) + ) + assertEquals(expected, output) + } }