@@ -20,12 +20,23 @@ import org.partiql.plan.relOpExcludeTypeStructSymbol
20
20
import org.partiql.plan.relOpExcludeTypeStructWildcard
21
21
import org.partiql.plan.rexOpVar
22
22
import org.partiql.planner.PartiQLPlanner
23
+ import org.partiql.plugins.memory.MemoryConnector
24
+ import org.partiql.spi.connector.ConnectorSession
23
25
import java.util.stream.Stream
24
26
import kotlin.test.assertEquals
25
27
26
28
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
+ }
29
40
30
41
private fun getExcludeClause (statement : Statement ): Rel .Op .Exclude {
31
42
val queryExpr = (statement as Statement .Query ).root
@@ -36,7 +47,12 @@ class SubsumptionTest {
36
47
private fun testExcludeExprSubsumption (tc : SubsumptionTC ) {
37
48
val text = " SELECT * EXCLUDE ${tc.excludeExprStr} FROM <<>> AS s, <<>> AS t;"
38
49
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
+ )
40
56
val plan = planner.plan(statement, session).plan
41
57
val excludeClause = getExcludeClause(plan.statement).paths
42
58
assertEquals(tc.expectedExcludeExprs, excludeClause)
@@ -111,25 +127,21 @@ class SubsumptionTest {
111
127
root = rexOpVar(0 ),
112
128
steps = listOf (
113
129
relOpExcludeStep(
114
- type = relOpExcludeTypeStructSymbol(symbol = " a" ),
115
- substeps = emptyList()
130
+ type = relOpExcludeTypeStructSymbol(symbol = " a" ), substeps = emptyList()
116
131
),
117
132
relOpExcludeStep(
118
- type = relOpExcludeTypeStructSymbol(symbol = " b" ),
119
- substeps = emptyList()
133
+ type = relOpExcludeTypeStructSymbol(symbol = " b" ), substeps = emptyList()
120
134
)
121
135
)
122
136
),
123
137
relOpExcludePath(
124
138
root = rexOpVar(1 ),
125
139
steps = listOf (
126
140
relOpExcludeStep(
127
- type = relOpExcludeTypeStructSymbol(symbol = " a" ),
128
- substeps = emptyList()
141
+ type = relOpExcludeTypeStructSymbol(symbol = " a" ), substeps = emptyList()
129
142
),
130
143
relOpExcludeStep(
131
- type = relOpExcludeTypeStructSymbol(symbol = " b" ),
132
- substeps = emptyList()
144
+ type = relOpExcludeTypeStructSymbol(symbol = " b" ), substeps = emptyList()
133
145
)
134
146
)
135
147
)
@@ -150,19 +162,16 @@ class SubsumptionTest {
150
162
root = rexOpVar(1 ),
151
163
steps = listOf (
152
164
relOpExcludeStep(
153
- type = relOpExcludeTypeStructSymbol(symbol = " a" ),
154
- substeps = emptyList()
165
+ type = relOpExcludeTypeStructSymbol(symbol = " a" ), substeps = emptyList()
155
166
),
156
167
relOpExcludeStep(
157
- type = relOpExcludeTypeStructSymbol(symbol = " b" ),
158
- substeps = emptyList()
168
+ type = relOpExcludeTypeStructSymbol(symbol = " b" ), substeps = emptyList()
159
169
),
160
170
relOpExcludeStep(
161
171
type = relOpExcludeTypeStructSymbol(symbol = " c" ),
162
172
substeps = listOf (
163
173
relOpExcludeStep(
164
- type = relOpExcludeTypeStructWildcard(),
165
- substeps = emptyList()
174
+ type = relOpExcludeTypeStructWildcard(), substeps = emptyList()
166
175
)
167
176
)
168
177
),
@@ -189,26 +198,23 @@ class SubsumptionTest {
189
198
type = relOpExcludeTypeStructSymbol(symbol = " g" ),
190
199
substeps = listOf (
191
200
relOpExcludeStep(
192
- type = relOpExcludeTypeCollWildcard(),
193
- substeps = emptyList()
201
+ type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
194
202
)
195
203
)
196
204
),
197
205
relOpExcludeStep(
198
206
type = relOpExcludeTypeStructSymbol(symbol = " h" ),
199
207
substeps = listOf (
200
208
relOpExcludeStep(
201
- type = relOpExcludeTypeCollIndex(index = 1 ),
202
- substeps = emptyList()
209
+ type = relOpExcludeTypeCollIndex(index = 1 ), substeps = emptyList()
203
210
)
204
211
)
205
212
),
206
213
relOpExcludeStep(
207
214
type = relOpExcludeTypeStructSymbol(symbol = " i" ),
208
215
substeps = listOf (
209
216
relOpExcludeStep(
210
- type = relOpExcludeTypeStructKey(key = " j" ),
211
- substeps = emptyList()
217
+ type = relOpExcludeTypeStructKey(key = " j" ), substeps = emptyList()
212
218
)
213
219
)
214
220
),
@@ -234,12 +240,10 @@ class SubsumptionTest {
234
240
root = rexOpVar(1 ),
235
241
steps = listOf (
236
242
relOpExcludeStep(
237
- type = relOpExcludeTypeStructSymbol(symbol = " a" ),
238
- substeps = emptyList()
243
+ type = relOpExcludeTypeStructSymbol(symbol = " a" ), substeps = emptyList()
239
244
),
240
245
relOpExcludeStep(
241
- type = relOpExcludeTypeStructSymbol(symbol = " b" ),
242
- substeps = emptyList()
246
+ type = relOpExcludeTypeStructSymbol(symbol = " b" ), substeps = emptyList()
243
247
),
244
248
relOpExcludeStep(
245
249
type = relOpExcludeTypeStructSymbol(symbol = " c" ),
@@ -273,45 +277,39 @@ class SubsumptionTest {
273
277
type = relOpExcludeTypeStructSymbol(symbol = " e" ),
274
278
substeps = listOf (
275
279
relOpExcludeStep(
276
- type = relOpExcludeTypeCollIndex(index = 1 ),
277
- substeps = emptyList()
280
+ type = relOpExcludeTypeCollIndex(index = 1 ), substeps = emptyList()
278
281
)
279
282
)
280
283
),
281
284
relOpExcludeStep(
282
285
type = relOpExcludeTypeStructSymbol(symbol = " f" ),
283
286
substeps = listOf (
284
287
relOpExcludeStep(
285
- type = relOpExcludeTypeCollIndex(index = 1 ),
286
- substeps = emptyList()
288
+ type = relOpExcludeTypeCollIndex(index = 1 ), substeps = emptyList()
287
289
)
288
290
)
289
291
),
290
292
relOpExcludeStep(
291
293
type = relOpExcludeTypeStructSymbol(symbol = " g" ),
292
294
substeps = listOf (
293
295
relOpExcludeStep(
294
- type = relOpExcludeTypeCollWildcard(),
295
- substeps = emptyList()
296
+ type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
296
297
)
297
298
)
298
299
),
299
300
relOpExcludeStep(
300
301
type = relOpExcludeTypeStructSymbol(symbol = " h" ),
301
302
substeps = listOf (
302
303
relOpExcludeStep(
303
- type = relOpExcludeTypeCollWildcard(),
304
- substeps = emptyList()
304
+ type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
305
305
)
306
306
)
307
307
),
308
308
relOpExcludeStep(
309
- type = relOpExcludeTypeStructKey(key = " i" ),
310
- substeps = emptyList()
309
+ type = relOpExcludeTypeStructKey(key = " i" ), substeps = emptyList()
311
310
),
312
311
relOpExcludeStep(
313
- type = relOpExcludeTypeStructKey(key = " j" ),
314
- substeps = emptyList()
312
+ type = relOpExcludeTypeStructKey(key = " j" ), substeps = emptyList()
315
313
),
316
314
)
317
315
),
@@ -330,17 +328,15 @@ class SubsumptionTest {
330
328
type = relOpExcludeTypeStructSymbol(symbol = " a" ),
331
329
substeps = listOf (
332
330
relOpExcludeStep(
333
- type = relOpExcludeTypeStructWildcard(),
334
- substeps = emptyList()
331
+ type = relOpExcludeTypeStructWildcard(), substeps = emptyList()
335
332
)
336
333
)
337
334
),
338
335
relOpExcludeStep(
339
336
type = relOpExcludeTypeStructKey(key = " b" ),
340
337
substeps = listOf (
341
338
relOpExcludeStep(
342
- type = relOpExcludeTypeStructWildcard(),
343
- substeps = emptyList()
339
+ type = relOpExcludeTypeStructWildcard(), substeps = emptyList()
344
340
)
345
341
)
346
342
),
@@ -361,8 +357,7 @@ class SubsumptionTest {
361
357
type = relOpExcludeTypeStructSymbol(symbol = " a" ),
362
358
substeps = listOf (
363
359
relOpExcludeStep(
364
- type = relOpExcludeTypeCollWildcard(),
365
- substeps = emptyList()
360
+ type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
366
361
)
367
362
)
368
363
),
@@ -373,8 +368,7 @@ class SubsumptionTest {
373
368
type = relOpExcludeTypeStructKey(key = " b1" ),
374
369
substeps = listOf (
375
370
relOpExcludeStep(
376
- type = relOpExcludeTypeCollWildcard(),
377
- substeps = emptyList()
371
+ type = relOpExcludeTypeCollWildcard(), substeps = emptyList()
378
372
)
379
373
)
380
374
)
@@ -394,15 +388,13 @@ class SubsumptionTest {
394
388
root = rexOpVar(1 ),
395
389
steps = listOf (
396
390
relOpExcludeStep(
397
- type = relOpExcludeTypeStructSymbol(symbol = " foo" ),
398
- substeps = emptyList()
391
+ type = relOpExcludeTypeStructSymbol(symbol = " foo" ), substeps = emptyList()
399
392
),
400
393
relOpExcludeStep(
401
394
type = relOpExcludeTypeStructKey(key = " bAr" ),
402
395
substeps = listOf (
403
396
relOpExcludeStep(
404
- type = relOpExcludeTypeStructSymbol(symbol = " baz" ),
405
- substeps = emptyList()
397
+ type = relOpExcludeTypeStructSymbol(symbol = " baz" ), substeps = emptyList()
406
398
)
407
399
)
408
400
),
@@ -587,28 +579,22 @@ class SubsumptionTest {
587
579
root = rexOpVar(1 ),
588
580
steps = listOf (
589
581
relOpExcludeStep(
590
- type = relOpExcludeTypeStructSymbol(symbol = " a" ),
591
- substeps = emptyList()
582
+ type = relOpExcludeTypeStructSymbol(symbol = " a" ), substeps = emptyList()
592
583
),
593
584
relOpExcludeStep(
594
- type = relOpExcludeTypeStructSymbol(symbol = " b" ),
595
- substeps = emptyList()
585
+ type = relOpExcludeTypeStructSymbol(symbol = " b" ), substeps = emptyList()
596
586
),
597
587
relOpExcludeStep(
598
- type = relOpExcludeTypeStructSymbol(symbol = " c" ),
599
- substeps = emptyList()
588
+ type = relOpExcludeTypeStructSymbol(symbol = " c" ), substeps = emptyList()
600
589
),
601
590
relOpExcludeStep(
602
- type = relOpExcludeTypeStructSymbol(symbol = " d" ),
603
- substeps = emptyList()
591
+ type = relOpExcludeTypeStructSymbol(symbol = " d" ), substeps = emptyList()
604
592
),
605
593
relOpExcludeStep(
606
- type = relOpExcludeTypeStructSymbol(symbol = " e" ),
607
- substeps = emptyList()
594
+ type = relOpExcludeTypeStructSymbol(symbol = " e" ), substeps = emptyList()
608
595
),
609
596
relOpExcludeStep(
610
- type = relOpExcludeTypeStructKey(key = " f" ),
611
- substeps = emptyList()
597
+ type = relOpExcludeTypeStructKey(key = " f" ), substeps = emptyList()
612
598
),
613
599
)
614
600
),
0 commit comments