Skip to content

Commit 9ef9a87

Browse files
committed
Fix SubsumptionTest
1 parent 0b4dde5 commit 9ef9a87

File tree

6 files changed

+246
-272
lines changed

6 files changed

+246
-272
lines changed

partiql-eval/src/main/kotlin/org/partiql/eval/internal/Compiler.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ internal class Compiler(
236236
return RelFilter(input, condition)
237237
}
238238

239-
override fun visitRelOpExclude(node: Rel.Op.Exclude, ctx: Unit): Operator {
239+
override fun visitRelOpExclude(node: Rel.Op.Exclude, ctx: Symbols): Operator {
240240
val input = visitRel(node.input, ctx)
241241
return RelExclude(input, node.paths)
242242
}

partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt

+177-166
Large diffs are not rendered by default.

partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import org.partiql.ast.helpers.toBinder
3232
import org.partiql.ast.util.AstRewriter
3333
import org.partiql.ast.visitor.AstBaseVisitor
3434
import org.partiql.planner.internal.Env
35-
import org.partiql.planner.internal.ir.Identifier
3635
import org.partiql.planner.internal.ir.Rel
3736
import org.partiql.planner.internal.ir.Rex
3837
import org.partiql.planner.internal.ir.rel
@@ -71,6 +70,7 @@ import org.partiql.planner.internal.ir.rexOpVarResolved
7170
import org.partiql.types.StaticType
7271
import org.partiql.value.PartiQLValueExperimental
7372
import org.partiql.value.boolValue
73+
import org.partiql.planner.internal.ir.Identifier as InternalId
7474

7575
/**
7676
* Lexically scoped state for use in translating an individual SELECT statement.
@@ -366,8 +366,8 @@ internal object RelConverter {
366366
val args = expr.args.map { arg -> arg.toRex(env) }
367367
val id = AstToPlan.convert(expr.function)
368368
val name = when (id) {
369-
is Identifier.Qualified -> error("Qualified aggregation calls are not supported.")
370-
is Identifier.Symbol -> id.symbol.lowercase()
369+
is InternalId.Qualified -> error("Qualified aggregation calls are not supported.")
370+
is InternalId.Symbol -> id.symbol.lowercase()
371371
}
372372
relOpAggregateCallUnresolved(name, args)
373373
}

partiql-planner/src/test/kotlin/org/partiql/planner/internal/exclude/SubsumptionTest.kt

+49-63
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,23 @@ import org.partiql.plan.relOpExcludeTypeStructSymbol
2020
import org.partiql.plan.relOpExcludeTypeStructWildcard
2121
import org.partiql.plan.rexOpVar
2222
import org.partiql.planner.PartiQLPlanner
23+
import org.partiql.plugins.memory.MemoryConnector
24+
import org.partiql.spi.connector.ConnectorSession
2325
import java.util.stream.Stream
2426
import kotlin.test.assertEquals
2527

2628
class SubsumptionTest {
27-
private val planner = org.partiql.planner.PartiQLPlannerBuilder().build()
28-
private val parser = PartiQLParser.default()
29+
30+
companion object {
31+
32+
private val planner = PartiQLPlanner.default()
33+
private val parser = PartiQLParser.default()
34+
private val session = object : ConnectorSession {
35+
override fun getQueryId(): String = "query-id"
36+
override fun getUserId(): String = "user-id"
37+
}
38+
private val connector = MemoryConnector.empty()
39+
}
2940

3041
private fun getExcludeClause(statement: Statement): Rel.Op.Exclude {
3142
val queryExpr = (statement as Statement.Query).root
@@ -36,7 +47,12 @@ class SubsumptionTest {
3647
private fun testExcludeExprSubsumption(tc: SubsumptionTC) {
3748
val text = "SELECT * EXCLUDE ${tc.excludeExprStr} FROM <<>> AS s, <<>> AS t;"
3849
val statement = parser.parse(text).root
39-
val session = PartiQLPlanner.Session("q", "u")
50+
val session = PartiQLPlanner.Session(
51+
queryId = "query-id", userId = "user-id", currentCatalog = "default",
52+
catalogs = mapOf(
53+
"default" to connector.getMetadata(session),
54+
)
55+
)
4056
val plan = planner.plan(statement, session).plan
4157
val excludeClause = getExcludeClause(plan.statement).paths
4258
assertEquals(tc.expectedExcludeExprs, excludeClause)
@@ -111,25 +127,21 @@ class SubsumptionTest {
111127
root = rexOpVar(0),
112128
steps = listOf(
113129
relOpExcludeStep(
114-
type = relOpExcludeTypeStructSymbol(symbol = "a"),
115-
substeps = emptyList()
130+
type = relOpExcludeTypeStructSymbol(symbol = "a"), substeps = emptyList()
116131
),
117132
relOpExcludeStep(
118-
type = relOpExcludeTypeStructSymbol(symbol = "b"),
119-
substeps = emptyList()
133+
type = relOpExcludeTypeStructSymbol(symbol = "b"), substeps = emptyList()
120134
)
121135
)
122136
),
123137
relOpExcludePath(
124138
root = rexOpVar(1),
125139
steps = listOf(
126140
relOpExcludeStep(
127-
type = relOpExcludeTypeStructSymbol(symbol = "a"),
128-
substeps = emptyList()
141+
type = relOpExcludeTypeStructSymbol(symbol = "a"), substeps = emptyList()
129142
),
130143
relOpExcludeStep(
131-
type = relOpExcludeTypeStructSymbol(symbol = "b"),
132-
substeps = emptyList()
144+
type = relOpExcludeTypeStructSymbol(symbol = "b"), substeps = emptyList()
133145
)
134146
)
135147
)
@@ -150,19 +162,16 @@ class SubsumptionTest {
150162
root = rexOpVar(1),
151163
steps = listOf(
152164
relOpExcludeStep(
153-
type = relOpExcludeTypeStructSymbol(symbol = "a"),
154-
substeps = emptyList()
165+
type = relOpExcludeTypeStructSymbol(symbol = "a"), substeps = emptyList()
155166
),
156167
relOpExcludeStep(
157-
type = relOpExcludeTypeStructSymbol(symbol = "b"),
158-
substeps = emptyList()
168+
type = relOpExcludeTypeStructSymbol(symbol = "b"), substeps = emptyList()
159169
),
160170
relOpExcludeStep(
161171
type = relOpExcludeTypeStructSymbol(symbol = "c"),
162172
substeps = listOf(
163173
relOpExcludeStep(
164-
type = relOpExcludeTypeStructWildcard(),
165-
substeps = emptyList()
174+
type = relOpExcludeTypeStructWildcard(), substeps = emptyList()
166175
)
167176
)
168177
),
@@ -189,26 +198,23 @@ class SubsumptionTest {
189198
type = relOpExcludeTypeStructSymbol(symbol = "g"),
190199
substeps = listOf(
191200
relOpExcludeStep(
192-
type = relOpExcludeTypeCollWildcard(),
193-
substeps = emptyList()
201+
type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
194202
)
195203
)
196204
),
197205
relOpExcludeStep(
198206
type = relOpExcludeTypeStructSymbol(symbol = "h"),
199207
substeps = listOf(
200208
relOpExcludeStep(
201-
type = relOpExcludeTypeCollIndex(index = 1),
202-
substeps = emptyList()
209+
type = relOpExcludeTypeCollIndex(index = 1), substeps = emptyList()
203210
)
204211
)
205212
),
206213
relOpExcludeStep(
207214
type = relOpExcludeTypeStructSymbol(symbol = "i"),
208215
substeps = listOf(
209216
relOpExcludeStep(
210-
type = relOpExcludeTypeStructKey(key = "j"),
211-
substeps = emptyList()
217+
type = relOpExcludeTypeStructKey(key = "j"), substeps = emptyList()
212218
)
213219
)
214220
),
@@ -234,12 +240,10 @@ class SubsumptionTest {
234240
root = rexOpVar(1),
235241
steps = listOf(
236242
relOpExcludeStep(
237-
type = relOpExcludeTypeStructSymbol(symbol = "a"),
238-
substeps = emptyList()
243+
type = relOpExcludeTypeStructSymbol(symbol = "a"), substeps = emptyList()
239244
),
240245
relOpExcludeStep(
241-
type = relOpExcludeTypeStructSymbol(symbol = "b"),
242-
substeps = emptyList()
246+
type = relOpExcludeTypeStructSymbol(symbol = "b"), substeps = emptyList()
243247
),
244248
relOpExcludeStep(
245249
type = relOpExcludeTypeStructSymbol(symbol = "c"),
@@ -273,45 +277,39 @@ class SubsumptionTest {
273277
type = relOpExcludeTypeStructSymbol(symbol = "e"),
274278
substeps = listOf(
275279
relOpExcludeStep(
276-
type = relOpExcludeTypeCollIndex(index = 1),
277-
substeps = emptyList()
280+
type = relOpExcludeTypeCollIndex(index = 1), substeps = emptyList()
278281
)
279282
)
280283
),
281284
relOpExcludeStep(
282285
type = relOpExcludeTypeStructSymbol(symbol = "f"),
283286
substeps = listOf(
284287
relOpExcludeStep(
285-
type = relOpExcludeTypeCollIndex(index = 1),
286-
substeps = emptyList()
288+
type = relOpExcludeTypeCollIndex(index = 1), substeps = emptyList()
287289
)
288290
)
289291
),
290292
relOpExcludeStep(
291293
type = relOpExcludeTypeStructSymbol(symbol = "g"),
292294
substeps = listOf(
293295
relOpExcludeStep(
294-
type = relOpExcludeTypeCollWildcard(),
295-
substeps = emptyList()
296+
type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
296297
)
297298
)
298299
),
299300
relOpExcludeStep(
300301
type = relOpExcludeTypeStructSymbol(symbol = "h"),
301302
substeps = listOf(
302303
relOpExcludeStep(
303-
type = relOpExcludeTypeCollWildcard(),
304-
substeps = emptyList()
304+
type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
305305
)
306306
)
307307
),
308308
relOpExcludeStep(
309-
type = relOpExcludeTypeStructKey(key = "i"),
310-
substeps = emptyList()
309+
type = relOpExcludeTypeStructKey(key = "i"), substeps = emptyList()
311310
),
312311
relOpExcludeStep(
313-
type = relOpExcludeTypeStructKey(key = "j"),
314-
substeps = emptyList()
312+
type = relOpExcludeTypeStructKey(key = "j"), substeps = emptyList()
315313
),
316314
)
317315
),
@@ -330,17 +328,15 @@ class SubsumptionTest {
330328
type = relOpExcludeTypeStructSymbol(symbol = "a"),
331329
substeps = listOf(
332330
relOpExcludeStep(
333-
type = relOpExcludeTypeStructWildcard(),
334-
substeps = emptyList()
331+
type = relOpExcludeTypeStructWildcard(), substeps = emptyList()
335332
)
336333
)
337334
),
338335
relOpExcludeStep(
339336
type = relOpExcludeTypeStructKey(key = "b"),
340337
substeps = listOf(
341338
relOpExcludeStep(
342-
type = relOpExcludeTypeStructWildcard(),
343-
substeps = emptyList()
339+
type = relOpExcludeTypeStructWildcard(), substeps = emptyList()
344340
)
345341
)
346342
),
@@ -361,8 +357,7 @@ class SubsumptionTest {
361357
type = relOpExcludeTypeStructSymbol(symbol = "a"),
362358
substeps = listOf(
363359
relOpExcludeStep(
364-
type = relOpExcludeTypeCollWildcard(),
365-
substeps = emptyList()
360+
type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
366361
)
367362
)
368363
),
@@ -373,8 +368,7 @@ class SubsumptionTest {
373368
type = relOpExcludeTypeStructKey(key = "b1"),
374369
substeps = listOf(
375370
relOpExcludeStep(
376-
type = relOpExcludeTypeCollWildcard(),
377-
substeps = emptyList()
371+
type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
378372
)
379373
)
380374
)
@@ -394,15 +388,13 @@ class SubsumptionTest {
394388
root = rexOpVar(1),
395389
steps = listOf(
396390
relOpExcludeStep(
397-
type = relOpExcludeTypeStructSymbol(symbol = "foo"),
398-
substeps = emptyList()
391+
type = relOpExcludeTypeStructSymbol(symbol = "foo"), substeps = emptyList()
399392
),
400393
relOpExcludeStep(
401394
type = relOpExcludeTypeStructKey(key = "bAr"),
402395
substeps = listOf(
403396
relOpExcludeStep(
404-
type = relOpExcludeTypeStructSymbol(symbol = "baz"),
405-
substeps = emptyList()
397+
type = relOpExcludeTypeStructSymbol(symbol = "baz"), substeps = emptyList()
406398
)
407399
)
408400
),
@@ -587,28 +579,22 @@ class SubsumptionTest {
587579
root = rexOpVar(1),
588580
steps = listOf(
589581
relOpExcludeStep(
590-
type = relOpExcludeTypeStructSymbol(symbol = "a"),
591-
substeps = emptyList()
582+
type = relOpExcludeTypeStructSymbol(symbol = "a"), substeps = emptyList()
592583
),
593584
relOpExcludeStep(
594-
type = relOpExcludeTypeStructSymbol(symbol = "b"),
595-
substeps = emptyList()
585+
type = relOpExcludeTypeStructSymbol(symbol = "b"), substeps = emptyList()
596586
),
597587
relOpExcludeStep(
598-
type = relOpExcludeTypeStructSymbol(symbol = "c"),
599-
substeps = emptyList()
588+
type = relOpExcludeTypeStructSymbol(symbol = "c"), substeps = emptyList()
600589
),
601590
relOpExcludeStep(
602-
type = relOpExcludeTypeStructSymbol(symbol = "d"),
603-
substeps = emptyList()
591+
type = relOpExcludeTypeStructSymbol(symbol = "d"), substeps = emptyList()
604592
),
605593
relOpExcludeStep(
606-
type = relOpExcludeTypeStructSymbol(symbol = "e"),
607-
substeps = emptyList()
594+
type = relOpExcludeTypeStructSymbol(symbol = "e"), substeps = emptyList()
608595
),
609596
relOpExcludeStep(
610-
type = relOpExcludeTypeStructKey(key = "f"),
611-
substeps = emptyList()
597+
type = relOpExcludeTypeStructKey(key = "f"), substeps = emptyList()
612598
),
613599
)
614600
),

0 commit comments

Comments
 (0)