Problem
When you try to use the ai_similarity
function to calculate the similarity score between two strings, you receive an Unexpected server response error.
Example code
SELECT ai_similarity('Apache Spark', NULL);
Example error message
[AI_FUNCTION_INVALID_HTTP_RESPONSE] Invalid HTTP response for function `ai_similarity`: Unexpected server response: Length of the left (1) is different from the right (0) SQLSTATE: 08000
Cause
You’re passing NULL as an argument, which means you’re providing input data with NULL values to the ai_similarity
function. The function only takes STRING expressions as arguments.
Solution
Filter out all NULL values from the input data. For details, refer to the ai_similarity
function (AWS | Azure | GCP) documentation.