Udf: example in golang
gedw99 opened this issue · comments
Like the design.
Saw there is a rust wasm example.
if you add a golang example compiled with tinygo that would be create
Thanks for the suggestion! I took a stab at porting the previously made Rust example into Golang/tinygo.
Results
$ ./query_udf.sh
SELECT addi64(1, 2) AS RESULT;
HTTP/1.1 200 OK
content-type: application/json; arrow-schema=%7B%22fields%22%3A%5B%7B%22children%22%3A%5B%5D%2C%22name%22%3A%22result%22%2C%22nullable%22%3Atrue%2C%22type%22%3A%7B%22bitWidth%22%3A64%2C%22isSigned%22%3Atrue%2C%22name%22%3A%22int%22%7D%7D%5D%2C%22metadata%22%3A%7B%7D%7D
x-seafowl-query-time: 426
vary: Authorization, Content-Type, Origin, X-Seafowl-Query
transfer-encoding: chunked
date: Tue, 18 Jul 2023 06:34:14 GMT
{"result":3}
1 + 2 = 3 🎉
NB This was my first time writing Golang and also my first WASM module, sorry for any bugs, which there likely are.
Practical note
Please be aware Seafowl supports registering and invoking UDFs, but doesn't yet support UDF deletion1, so if you end up iterating on your own WASM module and want to register it in Seafowl >1x, you will probably want to clear the Seafowl database (e.g. rm the seafowl.sqlite
file).
In case you're able to share what you build would be curious to check it out :)
Hope this is helpful, and good luck!
Deps
go version go1.20.6 darwin/amd64
tinygo version 0.28.1 darwin/amd64 (using go version go1.20.6 and LLVM version 15.0.0)
Footnotes
I believe the request has been fulfilled at this point so I'm going to close.
If any further assistance is needed, please just ask.
Closing