MCPcopy Create free account
hub / github.com/apache/arrow / AdjustForHashAggregate

Function AdjustForHashAggregate

python/pyarrow/src/arrow/python/udf.cc:565–588  ·  view source on GitHub ↗

\brief Create a new UdfOptions with adjustment for hash kernel \param options User provided udf options

Source from the content-addressed store, hash-verified

563/// \brief Create a new UdfOptions with adjustment for hash kernel
564/// \param options User provided udf options
565UdfOptions AdjustForHashAggregate(const UdfOptions& options) {
566 UdfOptions hash_options;
567 // Append hash_ before the function name to separate from the scalar
568 // version
569 hash_options.func_name = "hash_" + options.func_name;
570 // Extend input types with group id. Group id is appended by the group
571 // aggregation node. Here we change both arity and input types
572 if (options.arity.is_varargs) {
573 hash_options.arity = options.arity;
574 } else {
575 hash_options.arity = compute::Arity(options.arity.num_args + 1, false);
576 }
577 // Changing the function doc shouldn't be necessarily because group id
578 // is not user visible, however, this is currently needed to pass the
579 // function validation. The name group_id_array is consistent with
580 // hash kernels in hash_aggregate.cc
581 hash_options.func_doc = options.func_doc;
582 hash_options.func_doc.arg_names.emplace_back("group_id_array");
583 std::vector<std::shared_ptr<DataType>> input_dtypes = options.input_types;
584 input_dtypes.emplace_back(uint32());
585 hash_options.input_types = std::move(input_dtypes);
586 hash_options.output_type = options.output_type;
587 return hash_options;
588}
589
590Status RegisterHashAggregateFunction(PyObject* function, UdfWrapperCallback cb,
591 const UdfOptions& options,

Callers 1

Calls 2

ArityFunction · 0.85
emplace_backMethod · 0.80

Tested by

no test coverage detected