Skip to main content

math

math [expression]

Runs the mathematical expression provided. The equal sign must be on the left side of the expression (ex. math "sum = 10 + column") and columns used in the expression should have type number as row values (5 - ok vs. "5" - fail). See the tonumber command for casting/converting string values to numbers.

arguments:

expression

A mathematical expression to perform on the results. (ex. math "sum = (10 + column) / 60") (type: string)

examples:

Query

seed '[{"column": 10, "column2": 50},{"column": 5, "column2": 10}]'
|| math "x = (column + 5) * column2"

Results prior to math stage:

columncolumn2
1050
510

Results after math stage:

columncolumn2x
1050750
510100

Query

seed '[{"column": "10", "column2": "50"},{"column": "5", "column2": "10"}]'
|| tonumber column
|| tonumber column2
|| math "x = (column + 5) * column2"

Results prior to math stage:

columncolumn2
"10""50"
"5""10"

Results after math stage:

columncolumn2x
1050750
510100

flags:

--appendStage

Used to append the results from a previous stage to the current stage. (provide a label, stage index, or boolean true to append the previous results)

--cache

A boolean value of true/false that determines whether or not to use the cache. Generally most commands will default to true.

--checkpoint

Format: "{CHECKPOINT NAME}:{COLUMN}" Used to store the value of the provided column (in the first row of results) in the provided name for use as a checkpoint in scheduled queries or other stages. Not encrypted. Can be accessed using $CHECKPOINTS.{CHECKPOINT NAME}$

--filter

A filter to run on the command results before completing the command. If not provided, no filter is run on the results.

--guid

Adds a populated random guid column.

--labelStage

Used to label a stage with a user provided label.

--randomizeHash

Randomizes the stage hash, even if args and flags are the same.

--stats

Controls if a stats calculation is run on a stage after it completes.

--table

A comma separated list of columns to include in the command results. If not provided, all columns will be included.

--type

Each command has a default type, either "mapping" or "reducing". Some commands can operate as either, when "reducing" they will operate on all rows at once, when "mapping", they will operate on one row at a time.

--variable

Format: "{VARIABLE NAME}:{COLUMN}" Used to store the value of the provided column (in the first row of results) in the provided name for use as a variable in other stages. Can be accessed using $VARIABLES.{VARIABLE NAME}$. Stored as an encrypted secret. Not stored across queries.

support

AMI_ENTERPRISE AMI_FREE AMI_PRO BINARY_ENTERPRISE BINARY_FREE BINARY_PRO DESKTOP_ENTERPRISE DESKTOP_FREE DESKTOP_PRO DOCKER_ENTERPRISE DOCKER_FREE DOCKER_PRO