diff --git a/velox/functions/sparksql/Decimal.cpp b/velox/functions/sparksql/Decimal.cpp index 99b3f651364f4..9f8a529b05bd8 100644 --- a/velox/functions/sparksql/Decimal.cpp +++ b/velox/functions/sparksql/Decimal.cpp @@ -215,62 +215,6 @@ class RoundDecimalFunction final : public exec::VectorFunction { } }; -template -class AbsFunction final : public exec::VectorFunction { - void apply( - const SelectivityVector& rows, - std::vector& args, // Not using const ref so we can reuse args - const TypePtr& outputType, - exec::EvalCtx& context, - VectorPtr& resultRef) const final { - VELOX_CHECK_EQ(args.size(), 1); - auto inputType = args[0]->type(); - VELOX_CHECK( - inputType->isShortDecimal() || inputType->isLongDecimal(), - "ShortDecimal or LongDecimal type is required."); - - exec::DecodedArgs decodedArgs(rows, args, context); - auto decimalVector = decodedArgs.at(0); - if (inputType->isShortDecimal()) { - auto decimalType = inputType->asShortDecimal(); - context.ensureWritable( - rows, - DECIMAL(decimalType.precision(), decimalType.scale()), - resultRef); - auto result = - resultRef->asUnchecked>()->mutableRawValues(); - rows.applyToSelected([&](int row) { - auto unscaled = std::abs(decimalVector->valueAt(row)); - if (unscaled >= DecimalUtil::kShortDecimalMin && - unscaled <= DecimalUtil::kShortDecimalMax) { - result[row] = unscaled; - } else { - // TODO: adjust the bahavior according to ANSI. - resultRef->setNull(row, true); - } - }); - } else { - auto decimalType = inputType->asLongDecimal(); - context.ensureWritable( - rows, - DECIMAL(decimalType.precision(), decimalType.scale()), - resultRef); - auto result = - resultRef->asUnchecked>()->mutableRawValues(); - rows.applyToSelected([&](int row) { - auto unscaled = std::abs(decimalVector->valueAt(row)); - if (unscaled >= DecimalUtil::kLongDecimalMin && - unscaled <= DecimalUtil::kLongDecimalMax) { - result[row] = unscaled; - } else { - // TODO: adjust the bahavior according to ANSI. - resultRef->setNull(row, true); - } - }); - } - } -}; - class UnscaledValueFunction final : public exec::VectorFunction { void apply( const SelectivityVector& rows, @@ -328,17 +272,6 @@ std::vector> roundDecimalSignatures() { .build()}; } -std::vector> absSignatures() { - return {exec::FunctionSignatureBuilder() - .integerVariable("a_precision") - .integerVariable("a_scale") - .integerVariable("r_precision", "min(38, a_precision)") - .integerVariable("r_scale", "min(38, a_scale)") - .returnType("DECIMAL(r_precision, r_scale)") - .argumentType("DECIMAL(a_precision, a_scale)") - .build()}; -} - std::vector> unscaledValueSignatures() { return {exec::FunctionSignatureBuilder() diff --git a/velox/functions/sparksql/Decimal.h b/velox/functions/sparksql/Decimal.h index 59c79b88c01b5..b33d68c5ea03e 100644 --- a/velox/functions/sparksql/Decimal.h +++ b/velox/functions/sparksql/Decimal.h @@ -38,12 +38,6 @@ std::shared_ptr makeRoundDecimal( const std::string& name, const std::vector& inputArgs); -std::vector> absSignatures(); - -std::shared_ptr makeAbs( - const std::string& name, - const std::vector& inputArgs); - std::vector> unscaledValueSignatures(); std::shared_ptr makeUnscaledValue( diff --git a/velox/functions/sparksql/Register.cpp b/velox/functions/sparksql/Register.cpp index 945c997268d44..eb29da9cd117a 100644 --- a/velox/functions/sparksql/Register.cpp +++ b/velox/functions/sparksql/Register.cpp @@ -172,8 +172,6 @@ void registerFunctions(const std::string& prefix) { prefix + "make_decimal", makeDecimalSignatures(), makeMakeDecimal); exec::registerStatefulVectorFunction( prefix + "decimal_round", roundDecimalSignatures(), makeRoundDecimal); - exec::registerStatefulVectorFunction( - prefix + "abs", absSignatures(), makeAbs); exec::registerStatefulVectorFunction( prefix + "unscaled_value", unscaledValueSignatures(), makeUnscaledValue); // Register date functions.