Skip to content

Add the math functions SIGN / CBRT / TRUNC #790

Description

@Leomrlin

What & why

The math folder udf/table/math/ currently has only E, Log2, and Round
noticeably thin. Adding SIGN (the sign of a number), CBRT (cube root), and
TRUNC (truncate to N decimals) is a quick win that meaningfully fills out the
SQL toolbox.

数学函数目录现在只有 ELog2Round 三个,明显偏薄。补上 SIGN(符号)、
CBRT(立方根)、TRUNC(截断到指定小数位),花不了多少时间,却能明显补全 SQL 表达力。

The task

  • sign(x) → -1 / 0 / 1
  • cbrt(x) → cube root
  • trunc(x, d) → truncate (not round) to d decimal places

Where to look

  1. Follow udf/table/math/Round.java; in the same folder add Sign.java,
    Cbrt.java, Trunc.java (extend UDF, add @Description).
  2. Register them in BuildInSqlFunctionTable.java.
  3. Add tests under query/ + expect/ in geaflow-dsl-runtime, covering
    negative numbers, zero, and null.

Done when

  • Three functions implemented and registered
  • Negative / zero / null edge cases covered
  • trunc vs round clearly distinguished (truncate ≠ round) — show an example in the PR
  • Tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    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