Reputation: 643
I want to create View in BigQuery using UDF and BQ command line. BQ command :
bq query --use_legacy_sql=false --project_id="myProject" \
'CREATE OR REPLACE FUNCTION udfFunc(str STRING) RETURNS STRING LANGUAGE js AS
"""
data = fromLib(str);
return JSON.stringify(data);
""" OPTIONS(library = "gs://<bucket>/lib_file.js");
SELECT'
col1,
col2,
udfFunc(col2) as new_col
FROM
`myProject:mySataset.table`'
I am getting an error Invalid value: Routine name "udfFunc" missing dataset while no default dataset is set in the request.
Upvotes: 0
Views: 465
Reputation: 5518
From your query (and the comment on the question), it seems that you only need a temp function during the query time, this is the query that you:
CREATE TEMP FUNCTION udfFunc(str STRING) RETURNS STRING LANGUAGE js AS
"""
data = fromLib(str);
return JSON.stringify(data);
""" OPTIONS(library = "gs://<bucket>/lib_file.js");
SELECT
col1,
col2,
udfFunc(col2) as new_col
FROM
`myProject:mySataset.table`
Upvotes: 2