Thanks Jin! That's perfect.

On Thu, Jun 15, 2023 at 11:21 PM Jin Shang <shangjin1...@gmail.com> wrote:

> Hi Li,
>
> I've faced this issue before, and I ended up using a generic ArrayBuilder,
> for example:
>
> ```cpp
> auto type = int32();
> std::vector<std::shared_ptr<Scalar>> scalars = {MakeScalar(1),
> MakeScalar(2)};
>
> ARROW_ASSIGN_OR_RAISE(std::unique_ptr<ArrayBuilder> builder,
> MakeBuilder(type));
> ARROW_RETURN_NOT_OK(builder->AppendScalars(scalars));
> ARROW_ASSIGN_OR_RAISE(auto arr, builder->Finish());
> ```
>
> Best,
> Jin
>
>
> On Fri, Jun 16, 2023 at 5:23 AM Li Jin <ice.xell...@gmail.com> wrote:
>
> > Hi,
> >
> > I find myself in need of a function to turn a vector of Scalar to an
> Array
> > of the same datatype. The data type is known at the runtime. e.g.
> >
> > shared_ptr<ArrayData> concat_scalars(vector<shared_ptr<Scalar> values.
> > shared_ptr<DataType> type);
> >
> > I wonder if I need to use sth like Scalar::Accept(ScalarVisitor*) or is
> > there an easier/better way to achieve this?
> >
> > For context, I am trying to implement UDF support for hash aggregation,
> > each UDF invocation will give me back one Scalar (for each group), and I
> > need to concat them in the HashAggregateKernel finalize method. So
> > performance is not a large concern here, time in the UDF would likely
> > dominate the total runtime.
> >
> > Thanks!
> > Li
> >
>

Reply via email to