pitrou commented on code in PR #45562:
URL: https://github.com/apache/arrow/pull/45562#discussion_r1976370007
##########
cpp/src/arrow/compute/api_aggregate.h:
##########
@@ -175,6 +175,88 @@ class ARROW_EXPORT TDigestOptions : public FunctionOptions
{
uint32_t min_count;
};
+/// \brief Control Pivot kernel behavior
+///
+/// These options apply to the "pivot_wider" and "hash_pivot_wider" functions.
+///
+/// Constraints:
+/// - The corresponding `Aggregate::target` must have two FieldRef elements;
+/// the first one points to the pivot key column, the second points to the
+/// pivoted data column.
+/// - The pivot key column must be string-like; its values will be matched
+/// against `key_names` in order to dispatch the pivoted data into the
+/// output.
+///
+/// "pivot_wider" example
+/// ---------------------
+///
+/// Assuming the following two input columns with types utf8 and int16
(respectively):
+/// ```
+/// width | 11
+/// height | 13
+/// ```
+/// and the options `PivotWiderOptions(.key_names = {"height", "width"})`
+///
+/// then the output will be a scalar with the type
+/// `struct{"height": int16, "width": int16}`
+/// and the value `{"height": 13, "width": 11}`.
+///
+/// "hash_pivot_wider" example
+/// --------------------------
+///
+/// Assuming the following input with schema
+/// `{"group": int32, "key": utf8, "value": int16}`:
+/// ```
+/// group | key | value
+/// -----------------------------
+/// 1 | height | 11
+/// 1 | width | 12
+/// 2 | width | 13
+/// 3 | height | 14
+/// 3 | depth | 15
+/// ```
+/// and the following settings:
+/// - a hash grouping key "group"
+/// - Aggregate(
+/// .function = "hash_pivot_wider",
+/// .options = PivotWiderOptions(.key_names = {"height", "width"}),
+/// .target = {"key", "value"},
+/// .name = {"properties"})
+///
+/// then the output will have the schema
+/// `{"group": int32, "properties": struct{"height": int16, "width": int16}}`
+/// and the following value:
+/// ```
+/// group | properties
+/// | height | width
+/// -----------------------------
+/// 1 | 11 | 12
+/// 2 | null | 13
+/// 3 | 14 | null
+/// ```
+class ARROW_EXPORT PivotWiderOptions : public FunctionOptions {
Review Comment:
Well, because there is already a node named "pivot_longer".
https://github.com/apache/arrow/blob/0fbf9823542233c5f32c26534c34cc97ce3f0be2/cpp/src/arrow/acero/pivot_longer_node.cc#L4
Besides, I find "pivot_wider" / "pivot_longer" more explanatory than "pivot"
/ "melt" or other alternatives.
--
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]