-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tinygo example & turn on wasi support
- Loading branch information
Showing
13 changed files
with
688 additions
and
51 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.sql | ||
*.wasm | ||
Cargo.lock | ||
Cargo.lock | ||
tinygo/gen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# WASM UDF examples | ||
|
||
TODO: | ||
- [ ] error handing | ||
- [ ] schema validation | ||
|
||
## Required tools | ||
|
||
- [wasm-tools](https://github.com/bytecodealliance/wasm-tools): to create WASM component from WASM module. | ||
- [wit-bindgen](https://github.com/bytecodealliance/wit-bindgen) CLI: to generate guest code from WIT file. (Not required for Rust guest) | ||
|
||
``` | ||
cargo install [email protected] | ||
cargo install [email protected] | ||
``` | ||
|
||
> **Note** | ||
> | ||
> WASM component model IS NOT stable and may change. Please use the version specified above. | ||
## Examples for different guest languages | ||
|
||
Refer to each language's directory for an example. Some additional notes are listed below. | ||
Generally you will just need to copy the `wit` directory and follow the examples. | ||
|
||
It's not guaranteed to work if you used different versions of toolchains and project dependencies. | ||
|
||
### Rust | ||
|
||
nothing special | ||
|
||
### Golang | ||
|
||
#### TinyGo | ||
|
||
[TinyGo](https://tinygo.org/getting-started/install/) is an alternative Go compiler for small devices. It also supports WASM. | ||
|
||
tested under | ||
``` | ||
> tinygo version | ||
tinygo version 0.28.1 darwin/amd64 (using go version go1.20.2 and LLVM version 15.0.0) | ||
``` | ||
|
||
- TinyGo cannot compile the lz4 package ([Add support for reading Go assembly files by aykevl · Pull Request #3103 · tinygo-org/tinygo](https://github.com/tinygo-org/tinygo/pull/3103)), which is used by Arrow. Can workaround by using the forked version of arrow, which removed lz4. | ||
|
||
``` | ||
replace github.com/apache/arrow/go/v13 => github.com/xxchan/arrow/go/v13 v13.0.0-20230713134335-45002b4934f9 | ||
``` | ||
|
||
#### TODO: Go 1.21 | ||
|
||
(requires full wasi_snapshot_preview1) | ||
- [Go 1.21 Release Notes - The Go Programming Language](https://tip.golang.org/doc/go1.21) | ||
- [all: add GOOS=wasip1 GOARCH=wasm port · Issue #58141 · golang/go](https://github.com/golang/go/issues/58141) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/udf/wit_example/Cargo.toml → src/udf/wit_example/rust/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module github.com/my_account/my_udf | ||
|
||
go 1.20 | ||
|
||
require github.com/apache/arrow/go/v13 v13.0.0-20230712165359-085a0baf7868 | ||
|
||
require ( | ||
github.com/goccy/go-json v0.10.0 // indirect | ||
github.com/google/flatbuffers v23.5.26+incompatible // indirect | ||
github.com/klauspost/compress v1.16.7 // indirect | ||
github.com/klauspost/cpuid/v2 v2.2.3 // indirect | ||
github.com/zeebo/xxh3 v1.0.2 // indirect | ||
golang.org/x/mod v0.8.0 // indirect | ||
golang.org/x/sys v0.5.0 // indirect | ||
golang.org/x/tools v0.6.0 // indirect | ||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect | ||
) | ||
|
||
replace github.com/apache/arrow/go/v13 => github.com/xxchan/arrow/go/v13 v13.0.0-20230713134335-45002b4934f9 |
Oops, something went wrong.