Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add go-duckdb@v1.7.0 #2523

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions modules/go-duckdb/1.7.0/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module(
name = "go-duckdb",
version = "1.7.0",
)

bazel_dep(name = "gazelle", version = "0.36.0")
bazel_dep(name = "rules_go", version = "0.48.0")

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note that this use_repo clause is redundant as it's not importing any repos. no need to fix it in this PR but could fix upstream.

go_deps,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean to include this file? there's no arrow/cdata/BUILD.bazel file in https://github.com/marcboeker/go-duckdb

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a transitive dependency of go-duckdb. This is what it looks like in our deps.bzl file.

    go_repository(
        name = "com_github_apache_arrow_go_v14",
        build_file_proto_mode = "disable_global",
        importpath = "github.com/apache/arrow/go/v14",
        patch_args = ["-p1"],
        patches = ["@//bazel:patches/com_github_apache_arrow_go_v14_arrow_cdata.patch"],
        sum = "h1:N8OkaJEOfI3mEZt07BIkvo4sC6XDbL+48MBPWO5IONw=",
        version = "v14.0.2",
    )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. You need to translate this go_repository call to an appropriate tag on the go_deps module extension (probably see its docs for pointers). The patch file shouldn't be included in source.json as it doesn't apply to this repo itself.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm out of my depth here. I didn't write the patch, we engaged @pcj to get the fix running internally, and I opened this to try and make it publicly available. I can follow some explicit instructions, but that's about it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derekperkins You would have to turn github.com/apache/arrow/go/v14 into a Bazel module in the same way as go-duckdb first and then add it to go-duckdb as a bazel_dep. Alternatively, we could try to make Gazelle smarter so that the patch on arrow isn't needed anymore.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll probably just wait for that gazelle support to land. Not sure if you'd prefer that this PR is closed in the meantime, but I'm open to whatever

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--- a/arrow/cdata/BUILD.bazel
+++ b/arrow/cdata/BUILD.bazel
@@ -1,4 +1,4 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_source")

go_library(
name = "cdata",
@@ -8,6 +8,7 @@ go_library(
"exports.go",
"interface.go",
"trampoline.c",
+ ":headers",
],
cgo = True,
importpath = "github.com/apache/arrow/go/v14/arrow/cdata",
@@ -31,3 +32,11 @@ alias(
actual = ":cdata",
visibility = ["//visibility:public"],
)
+
+go_source(
+ name = "headers",
+ srcs = [
+ "arrow/c/abi.h",
+ "arrow/c/helpers.h",
+ ],
+)
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
diff --git a/BUILD.bazel b/BUILD.bazel
index 8285865..37e192e 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -18,49 +18,83 @@ go_library(
"transaction.go",
"types.go",
],
+ cdeps = select({
+ "@io_bazel_rules_go//go/platform:android_amd64": [
+ "//deps/linux_amd64:libduckdb",
+ ],
+ "@io_bazel_rules_go//go/platform:android_arm64": [
+ "//deps/linux_arm64:libduckdb",
+ ],
+ "@io_bazel_rules_go//go/platform:darwin_386": [
+ ],
+ "@io_bazel_rules_go//go/platform:darwin_amd64": [
+ "//deps/darwin_amd64:libduckdb",
+ ],
+ "@io_bazel_rules_go//go/platform:darwin_arm": [
+ ],
+ "@io_bazel_rules_go//go/platform:darwin_arm64": [
+ "//deps/darwin_arm64:libduckdb",
+ ],
+ "@io_bazel_rules_go//go/platform:freebsd_amd64": [
+ "//deps/freebsd_amd64:libduckdb",
+ ],
+ "@io_bazel_rules_go//go/platform:ios_amd64": [
+ "//deps/darwin_amd64:libduckdb",
+ ],
+ "@io_bazel_rules_go//go/platform:ios_arm64": [
+ "//deps/darwin_arm64:libduckdb",
+ ],
+ "@io_bazel_rules_go//go/platform:linux_amd64": [
+ "//deps/linux_amd64:libduckdb",
+ ],
+ "@io_bazel_rules_go//go/platform:linux_arm64": [
+ "//deps/linux_arm64:libduckdb",
+ ],
+ "//conditions:default": [],
+ }),
cgo = True,
clinkopts = select({
"@io_bazel_rules_go//go/platform:android_amd64": [
"-lduckdb",
- "-lstdc++ -lm -ldl -Ldeps/linux_amd64",
+ "-lstdc++ -lm -ldl -Lexternal/com_github_marcboeker_go_duckdb/deps/linux_amd64",
],
"@io_bazel_rules_go//go/platform:android_arm64": [
"-lduckdb",
- "-lstdc++ -lm -ldl -Ldeps/linux_arm64",
+ "-lstdc++ -lm -ldl -Lexternal/com_github_marcboeker_go_duckdb/deps/linux_arm64",
],
"@io_bazel_rules_go//go/platform:darwin_386": [
"-lduckdb",
],
"@io_bazel_rules_go//go/platform:darwin_amd64": [
- "-lc++ -Ldeps/darwin_amd64",
+ "-lc++ -Lexternal/com_github_marcboeker_go_duckdb/deps/darwin_amd64",
"-lduckdb",
],
"@io_bazel_rules_go//go/platform:darwin_arm": [
"-lduckdb",
],
"@io_bazel_rules_go//go/platform:darwin_arm64": [
- "-lc++ -Ldeps/darwin_arm64",
+ "-lc++ -Lexternal/com_github_marcboeker_go_duckdb/deps/darwin_arm64",
"-lduckdb",
],
"@io_bazel_rules_go//go/platform:freebsd_amd64": [
"-lduckdb",
- "-lstdc++ -lm -ldl -Ldeps/freebsd_amd64",
+ "-lstdc++ -lm -ldl -Lexternal/com_github_marcboeker_go_duckdb/deps/freebsd_amd64",
],
"@io_bazel_rules_go//go/platform:ios_amd64": [
"-lc++ -Ldeps/darwin_amd64",
"-lduckdb",
],
"@io_bazel_rules_go//go/platform:ios_arm64": [
- "-lc++ -Ldeps/darwin_arm64",
+ "-lc++ -Lexternal/com_github_marcboeker_go_duckdb/deps/darwin_arm64",
"-lduckdb",
],
"@io_bazel_rules_go//go/platform:linux_amd64": [
"-lduckdb",
- "-lstdc++ -lm -ldl -Ldeps/linux_amd64",
+ "-lstdc++ -lm -ldl -Lexternal/com_github_marcboeker_go_duckdb/deps/linux_amd64",
],
"@io_bazel_rules_go//go/platform:linux_arm64": [
"-lduckdb",
- "-lstdc++ -lm -ldl -Ldeps/linux_arm64",
+ "-lstdc++ -lm -ldl -Lexternal/com_github_marcboeker_go_duckdb/deps/linux_arm64",
],
"//conditions:default": [],
}),
diff --git a/deps/darwin_amd64/BUILD.bazel b/deps/darwin_amd64/BUILD.bazel
index 471671e..4f508b6 100644
--- a/deps/darwin_amd64/BUILD.bazel
+++ b/deps/darwin_amd64/BUILD.bazel
@@ -12,3 +12,9 @@ alias(
actual = ":darwin_amd64",
visibility = ["//visibility:public"],
)
+
+cc_library(
+ name = "libduckdb",
+ srcs = ["libduckdb.a"],
+ visibility = ["//visibility:public"],
+)
diff --git a/deps/darwin_arm64/BUILD.bazel b/deps/darwin_arm64/BUILD.bazel
index edc81b3..848fe8b 100644
--- a/deps/darwin_arm64/BUILD.bazel
+++ b/deps/darwin_arm64/BUILD.bazel
@@ -12,3 +12,9 @@ alias(
actual = ":darwin_arm64",
visibility = ["//visibility:public"],
)
+
+cc_library(
+ name = "libduckdb",
+ srcs = ["libduckdb.a"],
+ visibility = ["//visibility:public"],
+)
diff --git a/deps/freebsd_amd64/BUILD.bazel b/deps/freebsd_amd64/BUILD.bazel
index 849a7e3..f347669 100644
--- a/deps/freebsd_amd64/BUILD.bazel
+++ b/deps/freebsd_amd64/BUILD.bazel
@@ -12,3 +12,9 @@ alias(
actual = ":freebsd_amd64",
visibility = ["//visibility:public"],
)
+
+cc_library(
+ name = "libduckdb",
+ srcs = ["libduckdb.a"],
+ visibility = ["//visibility:public"],
+)
diff --git a/deps/linux_amd64/BUILD.bazel b/deps/linux_amd64/BUILD.bazel
index 0acbb38..23be608 100644
--- a/deps/linux_amd64/BUILD.bazel
+++ b/deps/linux_amd64/BUILD.bazel
@@ -12,3 +12,9 @@ alias(
actual = ":linux_amd64",
visibility = ["//visibility:public"],
)
+
+cc_library(
+ name = "libduckdb",
+ srcs = ["libduckdb.a"],
+ visibility = ["//visibility:public"],
+)
diff --git a/deps/linux_arm64/BUILD.bazel b/deps/linux_arm64/BUILD.bazel
index 64200d5..5c7fba0 100644
--- a/deps/linux_arm64/BUILD.bazel
+++ b/deps/linux_arm64/BUILD.bazel
@@ -12,3 +12,9 @@ alias(
actual = ":linux_arm64",
visibility = ["//visibility:public"],
)
+
+cc_library(
+ name = "libduckdb",
+ srcs = ["libduckdb.a"],
+ visibility = ["//visibility:public"],
+)
16 changes: 16 additions & 0 deletions modules/go-duckdb/1.7.0/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
matrix:
bazel:
- 7.x
platform:
- centos7
- debian10
- ubuntu2004
- macos
- windows
tasks:
verify_targets:
name: Verify build targets
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- '@go-duckdb//...'
10 changes: 10 additions & 0 deletions modules/go-duckdb/1.7.0/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"url": "https://proxy.golang.org/github.com/marcboeker/go-duckdb/@v/v1.7.0.zip",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Go proxy doesn't promise a stable hash, but neither does GitHub for its /archive endpoint, so we might as well go with this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied what was in the circl module. TBH, I didn't even realize the go proxy provided a download option like this

"integrity": "sha256-fo6vo0KV06lzFxoEGR1fN5RBdot9DjiZBuVwrCM4+wI=",
"patches": {
"com_github_apache_arrow_go_v14_arrow_cdata.patch": "sha256-Os1Hr/SizCVduwOmHBjAXh0Zn9ZtmRw1u1fYIE164MY=",
"com_github_marcboeker_go_duckdb.libduckdb.patch": "sha256-0XSMS6xiYibD9lEWui9D5wnYW4G80e0fWfVF5NDNRNk="
},
"patch_strip": 1,
"strip_prefix": "github.com/marcboeker/go-duckdb@v1.7.0"
}
14 changes: 14 additions & 0 deletions modules/go-duckdb/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"homepage": "https://github.com/marcboeker/go-duckdb",
"maintainers": [
{
"email": "bcr-maintainers@bazel.build",
"name": "No Maintainer Specified"
}
],
"repository": [],
"versions": [
"1.7.0"
],
"yanked_versions": {}
}