Skip to content

Instantly share code, notes, and snippets.

View gregpriday's full-sized avatar

Greg Priday gregpriday

View GitHub Profile
@demdxx
demdxx / mysql_cosine_similarity.sql
Created July 18, 2020 19:33
Cosine Similarity implementation in MySQL
-- for calculation of norm vector --
DELIMITER $$
CREATE FUNCTION vector_norm( vector JSON )
RETURNS DOUBLE
READS SQL DATA
DETERMINISTIC
BEGIN
DECLARE array_length INTEGER(11);
DECLARE retval DOUBLE(19,2);