---
title: vector_inner_product function
description: Learn the syntax of the vector\_inner\_product function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/gcp/en/sql/language-manual/functions/vector_inner_product
---

# `vector_inner_product` function

**Applies to:** ![check marked yes](https://docs.databricks.com/gcp/en/images/icons/check.png) Databricks Runtime 18.1 and above

Computes the inner product (dot product) between two vectors.

## Syntax

```
vector_inner_product(vector1, vector2)
```

## Arguments

* **vector1**: An `ARRAY<FLOAT>` expression representing the first vector.
* **vector2**: An `ARRAY<FLOAT>` expression representing the second vector.

## Returns

A `FLOAT` value representing the inner product of the two vectors.

Returns 0.0 for empty vectors. Returns `NULL` if either input is `NULL` or contains `NULL`.

## Notes

* Only `ARRAY<FLOAT>` is supported; other types such as `ARRAY<DOUBLE>` or `ARRAY<DECIMAL>` raise an error.
* Both vectors must have the same dimension; otherwise the function raises [VECTOR\_DIMENSION\_MISMATCH](https://docs.databricks.com/gcp/en/error-messages/error-classes.md#vector_dimension_mismatch).
* For normalized vectors, the inner product equals cosine similarity. Commonly used with Maximum Inner Product Search (MIPS) algorithms.

## Error conditions

* [VECTOR\_DIMENSION\_MISMATCH](https://docs.databricks.com/gcp/en/error-messages/error-classes.md#vector_dimension_mismatch)

## Examples

```sql
-- Basic inner product
> SELECT vector_inner_product(array(1.0f, 2.0f, 3.0f), array(4.0f, 5.0f, 6.0f));
  32.0

-- Inner product of orthogonal unit vectors
> SELECT vector_inner_product(array(1.0f, 0.0f), array(0.0f, 1.0f));
  0.0

-- Inner product with itself (squared L2 norm)
> SELECT vector_inner_product(array(3.0f, 4.0f), array(3.0f, 4.0f));
  25.0
```

## Related functions

* [`vector_cosine_similarity` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/vector_cosine_similarity.md)
* [`vector_l2_distance` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/vector_l2_distance.md)
* [`vector_normalize` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/vector_normalize.md)
* [`vector_norm` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/vector_norm.md)
