@@ -15,6 +15,7 @@ import org.junit.jupiter.params.provider.MethodSource
15
15
import org.partiql.errors.Problem
16
16
import org.partiql.errors.UNKNOWN_PROBLEM_LOCATION
17
17
import org.partiql.parser.PartiQLParser
18
+ import org.partiql.plan.Identifier
18
19
import org.partiql.plan.PartiQLPlan
19
20
import org.partiql.plan.Statement
20
21
import org.partiql.plan.debug.PlanPrinter
@@ -104,6 +105,18 @@ class PlanTyperTestsPorted {
104
105
}
105
106
}
106
107
108
+ private fun id (vararg parts : Identifier .Symbol ): Identifier {
109
+ return when (parts.size) {
110
+ 0 -> error(" Identifier requires more than one part." )
111
+ 1 -> parts.first()
112
+ else -> Identifier .Qualified (parts.first(), parts.drop(1 ))
113
+ }
114
+ }
115
+
116
+ private fun sensitive (part : String ): Identifier .Symbol = Identifier .Symbol (part, Identifier .CaseSensitivity .SENSITIVE )
117
+
118
+ private fun insensitive (part : String ): Identifier .Symbol = Identifier .Symbol (part, Identifier .CaseSensitivity .INSENSITIVE )
119
+
107
120
/* *
108
121
* MemoryConnector.Factory from reading the resources in /resource_path.txt for Github CI/CD.
109
122
*/
@@ -131,7 +144,6 @@ class PlanTyperTestsPorted {
131
144
}
132
145
}
133
146
map.entries.map {
134
- println (" Map Entry: ${it.key} to ${it.value} " )
135
147
it.key to MemoryConnector .Metadata .of(* it.value.toTypedArray())
136
148
}
137
149
}
@@ -805,7 +817,7 @@ class PlanTyperTestsPorted {
805
817
problemHandler = assertProblemExists {
806
818
Problem (
807
819
UNKNOWN_PROBLEM_LOCATION ,
808
- PlanningProblemDetails .UndefinedVariable (" a" , false )
820
+ PlanningProblemDetails .UndefinedVariable (insensitive( " a" ), setOf ( " t1 " , " t2 " ) )
809
821
)
810
822
}
811
823
),
@@ -2022,7 +2034,7 @@ class PlanTyperTestsPorted {
2022
2034
problemHandler = assertProblemExists {
2023
2035
Problem (
2024
2036
UNKNOWN_PROBLEM_LOCATION ,
2025
- PlanningProblemDetails .UndefinedVariable (" unknown_col" , false )
2037
+ PlanningProblemDetails .UndefinedVariable (insensitive( " unknown_col" ), setOf ( " pets " ) )
2026
2038
)
2027
2039
}
2028
2040
),
@@ -2920,7 +2932,7 @@ class PlanTyperTestsPorted {
2920
2932
problemHandler = assertProblemExists {
2921
2933
Problem (
2922
2934
UNKNOWN_PROBLEM_LOCATION ,
2923
- PlanningProblemDetails .UndefinedVariable (" main" , true )
2935
+ PlanningProblemDetails .UndefinedVariable (id(sensitive( " pql " ), sensitive( " main" )), setOf () )
2924
2936
)
2925
2937
}
2926
2938
),
@@ -2933,7 +2945,7 @@ class PlanTyperTestsPorted {
2933
2945
problemHandler = assertProblemExists {
2934
2946
Problem (
2935
2947
UNKNOWN_PROBLEM_LOCATION ,
2936
- PlanningProblemDetails .UndefinedVariable (" pql" , true )
2948
+ PlanningProblemDetails .UndefinedVariable (sensitive( " pql" ), setOf () )
2937
2949
)
2938
2950
}
2939
2951
),
@@ -3177,27 +3189,28 @@ class PlanTyperTestsPorted {
3177
3189
SuccessTestCase (
3178
3190
name = " AGGREGATE over nullable integers" ,
3179
3191
query = """
3180
- SELECT
3181
- COUNT(a) AS count_a
3182
- FROM <<
3183
- { 'a': 1, 'b': 2 }
3184
- >> t1 INNER JOIN <<
3185
- { 'c': 1, 'd': 3 }
3186
- >> t2
3187
- ON t1.a = t1.c
3188
- AND (
3189
- 1 = (
3190
- SELECT COUNT(e) AS count_e
3191
- FROM <<
3192
- { 'e': 10 }
3193
- >> t3
3192
+ SELECT T1.a
3193
+ FROM T1
3194
+ LEFT JOIN T2 AS T2_1
3195
+ ON T2_1.d =
3196
+ (
3197
+ SELECT
3198
+ CASE WHEN COUNT(f) = 1 THEN MAX(f) ELSE 0 END AS e
3199
+ FROM T3 AS T3_mapping
3194
3200
)
3195
- );
3201
+ LEFT JOIN T2 AS T2_2
3202
+ ON T2_2.d =
3203
+ (
3204
+ SELECT
3205
+ CASE WHEN COUNT(f) = 1 THEN MAX(f) ELSE 0 END AS e
3206
+ FROM T3 AS T3_mapping
3207
+ )
3208
+ ;
3196
3209
""" .trimIndent(),
3197
3210
expected = BagType (
3198
3211
StructType (
3199
3212
fields = mapOf (
3200
- " count_a " to StaticType .INT8
3213
+ " a " to StaticType .BOOL
3201
3214
),
3202
3215
contentClosed = true ,
3203
3216
constraints = setOf (
@@ -3206,8 +3219,9 @@ class PlanTyperTestsPorted {
3206
3219
TupleConstraint .Ordered
3207
3220
)
3208
3221
)
3209
- )
3210
- ),
3222
+ ),
3223
+ catalog = " aggregations"
3224
+ )
3211
3225
)
3212
3226
3213
3227
@JvmStatic
@@ -3459,47 +3473,6 @@ class PlanTyperTestsPorted {
3459
3473
// Parameterized Tests
3460
3474
//
3461
3475
3462
- @Test
3463
- fun failingAggTest () {
3464
- val tc = SuccessTestCase (
3465
- name = " AGGREGATE over nullable integers" ,
3466
- query = """
3467
- SELECT T1.a
3468
- FROM T1
3469
- LEFT JOIN T2 AS T2_1
3470
- ON T2_1.d =
3471
- (
3472
- SELECT
3473
- CASE WHEN COUNT(f) = 1 THEN MAX(f) ELSE 0 END AS e
3474
- FROM T3 AS T3_mapping
3475
- )
3476
- LEFT JOIN T2 AS T2_2
3477
- ON T2_2.d =
3478
- (
3479
- SELECT
3480
- CASE WHEN COUNT(f) = 1 THEN MAX(f) ELSE 0 END AS e
3481
- FROM T3 AS T3_mapping
3482
- )
3483
- ;
3484
- """ .trimIndent(),
3485
- expected = BagType (
3486
- StructType (
3487
- fields = mapOf (
3488
- " a" to StaticType .BOOL
3489
- ),
3490
- contentClosed = true ,
3491
- constraints = setOf (
3492
- TupleConstraint .Open (false ),
3493
- TupleConstraint .UniqueAttrs (true ),
3494
- TupleConstraint .Ordered
3495
- )
3496
- )
3497
- ),
3498
- catalog = " aggregations"
3499
- )
3500
- runTest(tc)
3501
- }
3502
-
3503
3476
@Test
3504
3477
@Disabled(" The planner doesn't support heterogeneous input to aggregation functions (yet?)." )
3505
3478
fun failingTest () {
@@ -3824,7 +3797,7 @@ class PlanTyperTestsPorted {
3824
3797
problemHandler = assertProblemExists {
3825
3798
Problem (
3826
3799
UNKNOWN_PROBLEM_LOCATION ,
3827
- PlanningProblemDetails .UndefinedVariable (" pets" , false )
3800
+ PlanningProblemDetails .UndefinedVariable (insensitive( " pets" ), emptySet() )
3828
3801
)
3829
3802
}
3830
3803
),
@@ -3857,7 +3830,7 @@ class PlanTyperTestsPorted {
3857
3830
problemHandler = assertProblemExists {
3858
3831
Problem (
3859
3832
UNKNOWN_PROBLEM_LOCATION ,
3860
- PlanningProblemDetails .UndefinedVariable (" pets" , false )
3833
+ PlanningProblemDetails .UndefinedVariable (insensitive( " pets" ), emptySet() )
3861
3834
)
3862
3835
}
3863
3836
),
@@ -3924,7 +3897,7 @@ class PlanTyperTestsPorted {
3924
3897
problemHandler = assertProblemExists {
3925
3898
Problem (
3926
3899
UNKNOWN_PROBLEM_LOCATION ,
3927
- PlanningProblemDetails .UndefinedVariable (" pets" , false )
3900
+ PlanningProblemDetails .UndefinedVariable (id(insensitive( " ddb " ), insensitive( " pets" )), emptySet() )
3928
3901
)
3929
3902
}
3930
3903
),
@@ -4194,7 +4167,7 @@ class PlanTyperTestsPorted {
4194
4167
problemHandler = assertProblemExists {
4195
4168
Problem (
4196
4169
UNKNOWN_PROBLEM_LOCATION ,
4197
- PlanningProblemDetails .UndefinedVariable (" non_existing_column" , false )
4170
+ PlanningProblemDetails .UndefinedVariable (insensitive( " non_existing_column" ), emptySet() )
4198
4171
)
4199
4172
}
4200
4173
),
@@ -4249,7 +4222,7 @@ class PlanTyperTestsPorted {
4249
4222
problemHandler = assertProblemExists {
4250
4223
Problem (
4251
4224
UNKNOWN_PROBLEM_LOCATION ,
4252
- PlanningProblemDetails .UndefinedVariable (" unknown_col" , false )
4225
+ PlanningProblemDetails .UndefinedVariable (insensitive( " unknown_col" ), setOf ( " orders " ) )
4253
4226
)
4254
4227
}
4255
4228
),
0 commit comments