[Python] Creating Python UDF function in BigQuery results into the following error: The...

Discussão em 'Python' iniciado por Stack, Maio 13, 2025.

  1. Stack

    Stack Membro Participativo

    I was trying to exactly recreate and use the Python UDF function with external python packages example in BigQuery's official documentation : https://cloud.google.com/bigquery/docs/user-defined-functions-python#console

    I was able to successfully create the BigQuery python UDF function with this code

    CREATE FUNCTION `<Project ID>.<Dataset ID>`.area(radius FLOAT64)
    RETURNS FLOAT64 LANGUAGE python
    OPTIONS (entry_point='area_handler', runtime_version='python-3.11', packages=['scipy==1.15.3'])
    AS r"""
    import scipy

    def area_handler(radius):
    return scipy.constants.pi*radius*radius
    """;



    However, when I was trying to use this function with this command with my project and dataset ids:

    SELECT `<Project ID>.<Dataset ID>`.area(4.5);


    I get a very ambiguous error: The function Project_ID.Dataset_ID.area failed to build.

    Why do I see this error? How do I resolve this?

    Continue reading...

Compartilhe esta Página