* (asterisk sign) operator
Applies to: Databricks SQL
Databricks Runtime
Returns multiplier multiplied by multiplicand.
Syntax
multiplier * multiplicand
Arguments
multiplier: A numeric orINTERVALexpression.multiplicand: A numeric expression orINTERVALexpression.
You may not specify an INTERVAL for both arguments.
Returns
- If both
multiplierandmultiplicandareDECIMAL, the result isDECIMAL. - If
multiplierormultiplicandis anINTERVAL, the result is of the same type. - If both
multiplierandmultiplicandare integral numeric types, the result is the larger of the two types. - In all other cases the result is a
DOUBLE.
If either the multiplier or the multiplicand is 0, the operator returns 0.
If the result of the multiplication is outside the bound for the result type an ARITHMETIC_OVERFLOW error is raised.
Use try_multiply to return NULL on overflow.
warning
In Databricks Runtime, if spark.sql.ansi.enabled is false, the result “wraps” if it is out of bounds for integral types, and the result is NULL for fractional types.
Examples
SQL
> SELECT 3 * 2;
6
> SELECT 2L * 2L;
4L
> SELECT INTERVAL '3' YEAR * 3;
9-0
> SELECT 100Y * 100Y;
Error: ARITHMETIC_OVERFLOW