diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PartiQLHeader.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PartiQLHeader.kt index 38d851d94a..24e5e22bff 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PartiQLHeader.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PartiQLHeader.kt @@ -411,8 +411,8 @@ internal object PartiQLHeader : Header() { parameters = listOf( FunctionParameter("value", ANY) ), - isNullCall = false, // TODO: Should this be true? - isNullable = false + isNullable = false, + isNullCall = false, ) } @@ -427,7 +427,7 @@ internal object PartiQLHeader : Header() { FunctionParameter("type_parameter_1", INT32), FunctionParameter("value", ANY) ), - isNullable = false, // TODO: Should this be true? + isNullable = false, isNullCall = false ) } @@ -455,8 +455,8 @@ internal object PartiQLHeader : Header() { FunctionParameter("type_parameter_2", INT32), FunctionParameter("value", ANY) // TODO: Decide if we need to further segment this ), - isNullCall = false, - isNullable = false + isNullable = false, + isNullCall = false ) } diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt index f88852c3c0..0f7b548c92 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt @@ -388,6 +388,66 @@ class PlanTyperTestsPorted { ), ) + @JvmStatic + fun isTypeCases() = listOf( + SuccessTestCase( + name = "IS BOOL", + key = key("is-type-00"), + catalog = "pql", + catalogPath = listOf("main"), + expected = StaticType.BOOL + ), + SuccessTestCase( + name = "IS INT", + key = key("is-type-01"), + catalog = "pql", + catalogPath = listOf("main"), + expected = StaticType.BOOL + ), + SuccessTestCase( + name = "IS STRING", + key = key("is-type-02"), + catalog = "pql", + catalogPath = listOf("main"), + expected = StaticType.BOOL + ), + SuccessTestCase( + name = "IS NULL", + key = key("is-type-03"), + catalog = "pql", + expected = StaticType.BOOL, + ), + SuccessTestCase( + name = "MISSING IS NULL", + key = key("is-type-04"), + catalog = "pql", + expected = StaticType.BOOL, + ), + SuccessTestCase( + name = "NULL IS NULL", + key = key("is-type-05"), + catalog = "pql", + expected = StaticType.BOOL, + ), + SuccessTestCase( + name = "MISSING IS MISSING", + key = key("is-type-06"), + catalog = "pql", + expected = StaticType.BOOL, + ), + SuccessTestCase( + name = "NULL IS MISSING", + key = key("is-type-07"), + catalog = "pql", + expected = StaticType.BOOL, + ), + ErrorTestCase( + name = "ERROR always MISSING", + key = key("is-type-08"), + catalog = "pql", + ), + ) + @JvmStatic fun sessionVariables() = listOf( SuccessTestCase( @@ -536,7 +596,10 @@ class PlanTyperTestsPorted { problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UnknownFunction("bitwise_and", listOf(StaticType.INT4, StaticType.STRING)) + PlanningProblemDetails.UnknownFunction( + "bitwise_and", + listOf(StaticType.INT4, StaticType.STRING) + ) ) } ), @@ -2972,6 +3035,11 @@ class PlanTyperTestsPorted { @Execution(ExecutionMode.CONCURRENT) fun testPivot(tc: TestCase) = runTest(tc) + @ParameterizedTest + @MethodSource("isTypeCases") + @Execution(ExecutionMode.CONCURRENT) + fun testIsType(tc: TestCase) = runTest(tc) + // --------- Finish Parameterized Tests ------ // @@ -2980,7 +3048,7 @@ class PlanTyperTestsPorted { private fun infer( query: String, session: PartiQLPlanner.Session, - problemCollector: ProblemCollector + problemCollector: ProblemCollector, ): PartiQLPlan { val ast = parser.parse(query).root return planner.plan(ast, session, problemCollector).plan diff --git a/partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/is_type.sql b/partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/is_type.sql new file mode 100644 index 0000000000..7a8da457f5 --- /dev/null +++ b/partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/is_type.sql @@ -0,0 +1,27 @@ +--#[is-type-00] +false IS BOOL; + +--#[is-type-01] +item.i_class_id IS INT; + +--#[is-type-02] +item.i_brand IS STRING; + +--#[is-type-03] +1 IS NULL; + +--#[is-type-04] +MISSING IS NULL; + +--#[is-type-05] +NULL IS NULL; + +--#[is-type-06] +MISSING IS MISSING; + +--#[is-type-07] +NULL IS MISSING; + +--#[is-type-08] +-- ERROR! always MISSING +MISSING IS BOOL;