dhruv9vats commented on a change in pull request #12162:
URL: https://github.com/apache/arrow/pull/12162#discussion_r793617156
##########
File path: cpp/src/arrow/compute/api_scalar.h
##########
@@ -1350,5 +1375,20 @@ ARROW_EXPORT Result<Datum> AssumeTimezone(const Datum&
values,
AssumeTimezoneOptions options,
ExecContext* ctx = NULLPTR);
+/// \brief Finds either the FIRST, LAST, or ALL items with a key that matches
the given
+/// query key in a map array.
+///
+/// Returns an array of items for FIRST and LAST, and an array of list of
items for ALL.
+///
+/// \param[in] map_array to look in
+/// \param[in] options to pass a query key and choose which matching keys to
return
+/// (FIRST, LAST or ALL)
+/// \param[in] ctx the function execution context, optional
+///
+/// \return the resulting datum
+/// \note API not yet finalized
+ARROW_EXPORT Result<Datum> MapArrayLookup(const Datum& map_array,
+ MapArrayLookupOptions options,
+ ExecContext* ctx = NULLPTR);
Review comment:
In a sync with Weston earlier this week, he mentioned adding this to
help with IDE autocompletion. Is this correct?
##########
File path: cpp/src/arrow/compute/kernels/scalar_nested.cc
##########
@@ -428,6 +428,273 @@ const FunctionDoc make_struct_doc{"Wrap Arrays into a
StructArray",
"specified through MakeStructOptions."),
{"*args"},
"MakeStructOptions"};
+template <typename KeyType>
+struct MapArrayLookupFunctor {
+ static Result<int64_t> GetOneMatchingIndex(const Array& keys,
+ const Scalar& query_key_scalar,
+ const bool& from_back) {
Review comment:
My (probably naive) line of thought:
- Still differentiating the helper functions on the bases of options (`ALL`
and `FIRST`/`LAST`) as opposed to input shapes as hinted by you as we need to
iterate till the end for the `LAST` option and putting that logic into a helper
function will fill it with conditional statements, making it look similar to
what `ExecMapArray` looks right now.
- Also still returning an `int` instead of appending to an array builder as
for the scalar case, as just a scalar via `GetScalar` gets returned which, too,
will introduce conditional statements.
##########
File path: cpp/src/arrow/compute/api_scalar.cc
##########
@@ -785,5 +819,12 @@ Result<Datum> Week(const Datum& arg, WeekOptions options,
ExecContext* ctx) {
return CallFunction("week", {arg}, &options, ctx);
}
+// ----------------------------------------------------------------------
+
+Result<Datum> MapArrayLookup(const Datum& arg, MapArrayLookupOptions options,
+ ExecContext* ctx) {
+ return CallFunction("map_array_lookup", {arg}, &options, ctx);
+}
+
Review comment:
Where should this go?
--
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]