DOT_PRODUCT

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Computes the conventional dot product (scalar product) of two vectors.

Syntax 

1DOT_PRODUCT(<array1>, <array2>)

Arguments 

Required 

  • <array1>: The first vector (array(real) or array(double precision)).
  • <array2>: The second vector (array(real) or array(double precision)).

Returns 

Returns a double-precision value that represents the dot product of the two vectors.

Considerations 

  • Both input arrays must be of the same element type and length.
  • If any element is NULL, the result is NULL.
  • For optimal performance, use array definitions with non-nullable elements such as array(real not null).

Examples 

Calculate Dot Product 

Compute the dot product of two vectors.

1SELECT DOT_PRODUCT(array[1, 2, 3], array[-1, 2, -3]) AS result;

Returns -6.0, calculated as (1 × -1) + (2 ×2 ) + (3 × -3) = -1 + 4 - 9 = -6.

Related Documentation 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!