Skip to content

Implement power function #1493

@alamb

Description

@alamb

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

@matthewmturner asks for it here: #147 (comment)

Describe the solution you'd like

Implement the power function as described in https://www.postgresql.org/docs/14/functions-math.html

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

https://github.com/apache/arrow-datafusion/blob/master/datafusion/src/physical_plan/functions.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions