Shape / columns · All operations

Apply a maths function

Numeric functions: arithmetic, rounding, trigonometry.

Status

In arcform

Runs as a SQL step

arcform carries it as a sql: step today.

Shape of the result
one row out per row in, with columns added or changed
Level
one clause of SQL

The DuckDB step

Numeric functions

It reads the orders table the proofs share. Create it first:

SQL
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);

Then run the statement:

SQL
CREATE TEMP TABLE result AS
SELECT amount, round(ln(amount), 3) AS ln_amount, sqrt(amount) AS root, amount % 7 AS mod7 FROM orders WHERE amount > 0;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT max(ln_amount) FILTER (WHERE amount = 120) = 4.787 AND max(mod7) FILTER (WHERE amount = 120) = 1 AND abs(max(root * root) FILTER (WHERE amount = 300) - 300) < 1e-9 FROM result)) THEN 'as expected' ELSE error('a logarithm, a root or a remainder is wrong') END AS verdict;
  • It needs nothing installed beyond DuckDB itself.
  • The statement checks its own result and raises an error when it is wrong: “a logarithm, a root or a remainder is wrong”.
  • It passed on DuckDB v2.0.0 (Cyanoptera) d54cbbe3df.

Variants

Apply a numeric function

Compute a logarithm, power, root, absolute value, trigonometric or other scalar function of a number in each row.

Find the largest or total across columns

Return the maximum, minimum, sum or mean of several columns within each row.

What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

Apache DataFusion (3)
Apache NiFi (2)
Apache SeaTunnel (1)
  • Numeric Functionsread 2026-09-27

    29 functions: ABS, ACOS, ARRAY_MAX, ARRAY_MIN, ASIN, …

AWS Glue (1)
  • IsEvenread 2026-09-27

    Add a boolean column telling whether a number is even

Azure Data Factory (1)
  • Math functionsread 2026-09-27

    9 functions: add, div, max, min, mod, …

Bruin (4)
dbt-utils (3)
  • safe_addread 2026-09-27

    Sum nullable fields, treating nulls as zero

  • safe_divideread 2026-09-27

    Divide two expressions, returning null when the denominator is 0

  • safe_subtractread 2026-09-27

    Subtract nullable fields, treating nulls as zero

DuckDB (1)
Duckle (8)
  • Absoluteread 2026-09-25

    absolute value

  • Clampread 2026-09-25

    clip values to a low and high bound

  • Logarithmread 2026-09-25

    logarithm

  • Moduloread 2026-09-25

    modulo

  • Powerread 2026-09-25

    raise to a power

  • Roundread 2026-09-25

    round a number

  • Signread 2026-09-25

    sign of a number

  • Square Rootread 2026-09-25

    square root

Ibis (45)
  • Absread 2026-09-27

    Absolute value

  • Acosread 2026-09-27

    Arc cosine

  • Addread 2026-09-27

    Add two values

  • Asinread 2026-09-27

    Arc sine

  • Atanread 2026-09-27

    Arc tangent

  • Atan2read 2026-09-27

    Two-argument arc tangent

  • BaseConvertread 2026-09-27

    Rewrite a number from one numeric base into another

  • BitwiseAndread 2026-09-27

    Bitwise AND of two integers

  • BitwiseLeftShiftread 2026-09-27

    Shift the bits of an integer left

  • BitwiseNotread 2026-09-27

    Bitwise NOT of an integer

  • BitwiseOrread 2026-09-27

    Bitwise OR of two integers

  • BitwiseRightShiftread 2026-09-27

    Shift the bits of an integer right

  • BitwiseXorread 2026-09-27

    Bitwise XOR of two integers

  • Ceilread 2026-09-27

    Round up to the nearest integer

  • Clipread 2026-09-27

    Limit a value to a lower and an upper bound

  • Cosread 2026-09-27

    Cosine

  • Cotread 2026-09-27

    Cotangent

  • Degreesread 2026-09-27

    Convert radians to degrees

  • Divideread 2026-09-27

    Divide the left value by the right

  • Eread 2026-09-27

    The constant e

  • Expread 2026-09-27

    Exponential function

  • Floorread 2026-09-27

    Round down to the nearest integer

  • FloorDivideread 2026-09-27

    Divide the left value by the right and round down to an integer

  • Greatestread 2026-09-27

    Largest value across a list of expressions, row by row

  • IsInfread 2026-09-27

    Test whether a float is infinite

  • IsNanread 2026-09-27

    Test whether a float is NaN

  • Leastread 2026-09-27

    Smallest value across a list of expressions, row by row

  • Lnread 2026-09-27

    Natural logarithm

  • Logread 2026-09-27

    Logarithm to a given base

  • Log10read 2026-09-27

    Base-10 logarithm

  • Log2read 2026-09-27

    Base-2 logarithm

  • Modulusread 2026-09-27

    Remainder of dividing the left value by the right

  • Multiplyread 2026-09-27

    Multiply two values

  • Negateread 2026-09-27

    Flip the sign of a value

  • Piread 2026-09-27

    The constant pi

  • Powerread 2026-09-27

    Raise the left value to the power of the right

  • Radiansread 2026-09-27

    Convert degrees to radians

  • RandomScalarread 2026-09-27

    Random float between 0 and 1

  • Roundread 2026-09-27

    Round to a given number of digits

  • Signread 2026-09-27

    Sign of a value

  • Sinread 2026-09-27

    Sine

  • Sqrtread 2026-09-27

    Square root

  • Subtractread 2026-09-27

    Subtract the right value from the left

  • Tanread 2026-09-27

    Tangent

  • Tanhread 2026-09-27

    Hyperbolic tangent

KNIME Analytics Platform (3)
  • Math Formularead 2026-09-27

    Evaluate a mathematical formula per row, appending or replacing a column

  • Evaluate one mathematical formula over each of several columns

  • Number Rounderread 2026-09-27

    Round numeric columns to decimal places or significant figures with a chosen rounding mode

mlpack (1)
  • Mathread 2026-09-27

    Core mathematical utility classes used by the methods

OpenRefine (1)
  • Math functionsread 2026-09-27

    34 functions: round, floor, mod, pow, random

Polars (12)
Power Query M (1)
  • Number functionsread 2026-09-27

    52 functions: Number.Round, Number.FromText, Number.Mod, Number.RandomBetween, Number.BitwiseAnd

RapidMiner Studio (4)
  • Add Noiseread 2026-09-27

    Add random noise to existing columns and append random columns

  • Generate Absolutesread 2026-09-27

    Replace numeric values with their absolute values

  • Generate Gaussiansread 2026-09-27

    Add a column holding a Gaussian function of a column for a given mean and sigma

  • Generate Productsread 2026-09-27

    Add columns holding the pairwise products of selected numeric columns

SQLMesh (3)
  • @SAFE_ADDread 2026-09-27

    Add two or more operands treating NULL as 0; NULL when all are NULL

  • @SAFE_DIVread 2026-09-27

    Divide two numbers, returning NULL when the denominator is 0

  • @SAFE_SUBread 2026-09-27

    Subtract two or more operands treating NULL as 0; NULL when all are NULL

subtoken (1)
Tableau Prep (1)
  • 27 functions: ABS, ROUND, DIV, HEXBINX, ZN; arithmetic, rounding, logs, trigonometry, hex bins

Trifacta (3)
  • Math Functions (group)read 2026-09-27

    20 functions: NUMFORMAT, MOD, LOG, ROUND, NUMVALUE; arithmetic, rounding, logs, number formatting

  • Numeric Operatorsread 2026-09-27

    Add, subtract, multiply, divide operators computing a value from two operands

  • 14 functions: SIN, COS, ATAN, TANH, RADIANS; trigonometric, hyperbolic and angle conversion

Background

DuckDB's numeric functions include logarithms, powers, roots, absolute values, trigonometric and hyperbolic functions, and the largest of several values.[1] Rounding is almost unavoidable when reporting many computations, especially those of mathematical functions such as square roots, logarithms and sines.[2]

When to use it

In DuckDB, a function that has a NULL input argument usually returns NULL, so cos(NULL) is NULL.[3]

In DuckDB, ln computes the natural logarithm and log computes the base-10 logarithm.[1] In PostgreSQL, log with one argument is also the base 10 logarithm, and a two-argument form takes the base first.[4] Check which logarithm a function name means in the system at hand before porting a formula from another language or a spreadsheet. (Meridian's view)

In PostgreSQL, each trigonometric function comes in two variants, one measuring angles in radians and one in degrees.[4] PostgreSQL prefers its degree-based trigonometric functions to converting with radians() and degrees(), because they avoid round-off error in special cases such as sind(30).[4] DuckDB provides radians() to convert degrees to radians and degrees() to convert radians to degrees.[1] Check which unit an angle column is in before taking its sine or cosine. (Meridian's view)

In double precision, 0.1 + 0.2 - 0.3 evaluates to about 5.551×10⁻¹⁷ instead of the expected 0, because none of the three numbers has a finite binary expansion.[5] PostgreSQL implements its double precision functions mostly on top of the host system's C library, so their accuracy and behaviour in boundary cases can vary by host.[4] Compare floating-point results within a small tolerance rather than for exact equality, and round them only when they are reported. (Meridian's view)

The method

In 1985 the IEEE 754 Standard for Floating-Point Arithmetic was established, and since the 1990s the most commonly encountered floating-point representations are those it defines.[5] In DuckDB, the FLOAT and DOUBLE types are in practice usually implementations of IEEE 754 single and double precision.[6]

IEEE 754 guarantees that add, subtract, multiply, divide, fused multiply–add, square root and floating-point remainder give the correctly rounded result of the infinite-precision operation.[2] The 1985 version of IEEE 754 gave no such guarantee for more complex functions, which are typically only accurate to within the last bit at best.[2] Floating-point addition and multiplication are commutative but not necessarily associative, so (a + b) + c is not necessarily equal to a + (b + c).[5]

Compared with the alternatives

In PostgreSQL, GREATEST and LEAST select the largest or smallest value from a list of any number of expressions.[7] Reach for GREATEST or LEAST to compare values across the columns of one row, and for an aggregate such as max to summarise a whole column. (Meridian's view)

Used in

5 Protocols use this operation: