feat(go): add Go packaging for protobuf, ANTLR and extensions - #32
feat(go): add Go packaging for protobuf, ANTLR and extensions#32nielspardon wants to merge 3 commits into
Conversation
|
you might consider two protobuf modules: the old pattern (structs) and the new one (builders). |
Good call — added a second module, |
Add Go packaging for three modules under
github.com/substrait-io/substrait-packaging/go/, mirroring the existing
Python/Rust/Java structure:
- substrait-protobuf: generated protobuf bindings (buf remote protocolbuffers/go)
- substrait-antlr: generated parsers via the stock ANTLR Go target
(substraittype + functestcase packages)
- substrait-extensions: spec extension/text/test-case data via //go:embed
(data only, mirroring the Java artifact; no schema codegen)
Unlike PyPI/crates.io/Maven Central, Go modules are published by pushing a
version-control tag — the proxy serves source from the tag. So there is no
registry upload step: each per-package workflow generates the code, commits it,
pushes a `go/<pkg>/vX.Y.Z` tag, and warms proxy.golang.org. Generated code and
vendored data therefore live only on release tags; the branch keeps only
scaffolding (extensions uses .gitkeep placeholders).
Alpha pre-release publishing is enabled by default (like Rust) for substrait-go
integration testing; scripts/go/next_alpha_version.sh auto-increments from the
repository's own tags, and pre-releases are excluded from `@latest`.
Adds: per-package generate scripts + pixi tasks, scripts/go/{module_exists,
next_alpha_version}.sh, ci_go.yml and go_{protobuf,antlr,extensions,publish}.yml
workflows, wired into publish_artifacts.yml.
🤖 Generated with AI
Ships a second Go protobuf module generated from the same protos and runtime as substrait-protobuf, differing only in the codegen surface: default_api_level=API_OPAQUE, giving opaque message state, Get/Set accessors and Builder types. Consumers pick the Open (struct) or Opaque (builder) API; the two are wire-compatible but expose distinct Go types. Mirrors the existing dir=module=tag=workflow convention: per-package generate script + pixi task, go_protobuf_opaque.yml publish workflow (tag namespace go/substrait-protobuf-opaque/vX.Y.Z), wired into go_publish.yml and ci_go.yml. The shared version/proxy scripts take the package as an arg and needed no changes. Addresses Jacques's PR review suggestion to ship both API patterns.
9315694 to
4141326
Compare
|
@nielspardon Is this high priority for you to get in? I ask because at DD we are trying to solve the diamond dependency problem for Go so we can do more graceful If not urgent, would you mind waiting a bit? I am writing up a proposal and will share it in an issue once it is ready. If this is high priority for you to get in, no worries. We may just need to change the Go versioning scheme later, which could mean using a different namespace/module path. Thanks! |
Not critical for me. I was just trying to help get this work completed since it was sitting dormant for quite some time since @vbarua started it. This is more about ensuring we are leaving a good impression on people evaluating Substrait. Currently, we have SDKs at different spec levels, with breaking builds, different feature levels. I want to make sure we are looking like and becoming a healthy community. That was my main motivation while starting to work on Go. |
Summary
Adds Go packaging for three modules under
github.com/substrait-io/substrait-packaging/go/, mirroring the existing Python/Rust/Java structure:substrait-protobufsubstraitpb+substraitpb/extensions), Open (struct) APIprotocolbuffers/gosubstrait-protobuf-opaqueprotocolbuffers/go(API_OPAQUE)substrait-antlrsubstraittype(listener) +functestcase(visitor)substrait-extensions//go:embedHow Go publishing differs
Unlike PyPI / crates.io / Maven Central, a Go module is published by pushing a version-control tag — the proxy serves source straight from the tag. So there's no registry upload step and no registry credentials:
go/<pkg>/vX.Y.Ztag (that is the publish), and warmsproxy.golang.orgsopkg.go.devindexes it.substrait-extensionsuses.gitkeepplaceholders, so it compiles only after data is vendored).Alpha publishing (enabled by default, like Rust)
alpha: trueis the default so we can publish alpha pre-releases for substrait-go integration testing.scripts/go/next_alpha_version.shauto-increments-alpha→-alpha.1→ … from the repository's own tags. Semver pre-releases are excluded from@latest, so they don't become the default for consumers. Flip toalpha: falsefor a stable release once integration is proven.Design notes
substrait-extensionsships data only. Go has no canonical JSON-schema code generator, and the extension schema's polymorphic function definitions don't map cleanly onto Go's type system — so typed parsing stays downstream (substrait-go), matching the Java extensions artifact. The package is namedsubstraitand exposesGetSubstraitExtensionsFS()/GetSubstraitTestsFS()(plus a newGetSubstraitTextFS()), making it a drop-in for the legacy spec-repo embed module.antlr4-go/antlr/v4runtime) — no fork required, unlike the Rust crate.protoc/protoc-gen-goneeded; onlybuf(already a pixi dependency).substrait-protobufships the Open (struct) API andsubstrait-protobuf-opaqueships the Opaque (builder) API — same protos, same runtime/version, differing only bydefault_api_level=API_OPAQUE. They're wire-compatible but expose distinct Go types, so consumers pick whichever fits. Each is its own module with its own tag namespace, so they version and deprecate independently.Contents
go/with per-package generate scripts +go-generate-*pixi tasksscripts/go/module_exists.sh(proxy idempotency check) andscripts/go/next_alpha_version.shci_go.yml(PR validation) andgo_{protobuf,protobuf_opaque,antlr,extensions}.yml+go_publish.yml, wired intopublish_artifacts.ymlValidation
baseparserimport needs an explicit alias since the module package isfunctestcase)🤖 Generated with AI