Skip to content

Commit

Permalink
Merge pull request #1299 from partiql/eval-struct
Browse files Browse the repository at this point in the history
Adds literal STRUCT test
  • Loading branch information
rchowell authored Dec 20, 2023
2 parents 5617ef6 + 0a16ab5 commit 35377df
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 35377df

Please sign in to comment.