Skip to content

Commit

Permalink
Address comments and rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
liujiayi771 committed Mar 30, 2024
1 parent b89d2ee commit c4dd224
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions velox/docs/functions/spark/aggregate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ General Aggregate Functions

``hash`` cannot be null.

.. spark:function:: collect_list(x) -> array<[same as x]>
Returns an array created from the input ``x`` elements. Ignores null
inputs, and return an empty array when all inputs are null.

.. spark:function:: first(x) -> x
Returns the first value of `x`.
Expand Down
9 changes: 5 additions & 4 deletions velox/functions/sparksql/aggregates/CollectListAggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

#include "velox/functions/sparksql/aggregates/CollectListAggregate.h"

#include "velox/exec/SimpleAggregateAdapter.h"
#include "velox/functions/lib/aggregates/ValueList.h"

using namespace facebook::velox::aggregate;
using namespace facebook::velox::exec;

Expand Down Expand Up @@ -48,8 +51,6 @@ class CollectListAggregate {
struct AccumulatorType {
ValueList elements_;

AccumulatorType() = delete;

explicit AccumulatorType(HashStringAllocator* /*allocator*/)
: elements_{} {}

Expand Down Expand Up @@ -81,7 +82,7 @@ class CollectListAggregate {
bool /*nonNullGroup*/,
exec::out_type<IntermediateType>& out) {
// If the group's accumulator is null, the corresponding intermediate
// result is an empty list.
// result is an empty array.
copyValueListToArrayWriter(out, elements_);
return true;
}
Expand All @@ -90,7 +91,7 @@ class CollectListAggregate {
bool /*nonNullGroup*/,
exec::out_type<OutputType>& out) {
// If the group's accumulator is null, the corresponding result is an
// empty list.
// empty array.
copyValueListToArrayWriter(out, elements_);
return true;
}
Expand Down
3 changes: 1 addition & 2 deletions velox/functions/sparksql/aggregates/CollectListAggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

#pragma once

#include "velox/exec/SimpleAggregateAdapter.h"
#include "velox/functions/lib/aggregates/ValueList.h"
#include <string>

namespace facebook::velox::functions::aggregate::sparksql {

Expand Down

0 comments on commit c4dd224

Please sign in to comment.