edponce commented on a change in pull request #10395: URL: https://github.com/apache/arrow/pull/10395#discussion_r650364204
########## File path: docs/source/cpp/compute.rst ########## @@ -286,6 +286,8 @@ an ``Invalid`` :class:`Status` when overflow is detected. +--------------------------+------------+--------------------+---------------------+ | power_checked | Binary | Numeric | Numeric | +--------------------------+------------+--------------------+---------------------+ +| sign | Unary | Numeric | Int8 | Review comment: I added a "Notes" column to the table, and included notes describing the output values and special case of 0. ########## File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc ########## @@ -1161,5 +1180,93 @@ TYPED_TEST(TestUnaryArithmeticFloating, AbsoluteValue) { } } +TYPED_TEST(TestUnaryArithmeticSigned, Sign) { + using CType = typename TestFixture::CType; + auto min = std::numeric_limits<CType>::min(); + auto max = std::numeric_limits<CType>::max(); + + for (auto allow_signed_zero : {false, true}) { + this->SetSignedZero(allow_signed_zero); + // Empty array + this->AssertUnaryOp(Sign, "[]", ArrayFromJSON(int8(), "[]")); + // Scalar/arrays with nulls + this->AssertUnaryOp(Sign, "[null]", ArrayFromJSON(int8(), "[null]")); + this->AssertUnaryOp(Sign, "[1, null, -10]", ArrayFromJSON(int8(), "[1, null, -1]")); + // Scalar/arrays with zeros + this->AssertUnaryOp(Sign, "[0]", ArrayFromJSON(int8(), "[0]")); + // Ordinary scalar/arrays (positive inputs) + this->AssertUnaryOp(Sign, "[1, 10, 127]", ArrayFromJSON(int8(), "[1, 1, 1]")); + // Ordinary scalar/arrays (negative inputs) + this->AssertUnaryOp(Sign, "[-1, -10, -127]", ArrayFromJSON(int8(), "[-1, -1, -1]")); + // Min/max + this->AssertUnaryOp(Sign, ArrayFromJSON(this->type_singleton(), MakeArray(min, max)), + ArrayFromJSON(int8(), "[-1, 1]")); + + auto arg = ArrayFromJSON(this->type_singleton(), MakeArray(-1, min, max, 1)); + arg = TweakValidityBit(arg, 1, false); + arg = TweakValidityBit(arg, 2, false); Review comment: Thanks for the explanation. These tests were removed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org