Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to use JS UDF #337

Open
Domlenart opened this issue Jul 15, 2024 · 2 comments
Open

Error when trying to use JS UDF #337

Domlenart opened this issue Jul 15, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Domlenart
Copy link

Domlenart commented Jul 15, 2024

What happened?

I'm trying to create a JS UDF from Python like so:

def create_js_udf(client, dataset):
    client.create_routine(
        bigquery.Routine(
            f"{client.project}.{dataset}.{name}",
            language="JavaScript",
            type_="SCALAR_FUNCTION",
            imported_libraries=["gs://some_bucket/turf.js"],
            body="return true",  # This is not the real body, as seen by error below this is not relevant
            return_type=bigquery.StandardSqlDataType(type_kind=bigquery.StandardSqlTypeNames.BOOL),
        ),
        exists_ok=True,
    )
   

with bigquery.Client(
        project=bigquery_project_id, client_options=client_options, credentials=AnonymousCredentials()
) as client:
    client.create_dataset(f"test.test", exists_ok=True)
    create_js_udf(client, "test")
    yield client

The emulator is configured like this in compose.yaml:

  bigquery-emulator:
    command: [ "--project", "test-project" ]
    image: ghcr.io/goccy/bigquery-emulator:latest
    platform: linux/x86_64
    ports:
      - 9050:9050

When running python code, I see the following log from the emulator:

bigquery-emulator-1  | 2024-07-15T09:52:22.835Z ERROR   server/handler.go:2037  internalError   {"error": "internalError: unsupported language: JavaScript"}

I have inspected the code in the error and looks like JS UDFs are not supported:

return fmt.Errorf("unsupported language: JavaScript")

What did you expect to happen?

I expected that JS UDFs would work as it's stated they work in the README.
image

How can we reproduce it (as minimally and precisely as possible)?

Use the snippets I provided above, or contact me for a full repro; I would gladly jump on a call.

Anything else we need to know?

No response

@Domlenart Domlenart added the bug Something isn't working label Jul 15, 2024
@anonimitoraf
Copy link

Did you try using Javascript instead of JavaScript?

@Domlenart
Copy link
Author

Yes, the enum with valid languages is here:

Nb, this is also a small bug since, per BQ/ZSQ docs, the valid parameter for JS lang is "JAVASCRIPT".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants