Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to user defined functions in Google's Cloud SQL

I just transferred my database to Google's Cloud SQL, but as stated in the FAQ on Google Cloud SQL, it says user defined functions are not supported. I am using a function called Levenshtein, taken from this stackoverflow article, to perform a search on a dictionary that I created in my database. It is a function that can find words that look similar (including misspellings) and returns the distance from a given word.

Does Google offer any alternatives to user defined functions that would allow me to use this functionality to perform search?

like image 308
Roel Vermeulen Avatar asked Apr 18 '15 09:04

Roel Vermeulen


People also ask

What are the different types of user-defined functions in SQL and when will you use them?

There are three types of user-defined functions in SQL Server: Scalar Functions (Returns A Single Value) Inline Table Valued Functions (Contains a single TSQL statement and returns a Table Set) Multi-Statement Table Valued Functions (Contains multiple TSQL statements and returns Table Set)

What are the different languages in which you can write user-defined functions in Bigquery for querying data?

A user-defined function (UDF) lets you create a function by using a SQL expression or JavaScript code.

Can you define functions in SQL?

Like functions in programming languages, SQL Server user-defined functions are routines that accept parameters, perform an action, such as a complex calculation, and return the result of that action as a value. The return value can either be a single scalar value or a result set.

Can you modify data inside a UDF?

You cannot modify data inside of a UDF. A scalar-valued UDF returns only one value, where a stored procedure can have numerous OUTPUT parameters. You can use scalar-valued UDFs as the default value for a column in a table.


1 Answers

You are confused about terminology:

  • User Defined Function = A function defined in real code, compiled into a DLL/SO, and created in MySQL with CREATE FUNCTION ... SONAME. This is not possible in Cloud SQL.

  • Stored Procedure = A function defined in SQL statements, and created in MySQL with CREATE FUNCTION routine_body or CREATE PROCEDURE. This is allowed in Cloud SQL.

I just tested this out by copying and pasting the definition from that SO post into my Cloud SQL instance and it worked perfectly.

like image 187
David Avatar answered Sep 28 '22 03:09

David