You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
We would like to compute a power function (like 2**4 = 2 * 2 * 2 * 2) in datafusion
power ( a numeric, b numeric ) → numeric
power ( a double precision, b double precision ) → double precision
a raised to the power of b
power(9, 3) → 729
Describe alternatives you've considered
It may also be interesting to investigate adding support for a**b as another way to write the same thing
Additional context
This is probably a good ticket to learn about the datafusion codebase and its function implementations -- one could follow the example of one of the existing functions in
ive started looking into this and i think it makes sense to add power / power_scalar compute kernels to arrow first then expose it in physical_plan/expressions/binary.rs and physical_plan/expressions/functions.rs
@matthewmturner I think power is more like a function rather than an operator -- so in that case I think you could just add power to BuiltinScalarFunction (and then fill in the implementation):
Activity
matthewmturner commentedon Dec 28, 2021
ill work on this
matthewmturner commentedon Dec 29, 2021
ive started looking into this and i think it makes sense to add
power/power_scalarcompute kernels to arrow first then expose it inphysical_plan/expressions/binary.rsandphysical_plan/expressions/functions.rs@alamb ok with that?
alamb commentedon Dec 30, 2021
@matthewmturner I think
poweris more like afunctionrather than anoperator-- so in that case I think you could just addpowertoBuiltinScalarFunction(and then fill in the implementation):https://github.com/apache/arrow-datafusion/blob/5668be78a9ccbf5469e9e95ad070920ca5d105ba/datafusion/src/physical_plan/functions.rs
matthewmturner commentedon Dec 30, 2021
@alamb ok happy to do that.
but just to show you where i was coming from, i saw both C++ (https://arrow.apache.org/docs/cpp/compute.html#arithmetic-functions) and arrow2 (https://github.com/jorgecarleitao/arrow2/blob/main/src/compute/arithmetics/basic/pow.rs) had kernels for power. so i thought we would want to do something similar and not have datafusion implement something that could / should be done downstream.
alamb commentedon Dec 30, 2021
@matthewmturner -- I don't have a strong preference.