Skip to content

Commit

Permalink
Update FnNeg to use new PError methods
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 committed Jan 16, 2025
1 parent b9c7fcc commit 64961d4
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

package org.partiql.spi.function.builtins

import org.partiql.spi.errors.DataException
import org.partiql.spi.function.Parameter
import org.partiql.spi.function.builtins.internal.PErrors
import org.partiql.spi.function.utils.FunctionUtils
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
Expand All @@ -18,7 +18,7 @@ internal val Fn_NEG__INT8__INT8 = FunctionUtils.hidden(
) { args ->
val value = args[0].byte
if (value == Byte.MIN_VALUE) {
throw DataException("Resulting value out of range for TINYINT: -($value)")
throw PErrors.numericValueOutOfRangeException("-($value)", PType.tinyint())
} else {
Datum.tinyint(value.times(-1).toByte())
}
Expand All @@ -33,7 +33,7 @@ internal val Fn_NEG__INT16__INT16 = FunctionUtils.hidden(
) { args ->
val value = args[0].short
if (value == Short.MIN_VALUE) {
throw DataException("Resulting value out of range for SMALLINT: -($value)")
throw PErrors.numericValueOutOfRangeException("-($value)", PType.smallint())
} else {
Datum.smallint(value.times(-1).toShort())
}
Expand All @@ -48,7 +48,7 @@ internal val Fn_NEG__INT32__INT32 = FunctionUtils.hidden(
) { args ->
val value = args[0].int
if (value == Int.MIN_VALUE) {
throw DataException("Resulting value out of range for INTEGER: -($value)")
throw PErrors.numericValueOutOfRangeException("-($value)", PType.integer())
} else {
Datum.integer(value.times(-1))
}
Expand All @@ -63,7 +63,7 @@ internal val Fn_NEG__INT64__INT64 = FunctionUtils.hidden(
) { args ->
val value = args[0].long
if (value == Long.MIN_VALUE) {
throw DataException("Resulting value out of range for BIGINT: -($value)")
throw PErrors.numericValueOutOfRangeException("-($value)", PType.bigint())
} else {
Datum.bigint(value * -1L)
}
Expand Down

0 comments on commit 64961d4

Please sign in to comment.