@@ -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
),
@@ -2707,7 +2719,7 @@ class PlanTyperTestsPorted {
2707
2719
problemHandler = assertProblemExists {
2708
2720
Problem (
2709
2721
UNKNOWN_PROBLEM_LOCATION ,
2710
- PlanningProblemDetails .UndefinedVariable (" main" , true )
2722
+ PlanningProblemDetails .UndefinedVariable (id(sensitive( " pql " ), sensitive( " main" )), setOf () )
2711
2723
)
2712
2724
}
2713
2725
),
@@ -2720,7 +2732,7 @@ class PlanTyperTestsPorted {
2720
2732
problemHandler = assertProblemExists {
2721
2733
Problem (
2722
2734
UNKNOWN_PROBLEM_LOCATION ,
2723
- PlanningProblemDetails .UndefinedVariable (" pql" , true )
2735
+ PlanningProblemDetails .UndefinedVariable (sensitive( " pql" ), setOf () )
2724
2736
)
2725
2737
}
2726
2738
),
@@ -2964,27 +2976,28 @@ class PlanTyperTestsPorted {
2964
2976
SuccessTestCase (
2965
2977
name = " AGGREGATE over nullable integers" ,
2966
2978
query = """
2967
- SELECT
2968
- COUNT(a) AS count_a
2969
- FROM <<
2970
- { 'a': 1, 'b': 2 }
2971
- >> t1 INNER JOIN <<
2972
- { 'c': 1, 'd': 3 }
2973
- >> t2
2974
- ON t1.a = t1.c
2975
- AND (
2976
- 1 = (
2977
- SELECT COUNT(e) AS count_e
2978
- FROM <<
2979
- { 'e': 10 }
2980
- >> t3
2979
+ SELECT T1.a
2980
+ FROM T1
2981
+ LEFT JOIN T2 AS T2_1
2982
+ ON T2_1.d =
2983
+ (
2984
+ SELECT
2985
+ CASE WHEN COUNT(f) = 1 THEN MAX(f) ELSE 0 END AS e
2986
+ FROM T3 AS T3_mapping
2981
2987
)
2982
- );
2988
+ LEFT JOIN T2 AS T2_2
2989
+ ON T2_2.d =
2990
+ (
2991
+ SELECT
2992
+ CASE WHEN COUNT(f) = 1 THEN MAX(f) ELSE 0 END AS e
2993
+ FROM T3 AS T3_mapping
2994
+ )
2995
+ ;
2983
2996
""" .trimIndent(),
2984
2997
expected = BagType (
2985
2998
StructType (
2986
2999
fields = mapOf (
2987
- " count_a " to StaticType .INT8
3000
+ " a " to StaticType .BOOL
2988
3001
),
2989
3002
contentClosed = true ,
2990
3003
constraints = setOf (
@@ -2993,8 +3006,9 @@ class PlanTyperTestsPorted {
2993
3006
TupleConstraint .Ordered
2994
3007
)
2995
3008
)
2996
- )
2997
- ),
3009
+ ),
3010
+ catalog = " aggregations"
3011
+ )
2998
3012
)
2999
3013
3000
3014
@JvmStatic
@@ -3246,47 +3260,6 @@ class PlanTyperTestsPorted {
3246
3260
// Parameterized Tests
3247
3261
//
3248
3262
3249
- @Test
3250
- fun failingAggTest () {
3251
- val tc = SuccessTestCase (
3252
- name = " AGGREGATE over nullable integers" ,
3253
- query = """
3254
- SELECT T1.a
3255
- FROM T1
3256
- LEFT JOIN T2 AS T2_1
3257
- ON T2_1.d =
3258
- (
3259
- SELECT
3260
- CASE WHEN COUNT(f) = 1 THEN MAX(f) ELSE 0 END AS e
3261
- FROM T3 AS T3_mapping
3262
- )
3263
- LEFT JOIN T2 AS T2_2
3264
- ON T2_2.d =
3265
- (
3266
- SELECT
3267
- CASE WHEN COUNT(f) = 1 THEN MAX(f) ELSE 0 END AS e
3268
- FROM T3 AS T3_mapping
3269
- )
3270
- ;
3271
- """ .trimIndent(),
3272
- expected = BagType (
3273
- StructType (
3274
- fields = mapOf (
3275
- " a" to StaticType .BOOL
3276
- ),
3277
- contentClosed = true ,
3278
- constraints = setOf (
3279
- TupleConstraint .Open (false ),
3280
- TupleConstraint .UniqueAttrs (true ),
3281
- TupleConstraint .Ordered
3282
- )
3283
- )
3284
- ),
3285
- catalog = " aggregations"
3286
- )
3287
- runTest(tc)
3288
- }
3289
-
3290
3263
@Test
3291
3264
@Disabled(" The planner doesn't support heterogeneous input to aggregation functions (yet?)." )
3292
3265
fun failingTest () {
@@ -3601,7 +3574,7 @@ class PlanTyperTestsPorted {
3601
3574
problemHandler = assertProblemExists {
3602
3575
Problem (
3603
3576
UNKNOWN_PROBLEM_LOCATION ,
3604
- PlanningProblemDetails .UndefinedVariable (" pets" , false )
3577
+ PlanningProblemDetails .UndefinedVariable (insensitive( " pets" ), emptySet() )
3605
3578
)
3606
3579
}
3607
3580
),
@@ -3634,7 +3607,7 @@ class PlanTyperTestsPorted {
3634
3607
problemHandler = assertProblemExists {
3635
3608
Problem (
3636
3609
UNKNOWN_PROBLEM_LOCATION ,
3637
- PlanningProblemDetails .UndefinedVariable (" pets" , false )
3610
+ PlanningProblemDetails .UndefinedVariable (insensitive( " pets" ), emptySet() )
3638
3611
)
3639
3612
}
3640
3613
),
@@ -3701,7 +3674,7 @@ class PlanTyperTestsPorted {
3701
3674
problemHandler = assertProblemExists {
3702
3675
Problem (
3703
3676
UNKNOWN_PROBLEM_LOCATION ,
3704
- PlanningProblemDetails .UndefinedVariable (" pets" , false )
3677
+ PlanningProblemDetails .UndefinedVariable (id(insensitive( " ddb " ), insensitive( " pets" )), emptySet() )
3705
3678
)
3706
3679
}
3707
3680
),
@@ -3971,7 +3944,7 @@ class PlanTyperTestsPorted {
3971
3944
problemHandler = assertProblemExists {
3972
3945
Problem (
3973
3946
UNKNOWN_PROBLEM_LOCATION ,
3974
- PlanningProblemDetails .UndefinedVariable (" non_existing_column" , false )
3947
+ PlanningProblemDetails .UndefinedVariable (insensitive( " non_existing_column" ), emptySet() )
3975
3948
)
3976
3949
}
3977
3950
),
@@ -4026,7 +3999,7 @@ class PlanTyperTestsPorted {
4026
3999
problemHandler = assertProblemExists {
4027
4000
Problem (
4028
4001
UNKNOWN_PROBLEM_LOCATION ,
4029
- PlanningProblemDetails .UndefinedVariable (" unknown_col" , false )
4002
+ PlanningProblemDetails .UndefinedVariable (insensitive( " unknown_col" ), setOf ( " orders " ) )
4030
4003
)
4031
4004
}
4032
4005
),
0 commit comments