问题
I am trying to use some Rust wasm code in Bigquery as UDF, and in order to pass on Java String to Rust code the TextEncoder
and TextDecoder
would be needed to conveniently doing that. As it mentioned here Passing a JavaScript string to a Rust function compiled to WebAssembly
But when I try out some of my code on BigQuery, I encountered an error saying TextEncoder
is not defined.
You can try it out as well with a query like this: https://github.com/liufuyang/rb62-wasm/blob/master/try-3-old.sql
While a working version without using TextEncoder
is at https://github.com/liufuyang/rb62-wasm/blob/master/try-3.sql
回答1:
That means the object is not defined.
As an option, bring your own TextEncoder.
For example, take your try-3-old.sql
, and then add this line at the end of the JS UDF definition:
return main();
'''
OPTIONS (library="gs://fh-bigquery/js/inexorabletash.encoding.js");
And now it works:
(wondering, what's the goal with rb62?)
来源:https://stackoverflow.com/questions/60094731/can-i-use-textencoder-in-bigquery-js-udf