Skip to content

Commit

Permalink
Updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedquinn committed Feb 5, 2025
1 parent 1ef1301 commit b9575e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import org.partiql.spi.catalog.Catalog
import org.partiql.spi.catalog.Name
import org.partiql.spi.catalog.Session
import org.partiql.spi.catalog.Table
import org.partiql.spi.errors.PRuntimeException
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.spi.value.DatumReader
Expand Down Expand Up @@ -75,22 +74,11 @@ public class SuccessTestCase(
.catalog("memory")
.catalogs(catalog)
.build()
val result: Datum
val plan: Plan
val comparison = try {
plan = planner.plan(statement, session).plan
result = DatumMaterialize.materialize(compiler.prepare(plan, mode).execute())
val comparison = when (jvmEquality) {
true -> expected == result
false -> Datum.comparator().compare(expected, result) == 0
}
comparison
} catch (e: PRuntimeException) {
val cause = e.error.getOrNull("CAUSE", Throwable::class.java)
if (cause != null) {
throw cause
}
throw e
val plan = planner.plan(statement, session).plan
val result = DatumMaterialize.materialize(compiler.prepare(plan, mode).execute())
val comparison = when (jvmEquality) {
true -> expected == result
false -> Datum.comparator().compare(expected, result) == 0
}
assert(comparison) {
comparisonString(expected, result, plan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.partiql.ast.SetOpType
import org.partiql.ast.SetQuantifier
import org.partiql.ast.expr.Expr
import org.partiql.ast.expr.ExprQuerySet
import org.partiql.spi.errors.PRuntimeException
import kotlin.test.assertEquals

class PartiQLParserBagOpTests {
Expand Down Expand Up @@ -384,7 +383,7 @@ class PartiQLParserBagOpTests {

@Test
fun outerExceptNonSpecified() = assertExpression(
"SELECT * FROM <<{'a': 1}>> EXCEPT (2)",
"SELECT * FROM <<{'a': 1}>> EXCEPT 2",
queryBody {
exprQuerySet(
body = queryBodySetOp(
Expand Down Expand Up @@ -674,12 +673,7 @@ class PartiQLParserBagOpTests {
)

private fun assertExpression(input: String, expected: AstNode) {
val parseResult = try {
parser.parse(input)
} catch (e: PRuntimeException) {
e.error.getOrNull("CAUSE", Throwable::class.java)?.let { throw it }
throw e
}
val parseResult = parser.parse(input)
assertEquals(1, parseResult.statements.size)
val actual = parseResult.statements[0]
assertEquals(expected, actual)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class WithSelectTests {
"Simplest test" to "WITH a AS (SELECT * FROM t) SELECT * FROM a, a",
"Simplest test delimited" to "WITH \"a\" AS (SELECT * FROM t) SELECT * FROM a, a",
"Multiple withs" to "WITH a AS (SELECT * FROM t), b AS (SELECT * FROM r) SELECT * FROM a, b",
"Qualified identifiers" to "WITH a.b AS (SELECT * FROM t), b.c AS (SELECT * FROM r) SELECT * FROM a.b, b.c",
"Qualified identifiers delimited" to "WITH \"a\".\"b\" AS (SELECT * FROM t), b.c AS (SELECT * FROM r) SELECT * FROM a.b, b.c",
"Simplest with column name" to "WITH a (b) AS (SELECT * FROM t) SELECT * FROM a, a",
"Simplest with column names" to "WITH a (b, c, d) AS (SELECT * FROM t) SELECT * FROM a, a",
"Target with union" to "WITH a AS (SELECT * FROM t UNION r) SELECT * FROM a, a",
Expand All @@ -44,6 +42,8 @@ class WithSelectTests {
"No parenthesis on with target" to "WITH a AS SELECT * FROM t SELECT * FROM a",
"Unsupported path index" to "WITH a.b[0] AS (SELECT * FROM t) SELECT * FROM a, a",
"Unsupported path index" to "WITH a['b'] AS (SELECT * FROM t) SELECT * FROM a, a",
"Qualified identifiers" to "WITH a.b AS (SELECT * FROM t), b.c AS (SELECT * FROM r) SELECT * FROM a.b, b.c",
"Qualified identifiers delimited" to "WITH \"a\".\"b\" AS (SELECT * FROM t), b.c AS (SELECT * FROM r) SELECT * FROM a.b, b.c",
"With target is scalar" to "WITH a AS (5) SELECT * FROM a",
"With target is bag" to "WITH a AS (<<5>>) SELECT * FROM a",
"With target is bag with no paren" to "WITH a AS <<5>> SELECT * FROM a",
Expand Down

0 comments on commit b9575e4

Please sign in to comment.