This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git
The following commit(s) were added to refs/heads/main by this push:
new 463f868f build: add pqarrow_read_only build tags to avoid building
write related code (#569)
463f868f is described below
commit 463f868f68933f32cf2e0897d4411501292852ea
Author: Jacob Romero <[email protected]>
AuthorDate: Fri Nov 14 13:53:05 2025 -0800
build: add pqarrow_read_only build tags to avoid building write related
code (#569)
### Rationale for this change
The current binary when built is 20mb. We have a use case in which we
only need to read data from a parquet file and do not need to write any
parquet data out. By Adding build tags to code that is only needed to
write we can save ~12mb off the size of our binary compiled with
arrow-go.
### What changes are included in this PR?
This PR adds the build tag `!pqarrow_read_only` to write related files
in the `pqarrow` package.
### Are these changes tested?
Tested the build locally and against my read only use case.
Added test in `ci/scripts/build.sh`
### Are there any user-facing changes?
No, this change is only for consumers who build `arrow-go` but do not
need write functionality.
---
arrow/avro/avro2parquet/main.go | 2 ++
ci/scripts/build.sh | 6 ++++++
parquet/pqarrow/encode_arrow.go | 2 ++
parquet/pqarrow/encode_dict_compute.go | 2 +-
parquet/pqarrow/encode_dict_nocompute.go | 2 +-
parquet/pqarrow/file_writer.go | 2 ++
6 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/arrow/avro/avro2parquet/main.go b/arrow/avro/avro2parquet/main.go
index 663ae58b..699993e7 100644
--- a/arrow/avro/avro2parquet/main.go
+++ b/arrow/avro/avro2parquet/main.go
@@ -14,6 +14,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build !pqarrow_read_only
+
package main
import (
diff --git a/ci/scripts/build.sh b/ci/scripts/build.sh
index acfca173..404d3e38 100755
--- a/ci/scripts/build.sh
+++ b/ci/scripts/build.sh
@@ -73,3 +73,9 @@ if [[ "${ARROW_INTEGRATION_GO}" = "ON" ]]; then
popd
fi
+
+pushd "${source_dir}/parquet"
+
+go install -tags pqarrow_read_only ./...
+
+popd
diff --git a/parquet/pqarrow/encode_arrow.go b/parquet/pqarrow/encode_arrow.go
index 5724e9f8..2e1434db 100644
--- a/parquet/pqarrow/encode_arrow.go
+++ b/parquet/pqarrow/encode_arrow.go
@@ -14,6 +14,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build !pqarrow_read_only
+
package pqarrow
import (
diff --git a/parquet/pqarrow/encode_dict_compute.go
b/parquet/pqarrow/encode_dict_compute.go
index ab587503..184ec0fa 100644
--- a/parquet/pqarrow/encode_dict_compute.go
+++ b/parquet/pqarrow/encode_dict_compute.go
@@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-//go:build go1.18
+//go:build go1.18 && !pqarrow_read_only
package pqarrow
diff --git a/parquet/pqarrow/encode_dict_nocompute.go
b/parquet/pqarrow/encode_dict_nocompute.go
index 52b6e604..fbe91272 100644
--- a/parquet/pqarrow/encode_dict_nocompute.go
+++ b/parquet/pqarrow/encode_dict_nocompute.go
@@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-//go:build !go1.18
+//go:build !go1.18 && !pqarrow_read_only
package pqarrow
diff --git a/parquet/pqarrow/file_writer.go b/parquet/pqarrow/file_writer.go
index 1560d0c7..84a29b7a 100644
--- a/parquet/pqarrow/file_writer.go
+++ b/parquet/pqarrow/file_writer.go
@@ -14,6 +14,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build !pqarrow_read_only
+
package pqarrow
import (