Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Numeric Functions

Reference of the SQL numeric functions supported by GridGain — trigonometric, logarithmic, bitwise, rounding, random, encryption, and compression functions.

ABS

Description

Returns the absolute value of an expression.

ABS (expression)

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate an absolute value:

SELECT transfer_id, ABS (price) from Transfers;

ACOS

Description

Calculates the arc cosine, returns a double.

ACOS (expression)

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate the arc cos value:

ASIN

Description

Calculates the arc sine, returns a double.

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate an arc sine:

ATAN

Description

Calculates the arc tangent, returns a double.

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate an arc tangent:

COS

Description

Calculates the trigonometric cosine, returns a double.

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate a cosine:

COSH

Description

Calculates the hyperbolic cosine, returns a double.

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate n hyperbolic cosine:

COT

Description

Calculates the trigonometric cotangent (1/TAN(ANGLE)), returns a double.

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate trigonometric cotangent:

SIN

Description

Calculates the trigonometric sine, returns a double.

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate a trigonometric sine:

SINH

Description

Calculates the hyperbolic sine, returns a double.

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate a hyperbolic sine:

TAN

Description

Calculates the trigonometric tangent, returns a double.

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate a trigonometric tangent:

TANH

Description

Calculates the hyperbolic tangent, returns a double.

Parameters

expression - may be a column name, a result of another function, or a math operation

Example

Calculate a hyperbolic tangent:

ATAN2

Description

Calculates the angle when converting the rectangular coordinates to the polar coordinates, returns a double.

Parameters

x and y - the arguments

Example

Calculate a 2-argument arctangent:

BITAND

Description

The bitwise AND operation, returns a long.

Parameters

x and y - the arguments.

Example

Return the bitwise AND:

BITGET

Description

Returns true if and only if the first parameter has a bit set in the position specified by the second parameter. The second parameter is zero-indexed; the least significant bit has position 0.

Parameters

x and y - the arguments

Example

Verify that the third bit is 1:

BITOR

Description

The bitwise OR operation, returns a long.

Parameters

x and y - the arguments

Example

Perform the bitwise OR operation:

BITXOR

Description

The bitwise XOR operation, returns a long.

Parameters

x and y - the arguments

Example

Perform the bitwise XOR operation:

MOD

Description

The modulo operation, returns a long.

Parameters

x and y - the arguments

Example

Calculate MOD between two fields:

CEILING

Description

Returns the smallest integer value that is greater than, or equal to, the argument. The returned value is of the same type as the argument, with the scale set to 0 the precision adjusted (if applicable).

Parameters

expression - any valid numeric expression

Example

Calculate a ceiling price for items:

DEGREES

Description

Converts an angle measured in radians to an approximately equivalent angle measured in degrees, returns a double.

Parameters

expression - any valid numeric expression

Example

Convert radians to degrees:

EXP

Description

Calculates E raised to the power of x, returns a double.

Parameters

expression - any valid numeric expression

Example

Calculate exp(X):

FLOOR

Description

Returns the largest integer value that is less than, or equal to, the argument. The returned value is of the same type as the argument, with the scale set to 0 the precision adjusted (if applicable).

Parameters

expression - any valid numeric expression

Example

Calculate a floor price:

LOG

Description

Calculates the natural logarithm (base e) of a double value, returns a double.

Parameters

expression - any valid numeric expression

Example

Calculate a natural logarithm:

LOG10

Description

Calculates the base 10 logarithm of a double value, returns a double.

Parameters

expression - any valid numeric expression

Example

Calculate a base 10 algorithm:

RADIANS

Description

Converts an angle measured in degrees to an approximately equivalent angle measured in radians, returns a double.

Parameters

expression - any valid numeric expression

Example

Calculate RADIANS:

SQRT

Description

Calculates the correctly rounded positive square root of a double value, returns a double.

Parameters

expression - any valid numeric expression

Example

Calculate a square root:

PI

Description

Returns Pi as a static final double constant.

Example

Calculate Pi:

POWER

Description

Calculates a number raised to the power of some other number, returns a double.

Parameters

  • x - the base

  • y - the power

Example

Calculate n in the power of 2:

RAND

Description

When called without a parameter, returns a pseudo random number. When called with a parameter, seeds the session's random number generator. Returns a double between 0 (including) and 1 (excluding).

Parameters

expression - any valid numeric expression

Example

Return a random number for every play:

RANDOM_UUID

Description

Returns a new UUID with 122 pseudo random bits.

Example

Return a random number for every Player:

ROUND

Description

Rounds to the specified number of digits, or to the nearest long (if the number of digits if not specified). Returns a numeric (the same type as the input).

Parameters

  • expression - any valid numeric expression

  • precision - the number of digits after the decimal point to round to

Example

Convert every Player's age to an integer:

ROUNDMAGIC

Description

Rounds numbers. Has a special handling algorithm for numbers around 0. Only numbers smaller than or equal to +/-1000000000000 are supported. The value is converted to a string internally, and then the last 4 characters are checked. '000x' becomes '0000' and '999x' becomes '999999', which is rounded automatically. This function returns a double.

This function can be slow.

Parameters

expression - any valid numeric expression

Example

Round every Player's age:

SECURE_RAND

Description

Generates a number of cryptographically secure random numbers, returns bytes.

Parameters

int - the number of digits

Example

Get a truly random number:

SIGN

Description

Returns -1 if the value is smaller than zero, 0 if zero, 1 otherwise.

Parameters

expression - any valid numeric expression

Example

Get a sign for every value:

ENCRYPT

Description

Encrypts data using a key. The supported algorithm is AES. The block size is 16 bytes. Returns bytes.

Parameters

  • algorithmString - the AES algorithm

  • keyBytes - the key

  • dataBytes - data block size

Example

Encrypt players names:

DECRYPT

Description

Decrypts data using a key. The supported algorithm is AES. The block size is 16 bytes. Returns bytes.

Parameters

  • algorithmString - the AES algorithm

  • keyBytes - the key

  • dataBytes - data block size

Example

Decrypt Players' names:

TRUNCATE

Description

Truncates to a number of digits (to the next value closer to 0). Returns a double. When used with a timestamp, truncates the timestamp to the date (day) value. When used with a date, truncates the date to the date (day) value less the time part. When used with a timestamp as string, truncates the timestamp to a date (day) value.

Parameters

  • digitsInt - the number for digits to truncate to

  • timestamp - the timestamp to truncate

  • date - the date to truncate to

  • timestampString - the timestamp expressed as a string

Example

Truncate teg value to 2 digits:

COMPRESS

Description

Compresses the data using the specified compression algorithm. The supported algorithms are: LZF (faster but lower compression; default) and DEFLATE (higher degree of compression). Compression does not always reduce size. Very small objects and objects with little redundancy may get larger. This function returns bytes.

Parameters

  • dataBytes - the data to compress

  • algorithmString - the algorithm to use for compression

Example

Compress STRINGTOUTF8 using the LZF (default) algorithm:

EXPAND

Description

Expands data that was previously compressed using the the COMPRESS function, returns bytes.

Parameters

dataBytes - the data to expand

Example

Converts the string to UTF8 format, compress it, expand it, and converts it back to Unicode:

ZERO

Description

Returns the value of 0. Can be used even if numeric literals are disabled.

Example

Return 0:

This page is: Copyright © 2026 MariaDB. All rights reserved.

Last updated

Was this helpful?