You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by Li Jin <ic...@gmail.com> on 2025/02/21 21:10:11 UTC

[Arrow Compute] Question on function chaining / math formular

Dear Arrow Devs,

I wonder if there is a nice way to do function chaining / math formular
with Arrow compute? (Either Python or C++?)

To give an example, let say I have three arrays a, x and y and want to
compute:

x * (1 - a) + y * a

Right now I can do this in pyarrow but pretty hard to read:

from pyarrow.compute import add, subtract, multiply

result = add(multiply(x, subtract(1, a)), multiply(y, a))

And it is probably harder to do this in C++ because the Result<Datum>
return type.

I wonder if there is a better way to do this kind of computation?

Thank you,
Li

Re: [Arrow Compute] Question on function chaining / math formular

Posted by "Lee, David (ITE)" <Da...@blackrock.com.INVALID>.
There might be something in Acero, but this something I’ve been planning to work on..

https://github.com/apache/arrow/issues/39128

Parse formula into relationship operators.

Wrap * operator with pc.multiply
Wrap - operator with pc.subtract
Etc. etc.
________________________________
From: Li Jin <ic...@gmail.com>
Sent: Friday, February 21, 2025 1:10:11 PM
To: dev@arrow.apache.org <de...@arrow.apache.org>
Subject: [Arrow Compute] Question on function chaining / math formular

External Email: Use caution with links and attachments


Dear Arrow Devs,

I wonder if there is a nice way to do function chaining / math formular
with Arrow compute? (Either Python or C++?)

To give an example, let say I have three arrays a, x and y and want to
compute:

x * (1 - a) + y * a

Right now I can do this in pyarrow but pretty hard to read:

from pyarrow.compute import add, subtract, multiply

result = add(multiply(x, subtract(1, a)), multiply(y, a))

And it is probably harder to do this in C++ because the Result<Datum>
return type.

I wonder if there is a better way to do this kind of computation?

Thank you,
Li

This message may contain information that is confidential or privileged. If you are not the intended recipient, please advise the sender immediately and delete this message. See http://www.blackrock.com/corporate/compliance/email-disclaimers for further information.  Please refer to http://www.blackrock.com/corporate/compliance/privacy-policy for more information about BlackRock’s Privacy Policy.


For a list of BlackRock's office addresses worldwide, see http://www.blackrock.com/corporate/about-us/contacts-locations.

© 2025 BlackRock, Inc. All rights reserved.