From d56bc857ece9de2e5698d4bb555b5a2a25aba6b9 Mon Sep 17 00:00:00 2001 From: John Ed Quinn Date: Tue, 19 Nov 2024 13:14:08 -0800 Subject: [PATCH] Fixes conformance failures Replaces creation of a DECIMAL_ARBITRARY with DECIMAL Fixes null-call of equals function --- .../partiql/eval/internal/helpers/ToNull.kt | 122 ------------------ .../org/partiql/spi/function/builtins/FnEq.kt | 2 +- .../kotlin/org/partiql/value/PartiQLValue.kt | 2 +- .../partiql/value/io/PartiQLValueIonReader.kt | 6 +- 4 files changed, 5 insertions(+), 127 deletions(-) delete mode 100644 partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/ToNull.kt diff --git a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/ToNull.kt b/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/ToNull.kt deleted file mode 100644 index 39b427439..000000000 --- a/partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/ToNull.kt +++ /dev/null @@ -1,122 +0,0 @@ -package org.partiql.eval.internal.helpers - -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental -import org.partiql.value.PartiQLValueType -import org.partiql.value.bagValue -import org.partiql.value.binaryValue -import org.partiql.value.blobValue -import org.partiql.value.boolValue -import org.partiql.value.byteValue -import org.partiql.value.charValue -import org.partiql.value.clobValue -import org.partiql.value.dateValue -import org.partiql.value.decimalValue -import org.partiql.value.float32Value -import org.partiql.value.float64Value -import org.partiql.value.int16Value -import org.partiql.value.int32Value -import org.partiql.value.int64Value -import org.partiql.value.int8Value -import org.partiql.value.intValue -import org.partiql.value.intervalValue -import org.partiql.value.listValue -import org.partiql.value.missingValue -import org.partiql.value.nullValue -import org.partiql.value.sexpValue -import org.partiql.value.stringValue -import org.partiql.value.structValue -import org.partiql.value.symbolValue -import org.partiql.value.timeValue -import org.partiql.value.timestampValue - -/** - * Constructor for a typed null. - */ -@OptIn(PartiQLValueExperimental::class) -internal fun PartiQLValueType.toNull(): () -> PartiQLValue = when (this) { - PartiQLValueType.ANY -> { - { nullValue() } - } - PartiQLValueType.BOOL -> { - { boolValue(null) } - } - PartiQLValueType.INT8 -> { - { int8Value(null) } - } - PartiQLValueType.INT16 -> { - { int16Value(null) } - } - PartiQLValueType.INT32 -> { - { int32Value(null) } - } - PartiQLValueType.INT64 -> { - { int64Value(null) } - } - PartiQLValueType.INT -> { - { intValue(null) } - } - PartiQLValueType.DECIMAL -> { - { decimalValue(null) } - } - PartiQLValueType.FLOAT32 -> { - { float32Value(null) } - } - PartiQLValueType.FLOAT64 -> { - { float64Value(null) } - } - PartiQLValueType.CHAR -> { - { charValue(null) } - } - PartiQLValueType.STRING -> { - { stringValue(null) } - } - PartiQLValueType.SYMBOL -> { - { symbolValue(null) } - } - PartiQLValueType.BINARY -> { - { binaryValue(null) } - } - PartiQLValueType.BYTE -> { - { byteValue(null) } - } - PartiQLValueType.BLOB -> { - { blobValue(null) } - } - PartiQLValueType.CLOB -> { - { clobValue(null) } - } - PartiQLValueType.DATE -> { - { dateValue(null) } - } - PartiQLValueType.TIME -> { - { timeValue(null) } - } - PartiQLValueType.TIMESTAMP -> { - { timestampValue(null) } - } - PartiQLValueType.INTERVAL -> { - { intervalValue(null) } - } - PartiQLValueType.BAG -> { - { bagValue(null) } - } - PartiQLValueType.LIST -> { - { listValue(null) } - } - PartiQLValueType.SEXP -> { - { sexpValue(null) } - } - PartiQLValueType.STRUCT -> { - { structValue(null) } - } - PartiQLValueType.NULL -> { - { nullValue() } - } - PartiQLValueType.MISSING -> { - { missingValue() } - } - PartiQLValueType.DECIMAL_ARBITRARY -> { - { decimalValue(null) } - } -} diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnEq.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnEq.kt index 33e78fdf6..22d8582bb 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnEq.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnEq.kt @@ -42,7 +42,7 @@ internal object FnEq : Function { "eq", args, boolType, - isNullCall = false, + isNullCall = true, isMissingCall = false ) { override fun invoke(args: Array): Datum { diff --git a/partiql-spi/src/main/kotlin/org/partiql/value/PartiQLValue.kt b/partiql-spi/src/main/kotlin/org/partiql/value/PartiQLValue.kt index f1784526b..6be7e8fbe 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/value/PartiQLValue.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/value/PartiQLValue.kt @@ -220,7 +220,7 @@ public abstract class IntValue : NumericValue() { @PartiQLValueExperimental public abstract class DecimalValue : NumericValue() { - override val type: PartiQLValueType = PartiQLValueType.DECIMAL_ARBITRARY + override val type: PartiQLValueType = PartiQLValueType.DECIMAL abstract override fun copy(annotations: Annotations): DecimalValue diff --git a/partiql-spi/src/main/kotlin/org/partiql/value/io/PartiQLValueIonReader.kt b/partiql-spi/src/main/kotlin/org/partiql/value/io/PartiQLValueIonReader.kt index baca33715..7c49b096c 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/value/io/PartiQLValueIonReader.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/value/io/PartiQLValueIonReader.kt @@ -429,7 +429,7 @@ internal class PartiQLValueIonReader( val map = mutableMapOf() checkRequiredFieldNameAndPut(reader, map, "hour", PartiQLValueType.INT) checkRequiredFieldNameAndPut(reader, map, "minute", PartiQLValueType.INT) - checkRequiredFieldNameAndPut(reader, map, "second", PartiQLValueType.DECIMAL_ARBITRARY) + checkRequiredFieldNameAndPut(reader, map, "second", PartiQLValueType.DECIMAL) checkOptionalFieldNameAndPut(reader, map, "offset", PartiQLValueType.INT) // check remaining if (reader.next() != null) { @@ -464,7 +464,7 @@ internal class PartiQLValueIonReader( checkRequiredFieldNameAndPut(reader, map, "day", PartiQLValueType.INT) checkRequiredFieldNameAndPut(reader, map, "hour", PartiQLValueType.INT) checkRequiredFieldNameAndPut(reader, map, "minute", PartiQLValueType.INT) - checkRequiredFieldNameAndPut(reader, map, "second", PartiQLValueType.DECIMAL_ARBITRARY) + checkRequiredFieldNameAndPut(reader, map, "second", PartiQLValueType.DECIMAL) // check remaining if (reader.next() != null) { throw IllegalArgumentException("excess field in struct") @@ -535,7 +535,7 @@ internal class PartiQLValueIonReader( val v = fromIon(reader) when (expectedType) { PartiQLValueType.INT -> destination[k] = (v as IntValue).value?.intValueExact() - PartiQLValueType.DECIMAL_ARBITRARY -> destination[k] = (v as DecimalValue).value + PartiQLValueType.DECIMAL_ARBITRARY, PartiQLValueType.DECIMAL -> destination[k] = (v as DecimalValue).value else -> throw IllegalArgumentException("$expectedField should be either INT OR DECIMAL") } } else {