From af7f6d5e195696030c4c810d0f99c39cae0a4c04 Mon Sep 17 00:00:00 2001 From: Alan Cai Date: Tue, 19 Nov 2024 13:54:34 -0800 Subject: [PATCH] Fix failing conformance tests --- .../internal/transforms/RexConverter.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt index de00a584c..7aab678b8 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt @@ -106,6 +106,7 @@ import org.partiql.value.decimalValue import org.partiql.value.float64Value import org.partiql.value.int32Value import org.partiql.value.int64Value +import org.partiql.value.intValue import org.partiql.value.io.PartiQLValueIonReaderBuilder import org.partiql.value.missingValue import org.partiql.value.nullValue @@ -158,10 +159,16 @@ internal object RexConverter { is LiteralNull, is LiteralMissing -> PType.unknown() is LiteralString -> PType.string() is LiteralBool -> PType.bool() - is LiteralDecimal -> PType.decimal(this.value.precision(), this.value.scale()) + is LiteralDecimal -> { + if (this.value.scale() == 0) { + PType.numeric() + } else { + PType.decimal(this.value.precision(), this.value.scale()) + } + } is LiteralInt -> PType.integer() is LiteralLong -> PType.bigint() - is LiteralDouble -> PType.real() + is LiteralDouble -> PType.doublePrecision() is LiteralTypedString -> { val type = this.type when (type.code()) { @@ -199,7 +206,13 @@ internal object RexConverter { is LiteralMissing -> missingValue() is LiteralString -> stringValue(value) is LiteralBool -> boolValue(value) - is LiteralDecimal -> decimalValue(this.value) + is LiteralDecimal -> { + if (this.value.scale() == 0) { + intValue(this.value.toBigInteger()) + } else { + decimalValue(this.value) + } + } is LiteralInt -> int32Value(this.value) is LiteralLong -> int64Value(this.value) is LiteralDouble -> float64Value(this.value)