From 5e9cd1961b168a689c54cda5f11eeeaa47a87833 Mon Sep 17 00:00:00 2001 From: yliuuuu <107505258+yliuuuu@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:12:12 -0800 Subject: [PATCH] resolve nullable type causes a dynamic call (#1366) --- .../org/partiql/planner/internal/typer/FnResolver.kt | 10 +++++++++- .../org/partiql/planner/internal/typer/TypeUtils.kt | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/FnResolver.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/FnResolver.kt index ab5a88add..dbfa6084f 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/FnResolver.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/FnResolver.kt @@ -5,6 +5,8 @@ import org.partiql.planner.internal.ir.Agg import org.partiql.planner.internal.ir.Fn import org.partiql.planner.internal.ir.Identifier import org.partiql.planner.internal.ir.Rex +import org.partiql.types.AnyOfType +import org.partiql.types.NullType import org.partiql.types.StaticType import org.partiql.types.function.FunctionParameter import org.partiql.types.function.FunctionSignature @@ -192,7 +194,13 @@ internal class FnResolver(private val header: Header) { } private fun buildArgumentPermutations(args: List): List> { - val flattenedArgs = args.map { it.flatten().allTypes } + val flattenedArgs = args.map { + if (it is AnyOfType) { + it.flatten().allTypes.filter { it !is NullType } + } else { + it.flatten().allTypes + } + } return buildArgumentPermutations(flattenedArgs, accumulator = emptyList()) } diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeUtils.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeUtils.kt index 081f2a0cb..24ecb54c5 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeUtils.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeUtils.kt @@ -121,7 +121,10 @@ private fun StaticType.asRuntimeType(): PartiQLValueType = when (this) { is ListType -> PartiQLValueType.LIST is SexpType -> PartiQLValueType.SEXP is DateType -> PartiQLValueType.DATE - is DecimalType -> PartiQLValueType.DECIMAL_ARBITRARY + is DecimalType -> when (this.precisionScaleConstraint) { + is DecimalType.PrecisionScaleConstraint.Constrained -> PartiQLValueType.DECIMAL + DecimalType.PrecisionScaleConstraint.Unconstrained -> PartiQLValueType.DECIMAL_ARBITRARY + } is FloatType -> PartiQLValueType.FLOAT64 is GraphType -> error("Graph type missing from runtime types") is IntType -> when (this.rangeConstraint) {