SIGN

Returns the signum function of the given input, that is:

  • 0 if the argument is 0

  • 1 if the argument is greater than 0

  • -1 if the argument is less than 0

Syntax

SIGN(X)

Arguments

X

Type: numeric

A numeric value.

Returns

Type: same as input

A value 1, 0, or -1 indicating the sign of X.


Examples

XOutput

1

1

-1

-1

0

0

1.1

1.0

-1.35

-1.0

3

1

Transformation job example

SQL

CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true	
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT SIGN(-1.35) AS sign_example
    FROM default_glue_catalog.upsolver_samples.orders_raw_data 
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;

Query result

sign_example

-1.0

Last updated