问题描述
我试图在 Bigquery 中使用一些 Rust wasm 代码作为 UDF,为了将 Java String 传递给 Rust 代码,需要 TextEncoder
和 TextDecoder
方便地这样做.正如这里提到的
您也可以通过这样的查询尝试一下:
(想知道,rb62 的目标是什么?)
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
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?)
这篇关于我可以在 Bigquery JS UDF 中使用 `TextEncoder` 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!