Copilot commented on code in PR #45001:
URL: https://github.com/apache/arrow/pull/45001#discussion_r3969083947


##########
docs/source/cpp/compute.rst:
##########
@@ -1282,6 +1282,27 @@ Containment tests
 * \(8) Output is true iff :member:`MatchSubstringOptions::pattern`
   matches the corresponding input element at any position.
 
+Hash Functions
+~~~~~~~~~~~~~~
+
+Not to be confused with the "group by" functions, hash functions produce an 
array of hash
+values corresponding to the length of the input. Currently, these functions 
take a single
+array as input.

Review Comment:
   This section says the hash functions take a single array as input, but 
`hash32`/`hash64` also accept Scalar and ChunkedArray inputs (returning the 
same shape). The docs should describe the more general Datum contract to avoid 
misleading users.



##########
cpp/src/arrow/compute/api_scalar.h:
##########
@@ -1807,5 +1807,46 @@ ARROW_EXPORT Result<Datum> NanosecondsBetween(const 
Datum& left, const Datum& ri
 /// \note API not yet finalized
 ARROW_EXPORT Result<Datum> MapLookup(const Datum& map, MapLookupOptions 
options,
                                      ExecContext* ctx = NULLPTR);
+
+/// \brief Construct a hash value for each row of the input.
+///
+/// The result has the same length and shape as the input (Array in, Array out;
+/// ChunkedArray in, ChunkedArray out), but with element type UInt32. For a 
nested
+/// input type (struct, list, map, etc.), each row's child values are combined 
into a
+/// single hash for that row, recursively. A null input row produces a null 
output row;
+/// within a struct, a null field makes that whole row null, while within a 
list or map a
+/// null element does not (only the row's own validity matters there). Hash 
values are not
+/// guaranteed to be stable across different versions of the library, and this 
function
+/// does not currently take options, though these may be added in the future.
+///
+/// \param[in] input_array input data to hash
+/// \param[in] ctx function execution context, optional
+/// \return elementwise hash values
+///
+/// \since 26.0.0
+/// \note API not yet finalized
+ARROW_EXPORT
+Result<Datum> Hash32(const Datum& input_array, ExecContext* ctx = NULLPTR);
+
+/// \brief Construct a hash value for each row of the input.
+///
+/// The result has the same length and shape as the input (Array in, Array out;
+/// ChunkedArray in, ChunkedArray out), but with element type UInt64. For a 
nested

Review Comment:
   The C++ API docs describe only Array/ChunkedArray inputs, but these kernels 
also accept Scalar input (and return a Scalar), as covered by 
`TestScalarHash.ScalarInput`. Please document Scalar-in/Scalar-out in both 
`Hash32` and `Hash64` docstrings.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to