From b36a420af802773389e015b5eac14323729e8086 Mon Sep 17 00:00:00 2001 From: John Ed Quinn Date: Tue, 26 Nov 2024 11:33:33 -0800 Subject: [PATCH] Removes use of deprecated PType.numeric() --- .../internal/transforms/RelConverter.kt | 2 +- .../internal/transforms/RexConverter.kt | 2 +- .../planner/internal/typer/DynamicTyper.kt | 2 +- .../planner/internal/typer/PlanTyper.kt | 4 +-- .../internal/typer/PlanTyperTestsPorted.kt | 4 +-- .../typer/operator/OpBitwiseAndTest.kt | 6 ++--- .../kotlin/org/partiql/planner/util/Utils.kt | 2 +- .../java/org/partiql/spi/value/Datum.java | 25 ++++++++++++++++++- .../partiql/spi/value/DatumBigInteger.java | 2 +- .../org/partiql/spi/function/Builtins.kt | 8 +++--- .../partiql/spi/function/builtins/AggAvg.kt | 6 ++--- .../partiql/spi/function/builtins/AggMax.kt | 6 ++--- .../partiql/spi/function/builtins/AggMin.kt | 4 +-- .../partiql/spi/function/builtins/AggSum.kt | 8 +++--- .../spi/function/builtins/DefaultNumeric.kt | 8 ++++++ .../partiql/spi/function/builtins/FnAbs.kt | 6 ++--- .../spi/function/builtins/FnBetween.kt | 6 ++--- .../spi/function/builtins/FnBitwiseAnd.kt | 2 +- .../spi/function/builtins/FnDateAddDay.kt | 4 +-- .../spi/function/builtins/FnDateAddHour.kt | 4 +-- .../spi/function/builtins/FnDateAddMinute.kt | 4 +-- .../spi/function/builtins/FnDateAddMonth.kt | 4 +-- .../spi/function/builtins/FnDateAddSecond.kt | 4 +-- .../spi/function/builtins/FnDateAddYear.kt | 4 +-- .../partiql/spi/function/builtins/FnDivide.kt | 2 +- .../org/partiql/spi/function/builtins/FnGt.kt | 2 +- .../partiql/spi/function/builtins/FnGte.kt | 2 +- .../org/partiql/spi/function/builtins/FnLt.kt | 2 +- .../partiql/spi/function/builtins/FnLte.kt | 2 +- .../partiql/spi/function/builtins/FnMinus.kt | 2 +- .../partiql/spi/function/builtins/FnModulo.kt | 2 +- .../partiql/spi/function/builtins/FnNeg.kt | 4 +-- .../partiql/spi/function/builtins/FnPlus.kt | 2 +- .../partiql/spi/function/builtins/FnPos.kt | 4 +-- .../partiql/spi/function/builtins/FnTimes.kt | 2 +- .../org/partiql/value/PartiQLValueType.kt | 2 +- .../partiql/eval/value/DatumComparatorTest.kt | 2 +- partiql-types/api/partiql-types.api | 1 - .../main/java/org/partiql/types/PType.java | 11 -------- .../org/partiql/types/FromStaticType.kt | 2 +- 40 files changed, 95 insertions(+), 76 deletions(-) create mode 100644 partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DefaultNumeric.kt diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt index f3c054637..fe68632bf 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt @@ -751,5 +751,5 @@ internal object RelConverter { private val STRUCT: CompilerType = CompilerType(PType.struct()) private val BAG: CompilerType = CompilerType(PType.bag()) private val LIST: CompilerType = CompilerType(PType.array()) - private val INT: CompilerType = CompilerType(PType.numeric()) + private val INT: CompilerType = CompilerType(PType.numeric(38, 0)) } 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 042003ff5..a8dbb5bd9 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 @@ -1084,7 +1084,7 @@ internal object RexConverter { private val STRUCT: CompilerType = CompilerType(PType.struct()) private val BAG: CompilerType = CompilerType(PType.bag()) private val LIST: CompilerType = CompilerType(PType.array()) - private val INT: CompilerType = CompilerType(PType.numeric()) + private val INT: CompilerType = CompilerType(PType.numeric(38, 0)) private val INT4: CompilerType = CompilerType(PType.integer()) private val TIMESTAMP: CompilerType = CompilerType(PType.timestamp(6)) } diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/DynamicTyper.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/DynamicTyper.kt index 53842c0be..3475090f0 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/DynamicTyper.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/DynamicTyper.kt @@ -394,7 +394,7 @@ internal class DynamicTyper { PType.SMALLINT -> PType.smallint() PType.INTEGER -> PType.integer() PType.BIGINT -> PType.bigint() - PType.NUMERIC -> PType.numeric() + PType.NUMERIC -> PType.numeric(38, 0) // TODO: To be updated PType.DECIMAL -> PType.decimal(38, 0) // TODO: To be updated. PType.REAL -> PType.real() PType.DOUBLE -> PType.doublePrecision() diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt index c8fa5cd7f..260876cd6 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt @@ -382,7 +382,7 @@ internal class PlanTyper(private val env: Env, config: Context) { val limit = node.limit.type(input.type.schema, outer, Strategy.GLOBAL) // check types if (limit.type.isNumeric().not()) { - val problem = PErrors.typeUnexpected(null, limit.type, listOf(PType.numeric())) + val problem = PErrors.typeUnexpected(null, limit.type, listOf(PType.numeric(38, 0))) val err = errorRexAndReport(_listener, problem) return rel(input.type, relOpLimit(input, err)) } @@ -400,7 +400,7 @@ internal class PlanTyper(private val env: Env, config: Context) { val offset = node.offset.type(input.type.schema, outer, Strategy.GLOBAL) // check types if (offset.type.isNumeric().not()) { - val problem = PErrors.typeUnexpected(null, offset.type, listOf(PType.numeric())) + val problem = PErrors.typeUnexpected(null, offset.type, listOf(PType.numeric(38, 0))) val err = errorRexAndReport(_listener, problem) return rel(input.type, relOpLimit(input, err)) } 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 39c01d5ec..13d06bd03 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 @@ -4340,7 +4340,7 @@ internal class PlanTyperTestsPorted { query = "SELECT * FROM pets LIMIT '5'", expected = TABLE_AWS_DDB_PETS, problemHandler = assertProblemExists( - PErrors.typeUnexpected(null, PType.string(), listOf(PType.numeric())) + PErrors.typeUnexpected(null, PType.string(), listOf(PType.numeric(38, 0))) ) ), SuccessTestCase( @@ -4357,7 +4357,7 @@ internal class PlanTyperTestsPorted { query = "SELECT * FROM pets LIMIT 1 OFFSET '5'", expected = TABLE_AWS_DDB_PETS, problemHandler = assertProblemExists( - PErrors.typeUnexpected(null, PType.string(), listOf(PType.numeric())) + PErrors.typeUnexpected(null, PType.string(), listOf(PType.numeric(38, 0))) ) ), SuccessTestCase( diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/operator/OpBitwiseAndTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/operator/OpBitwiseAndTest.kt index 93ec9815e..8987afcad 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/operator/OpBitwiseAndTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/operator/OpBitwiseAndTest.kt @@ -33,9 +33,9 @@ class OpBitwiseAndTest : PartiQLTyperTestBase() { val arg0 = args.first() val arg1 = args[1] val output = when { - arg0 !in allIntPType && arg1 !in allIntPType -> PType.numeric() - arg0 in allIntPType && arg1 !in allIntPType -> PType.numeric() - arg0 !in allIntPType && arg1 in allIntPType -> PType.numeric() + arg0 !in allIntPType && arg1 !in allIntPType -> PType.numeric(38, 0) + arg0 in allIntPType && arg1 !in allIntPType -> PType.numeric(38, 0) + arg0 !in allIntPType && arg1 in allIntPType -> PType.numeric(38, 0) arg0 == arg1 -> arg1 castTablePType(arg1, arg0) == CastType.COERCION -> arg0 castTablePType(arg0, arg1) == CastType.COERCION -> arg1 diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/util/Utils.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/util/Utils.kt index b317f5b47..c52bacf40 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/util/Utils.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/util/Utils.kt @@ -72,7 +72,7 @@ val allBooleanPType = setOf( PType.bool() ) -val allIntPType = setOf(PType.tinyint(), PType.smallint(), PType.integer(), PType.bigint(), PType.numeric()) +val allIntPType = setOf(PType.tinyint(), PType.smallint(), PType.integer(), PType.bigint(), PType.numeric(38, 0)) val allNumberPType = allIntPType + setOf( PType.decimal(38, 19), diff --git a/partiql-spi/src/main/java/org/partiql/spi/value/Datum.java b/partiql-spi/src/main/java/org/partiql/spi/value/Datum.java index ba3faa4f1..0f3647a8c 100644 --- a/partiql-spi/src/main/java/org/partiql/spi/value/Datum.java +++ b/partiql-spi/src/main/java/org/partiql/spi/value/Datum.java @@ -23,7 +23,30 @@ import java.util.Iterator; import java.util.Objects; -import static org.partiql.types.PType.*; // TODO +import static org.partiql.types.PType.DYNAMIC; +import static org.partiql.types.PType.BOOL; +import static org.partiql.types.PType.TINYINT; +import static org.partiql.types.PType.SMALLINT; +import static org.partiql.types.PType.INTEGER; +import static org.partiql.types.PType.BIGINT; +import static org.partiql.types.PType.NUMERIC; +import static org.partiql.types.PType.DECIMAL; +import static org.partiql.types.PType.REAL; +import static org.partiql.types.PType.DOUBLE; +import static org.partiql.types.PType.CHAR; +import static org.partiql.types.PType.STRING; +import static org.partiql.types.PType.BLOB; +import static org.partiql.types.PType.CLOB; +import static org.partiql.types.PType.DATE; +import static org.partiql.types.PType.TIME; +import static org.partiql.types.PType.TIMEZ; +import static org.partiql.types.PType.TIMESTAMP; +import static org.partiql.types.PType.TIMESTAMPZ; +import static org.partiql.types.PType.ARRAY; +import static org.partiql.types.PType.BAG; +import static org.partiql.types.PType.ROW; +import static org.partiql.types.PType.STRUCT; +import static org.partiql.types.PType.UNKNOWN; /** * This is an EXPERIMENTAL representation of a value in PartiQL's type system. The intention of this modeling is to diff --git a/partiql-spi/src/main/java/org/partiql/spi/value/DatumBigInteger.java b/partiql-spi/src/main/java/org/partiql/spi/value/DatumBigInteger.java index 3d82aec16..a81449e2b 100644 --- a/partiql-spi/src/main/java/org/partiql/spi/value/DatumBigInteger.java +++ b/partiql-spi/src/main/java/org/partiql/spi/value/DatumBigInteger.java @@ -13,7 +13,7 @@ class DatumBigInteger implements Datum { @NotNull private final BigInteger _value; - private final static PType _type = PType.numeric(); + private final static PType _type = PType.numeric(38, 0); DatumBigInteger(@NotNull BigInteger value) { _value = value; diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/Builtins.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/Builtins.kt index 4cdc29fa9..cdd7f2f47 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/Builtins.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/Builtins.kt @@ -23,7 +23,7 @@ internal object Builtins { Fn_ABS__INT16__INT16, Fn_ABS__INT32__INT32, Fn_ABS__INT64__INT64, - Fn_ABS__INT__INT, + Fn_ABS__NUMERIC__NUMERIC, Fn_ABS__FLOAT32__FLOAT32, Fn_ABS__FLOAT64__FLOAT64, Fn_ABS__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, @@ -261,7 +261,7 @@ internal object Builtins { Agg_AVG__INT16__INT16, Agg_AVG__INT32__INT32, Agg_AVG__INT64__INT64, - Agg_AVG__INT__INT, + Agg_AVG__NUMERIC__NUMERIC, Agg_AVG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, Agg_AVG__FLOAT32__FLOAT32, Agg_AVG__FLOAT64__FLOAT64, @@ -273,7 +273,7 @@ internal object Builtins { Agg_MAX__INT16__INT16, Agg_MAX__INT32__INT32, Agg_MAX__INT64__INT64, - Agg_MAX__INT__INT, + Agg_MAX__NUMERIC__NUMERIC, Agg_MAX__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, Agg_MAX__FLOAT32__FLOAT32, Agg_MAX__FLOAT64__FLOAT64, @@ -293,7 +293,7 @@ internal object Builtins { Agg_SUM__INT16__INT16, Agg_SUM__INT32__INT32, Agg_SUM__INT64__INT64, - Agg_SUM__INT__INT, + Agg_SUM__NUMERIC__NUMERIC, Agg_SUM__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, Agg_SUM__FLOAT32__FLOAT32, Agg_SUM__FLOAT64__FLOAT64, diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAvg.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAvg.kt index bc87119eb..e4a18c624 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAvg.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAvg.kt @@ -42,12 +42,12 @@ internal val Agg_AVG__INT64__INT64 = Aggregation.static( accumulator = ::AccumulatorAvg, ) -internal val Agg_AVG__INT__INT = Aggregation.static( +internal val Agg_AVG__NUMERIC__NUMERIC = Aggregation.static( name = "avg", - returns = PType.decimal(38, 19), + returns = PType.decimal(38, 19), // TODO: Return Numeric once Datum is updated to use BigDecimal parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("value", PType.numeric()), + Parameter("value", DefaultNumeric.NUMERIC), ), accumulator = ::AccumulatorAvg, ) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMax.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMax.kt index 8ec70236c..de8831d7b 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMax.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMax.kt @@ -48,12 +48,12 @@ internal val Agg_MAX__INT64__INT64 = Aggregation.static( accumulator = ::AccumulatorMax, ) -internal val Agg_MAX__INT__INT = Aggregation.static( +internal val Agg_MAX__NUMERIC__NUMERIC = Aggregation.static( name = "max", - returns = PType.numeric(), + returns = DefaultNumeric.NUMERIC, parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("value", PType.numeric()), + Parameter("value", DefaultNumeric.NUMERIC), ), accumulator = ::AccumulatorMax, ) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMin.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMin.kt index a61c679ed..140f569fe 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMin.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMin.kt @@ -46,9 +46,9 @@ internal val Agg_MIN__INT64__INT64 = Aggregation.static( internal val Agg_MIN__INT__INT = Aggregation.static( name = "min", - returns = PType.numeric(), + returns = DefaultNumeric.NUMERIC, parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("value", PType.numeric()), + Parameter("value", DefaultNumeric.NUMERIC), // TODO: Rewrite aggregations using new function modeling. ), accumulator = ::AccumulatorMin, ) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSum.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSum.kt index d923db4dc..b661e6dc7 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSum.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSum.kt @@ -44,13 +44,13 @@ internal val Agg_SUM__INT64__INT64 = Aggregation.static( accumulator = { AccumulatorSum(PType.bigint()) }, ) -internal val Agg_SUM__INT__INT = Aggregation.static( +internal val Agg_SUM__NUMERIC__NUMERIC = Aggregation.static( name = "sum", - returns = PType.numeric(), + returns = DefaultNumeric.NUMERIC, parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("value", PType.numeric()), + Parameter("value", DefaultNumeric.NUMERIC), ), - accumulator = { AccumulatorSum(PType.numeric()) }, + accumulator = { AccumulatorSum(DefaultNumeric.NUMERIC) }, ) internal val Agg_SUM__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY = Aggregation.static( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DefaultNumeric.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DefaultNumeric.kt new file mode 100644 index 000000000..cb9d44a30 --- /dev/null +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DefaultNumeric.kt @@ -0,0 +1,8 @@ +package org.partiql.spi.function.builtins + +import org.partiql.types.PType + +internal object DefaultNumeric { + // TODO: Once all functions are converted to use the new function modeling, this can be removed. + val NUMERIC: PType = PType.numeric(38, 19) +} diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAbs.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAbs.kt index 49ee97fef..d97538786 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAbs.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAbs.kt @@ -47,10 +47,10 @@ internal val Fn_ABS__INT64__INT64 = Function.static( Datum.bigint(value.absoluteValue) } -internal val Fn_ABS__INT__INT = Function.static( +internal val Fn_ABS__NUMERIC__NUMERIC = Function.static( name = "abs", - returns = PType.numeric(), - parameters = arrayOf(Parameter("value", PType.numeric())), + returns = DefaultNumeric.NUMERIC, + parameters = arrayOf(Parameter("value", DefaultNumeric.NUMERIC)), ) { args -> val value = args[0].bigInteger Datum.numeric(value.abs()) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBetween.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBetween.kt index fca7664df..3df72bc16 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBetween.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBetween.kt @@ -81,9 +81,9 @@ internal val Fn_BETWEEN__INT_INT_INT__BOOL = Function.static( name = "between", returns = PType.bool(), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("value", PType.numeric()), - @Suppress("DEPRECATION") Parameter("lower", PType.numeric()), - @Suppress("DEPRECATION") Parameter("upper", PType.numeric()), + Parameter("value", DefaultNumeric.NUMERIC), + Parameter("lower", DefaultNumeric.NUMERIC), + Parameter("upper", DefaultNumeric.NUMERIC), ), ) { args -> diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitwiseAnd.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitwiseAnd.kt index cdba43d3c..f2e1db52b 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitwiseAnd.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitwiseAnd.kt @@ -48,7 +48,7 @@ internal object FnBitwiseAnd : DiadicArithmeticOperator("bitwise_and") { // TODO: Probably remove this if we don't expose NUMERIC override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.numeric()) { args -> + return basic(DefaultNumeric.NUMERIC) { args -> val arg0 = args[0].bigInteger val arg1 = args[1].bigInteger Datum.numeric(arg0 and arg1) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddDay.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddDay.kt index 8a2d0fb92..98f9e4f5a 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddDay.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddDay.kt @@ -49,7 +49,7 @@ internal val Fn_DATE_ADD_DAY__INT_DATE__DATE = Function.static( name = "date_add_day", returns = PType.date(), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.date()), ), @@ -104,7 +104,7 @@ internal val Fn_DATE_ADD_DAY__INT_TIMESTAMP__TIMESTAMP = Function.static( name = "date_add_day", returns = PType.timestamp(6), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.timestamp(6)), ), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddHour.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddHour.kt index 31c919426..be21e3c08 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddHour.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddHour.kt @@ -49,7 +49,7 @@ internal val Fn_DATE_ADD_HOUR__INT_TIME__TIME = Function.static( name = "date_add_hour", returns = PType.time(6), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.time(6)), ), @@ -104,7 +104,7 @@ internal val Fn_DATE_ADD_HOUR__INT_TIMESTAMP__TIMESTAMP = Function.static( name = "date_add_hour", returns = PType.timestamp(6), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.timestamp(6)), ), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMinute.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMinute.kt index 4e26500c4..9811538a9 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMinute.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMinute.kt @@ -49,7 +49,7 @@ internal val Fn_DATE_ADD_MINUTE__INT_TIME__TIME = Function.static( name = "date_add_minute", returns = PType.time(6), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.time(6)), ), @@ -104,7 +104,7 @@ internal val Fn_DATE_ADD_MINUTE__INT_TIMESTAMP__TIMESTAMP = Function.static( name = "date_add_minute", returns = PType.timestamp(6), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.timestamp(6)), ), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt index 443d26a81..5a61e31c5 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt @@ -49,7 +49,7 @@ internal val Fn_DATE_ADD_MONTH__INT_DATE__DATE = Function.static( name = "date_add_month", returns = PType.date(), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.date()), ), @@ -104,7 +104,7 @@ internal val Fn_DATE_ADD_MONTH__INT_TIMESTAMP__TIMESTAMP = Function.static( name = "date_add_month", returns = PType.timestamp(6), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.timestamp(6)), ), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt index 995ecfd11..53c3415e5 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt @@ -49,7 +49,7 @@ internal val Fn_DATE_ADD_SECOND__INT_TIME__TIME = Function.static( name = "date_add_second", returns = PType.time(6), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.time(6)), ), @@ -104,7 +104,7 @@ internal val Fn_DATE_ADD_SECOND__INT_TIMESTAMP__TIMESTAMP = Function.static( name = "date_add_second", returns = PType.timestamp(6), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.timestamp(6)), ), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt index 3ba1f66e1..4beae8cbb 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt @@ -49,7 +49,7 @@ internal val Fn_DATE_ADD_YEAR__INT_DATE__DATE = Function.static( name = "date_add_year", returns = PType.date(), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.date()), ), @@ -104,7 +104,7 @@ internal val Fn_DATE_ADD_YEAR__INT_TIMESTAMP__TIMESTAMP = Function.static( name = "date_add_year", returns = PType.timestamp(6), parameters = arrayOf( - @Suppress("DEPRECATION") Parameter("interval", PType.numeric()), + Parameter("interval", DefaultNumeric.NUMERIC), Parameter("datetime", PType.timestamp(6)), ), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDivide.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDivide.kt index 3bbfcc087..cc1f6f1a2 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDivide.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDivide.kt @@ -46,7 +46,7 @@ internal object FnDivide : DiadicArithmeticOperator("divide") { } override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.numeric()) { args -> + return basic(DefaultNumeric.NUMERIC) { args -> val arg0 = args[0].bigInteger val arg1 = args[1].bigInteger Datum.numeric(arg0 / arg1) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGt.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGt.kt index da1efb025..c0077be00 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGt.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGt.kt @@ -52,7 +52,7 @@ internal object FnGt : DiadicComparisonOperator("gt") { // TODO: Update numeric to use bigDecimal rather than bigInteger. override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.bool(), PType.numeric()) { args -> + return basic(PType.bool(), DefaultNumeric.NUMERIC) { args -> val lhs = args[0].bigInteger val rhs = args[1].bigInteger Datum.bool(lhs > rhs) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt index 714be6a7a..9a581b5c2 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt @@ -52,7 +52,7 @@ internal object FnGte : DiadicComparisonOperator("gte") { // TODO: Update override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.bool(), PType.numeric()) { args -> + return basic(PType.bool(), DefaultNumeric.NUMERIC) { args -> val lhs = args[0].bigInteger val rhs = args[1].bigInteger Datum.bool(lhs >= rhs) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt index cf685ea4e..8e526a2be 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt @@ -48,7 +48,7 @@ internal object FnLt : DiadicComparisonOperator("lt") { // TODO: Update override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.bool(), PType.numeric()) { args -> + return basic(PType.bool(), DefaultNumeric.NUMERIC) { args -> val lhs = args[0].bigInteger val rhs = args[1].bigInteger Datum.bool(lhs < rhs) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt index 11a9208a8..35d6cba0e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt @@ -52,7 +52,7 @@ internal object FnLte : DiadicComparisonOperator("lte") { // TODO: Update override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.bool(), PType.numeric()) { args -> + return basic(PType.bool(), DefaultNumeric.NUMERIC) { args -> val lhs = args[0].bigInteger val rhs = args[1].bigInteger Datum.bool(lhs <= rhs) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnMinus.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnMinus.kt index 348300ce3..df7de273c 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnMinus.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnMinus.kt @@ -48,7 +48,7 @@ internal object FnMinus : DiadicArithmeticOperator("minus") { // TODO: Delete this override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.numeric()) { args -> + return basic(DefaultNumeric.NUMERIC) { args -> val arg0 = args[0].bigInteger val arg1 = args[1].bigInteger Datum.numeric(arg0 - arg1) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnModulo.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnModulo.kt index d5eb4a1cd..a785a020e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnModulo.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnModulo.kt @@ -46,7 +46,7 @@ internal object FnModulo : DiadicArithmeticOperator("modulo") { } override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.numeric()) { args -> + return basic(DefaultNumeric.NUMERIC) { args -> val arg0 = args[0].bigInteger val arg1 = args[1].bigInteger Datum.numeric(arg0 % arg1) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNeg.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNeg.kt index 77cb15080..0ebc9380c 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNeg.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNeg.kt @@ -57,8 +57,8 @@ internal val Fn_NEG__INT64__INT64 = Function.static( internal val Fn_NEG__INT__INT = Function.static( name = "neg", - returns = PType.numeric(), - parameters = arrayOf(Parameter("value", PType.numeric())), + returns = DefaultNumeric.NUMERIC, + parameters = arrayOf(Parameter("value", DefaultNumeric.NUMERIC)), ) { args -> val value = args[0].bigInteger diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPlus.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPlus.kt index f3ca315e3..576951390 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPlus.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPlus.kt @@ -48,7 +48,7 @@ internal object FnPlus : DiadicArithmeticOperator("plus") { // TODO: Probably remove this if we don't expose NUMERIC override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.numeric()) { args -> + return basic(DefaultNumeric.NUMERIC) { args -> val arg0 = args[0].bigInteger val arg1 = args[1].bigInteger Datum.numeric(arg0 + arg1) diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPos.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPos.kt index 971def0f0..bb0ab5085 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPos.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPos.kt @@ -50,8 +50,8 @@ internal val Fn_POS__INT64__INT64 = Function.static( internal val Fn_POS__INT__INT = Function.static( name = "pos", - returns = PType.numeric(), - parameters = arrayOf(Parameter("value", PType.numeric())), + returns = DefaultNumeric.NUMERIC, + parameters = arrayOf(Parameter("value", DefaultNumeric.NUMERIC)), ) { args -> args[0] diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTimes.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTimes.kt index a261f6788..9e3b00f64 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTimes.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTimes.kt @@ -46,7 +46,7 @@ internal object FnTimes : DiadicArithmeticOperator("times") { } override fun getNumericInstance(numericLhs: PType, numericRhs: PType): Function.Instance { - return basic(PType.numeric()) { args -> + return basic(DefaultNumeric.NUMERIC) { args -> val arg0 = args[0].bigInteger val arg1 = args[1].bigInteger Datum.numeric(arg0 * arg1) diff --git a/partiql-spi/src/main/kotlin/org/partiql/value/PartiQLValueType.kt b/partiql-spi/src/main/kotlin/org/partiql/value/PartiQLValueType.kt index 6958fbaeb..770712958 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/value/PartiQLValueType.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/value/PartiQLValueType.kt @@ -84,7 +84,7 @@ public enum class PartiQLValueType { LIST -> PType.array() BAG -> PType.bag() FLOAT32 -> PType.real() - INT -> PType.numeric() + INT -> PType.numeric(38, 0) INT64 -> PType.bigint() INT32 -> PType.integer() INT16 -> PType.smallint() diff --git a/partiql-spi/src/test/kotlin/org/partiql/eval/value/DatumComparatorTest.kt b/partiql-spi/src/test/kotlin/org/partiql/eval/value/DatumComparatorTest.kt index aac37eec0..9b19422c3 100644 --- a/partiql-spi/src/test/kotlin/org/partiql/eval/value/DatumComparatorTest.kt +++ b/partiql-spi/src/test/kotlin/org/partiql/eval/value/DatumComparatorTest.kt @@ -100,7 +100,7 @@ class DatumComparatorTest { Datum.missing(), // missing Datum.nullValue(), // TODO: annotations = listOf("a")), // `a::null` Datum.missing(), // TODO: annotations = listOf("a")), // `a::missing` - Datum.nullValue(PType.numeric()), // `null.int`, + Datum.nullValue(PType.numeric(38, 0)), // `null.int`, Datum.nullValue(PType.struct()) // `null.struct` ) ) diff --git a/partiql-types/api/partiql-types.api b/partiql-types/api/partiql-types.api index 85cdfaf1b..27e71076c 100644 --- a/partiql-types/api/partiql-types.api +++ b/partiql-types/api/partiql-types.api @@ -61,7 +61,6 @@ public abstract class org/partiql/types/PType : org/partiql/types/Enum { public fun getTypeParameter ()Lorg/partiql/types/PType; public static fun integer ()Lorg/partiql/types/PType; public fun name ()Ljava/lang/String; - public static fun numeric ()Lorg/partiql/types/PType; public static fun numeric (II)Lorg/partiql/types/PType; public static fun real ()Lorg/partiql/types/PType; public static fun row (Ljava/util/Collection;)Lorg/partiql/types/PType; diff --git a/partiql-types/src/main/java/org/partiql/types/PType.java b/partiql-types/src/main/java/org/partiql/types/PType.java index 4b01a27be..afc74138a 100644 --- a/partiql-types/src/main/java/org/partiql/types/PType.java +++ b/partiql-types/src/main/java/org/partiql/types/PType.java @@ -526,21 +526,10 @@ public static PType bigint() { return new PTypePrimitive(BIGINT); } - /** - * @return a PartiQL int (arbitrary precision) type - * @deprecated this API is experimental and is subject to modification/deletion without prior notice. - */ - @NotNull - @Deprecated - public static PType numeric() { - return new PTypeDecimal(NUMERIC, 38, 0); - } - /** * @return a SQL:1999 NUMERIC type. */ @NotNull - @SuppressWarnings("unused") public static PType numeric(int precision, int scale) { return new PTypeDecimal(NUMERIC, precision, scale); } diff --git a/partiql-types/src/testFixtures/kotlin/org/partiql/types/FromStaticType.kt b/partiql-types/src/testFixtures/kotlin/org/partiql/types/FromStaticType.kt index f53ab1b09..b7fa411be 100644 --- a/partiql-types/src/testFixtures/kotlin/org/partiql/types/FromStaticType.kt +++ b/partiql-types/src/testFixtures/kotlin/org/partiql/types/FromStaticType.kt @@ -54,7 +54,7 @@ fun fromStaticType(type: StaticType): PType { } else if (cons == IntType.IntRangeConstraint.LONG) { PType.bigint() } else if (cons == IntType.IntRangeConstraint.UNCONSTRAINED) { - PType.numeric() + PType.numeric(38, 0) } else { throw IllegalStateException() }