Skip to content
Advertisement

How to calculate the dot product of two 1-d array fields in bigquery?

Maybe more of a standard sql question (it might use some of bigquery’s array functions somehow though), but wondering how to concisely calculate the dot product of two (same-sized) vector fields of a table

I’m looking for what the details are for the sql in the “[ ]” here:

Select [dot product formula involving a.vector1 and a.vector2] from a

thanks

Advertisement

Answer

Below is simple example to demonstrate approach
For BigQuery Standard SQL

with result

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement