1

As illustrated here, dumping the wasm byte code and copy past into the javascript seems difficult.

4

I guess you mean a better way than copying into JS - I haven't investigated that (yet), but this will make UDFs easier for others to use:

  • Move the .js out of the query into a file.
  • Create a persistent function.

Then people will be able to call it like this:

SELECT fhoffa.x.sample_wasm_udf([2,3,4])

To create this function I did:

CREATE OR REPLACE FUNCTION fhoffa.x.sample_wasm_udf(x ARRAY<INT64>) 
RETURNS ARRAY<INT64>
LANGUAGE js AS '''
   return main(x)
'''
OPTIONS (library="gs://fh-bigquery/js/wasm.udf.js");

For more on persistent functions, see:

1
  • Aha, I see, thanks, this could help I think. Just a follow up question, only gs:// is supported? If the js file is on some github page or on some web server, would it be also supported? – Fuyang Liu Feb 6 '20 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.