Dear all,
I have the following issue : I have created a UDF, added it in a list of UDF resources and declared a custom job config including this new udf resources.
from google.cloud.bigquery.query import UDFResource
from google.cloud.bigquery.job import QueryJobConfig
edit_distance = """
CREATE TEMP FUNCTION HammingDistance(a STRING, b STRING) AS (
...
);
"""
# add the user defined function as resources and create a query job config
udf_function_resources = UDFResource('inlineCode', edit_distance)
custom_job_config = QueryJobConfig()
custom_job_config.udf_resources = [udf_function_resources]
I create the following SQL query string :
unitary_query = "SELECT CHUNK_ID, LABEL, TEXT, START_OFFSET, END_OFFSET from " + entities_table + " WHERE LABEL='" + label + "' AND HammingDistance(LOWER(TEXT), '" + attribute +"') < 2"
And try it in BigQuery client:
unitary_query = bq_client.query(unitary_query, job_config=custom_job_config)
bq_results = unitary_query.result()
But, I have the following error:
BadRequest: 400 Function not found: HammingDistance at [1:143]
Thanks for help
Best regards
Jerome