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 4c418e4 refactor(arrow): rename Record to RecordBatch and add
deprecated alias (#466)
4c418e4 is described below
commit 4c418e4d8eed5ce6b8b6d16abee1a3672267df20
Author: Mandukhai Alimaa <[email protected]>
AuthorDate: Thu Aug 14 00:55:19 2025 +0800
refactor(arrow): rename Record to RecordBatch and add deprecated alias
(#466)
### Rationale for this change
Rename the Record interface to RecordBatch for clarity, since Record
commonly means a single row but this type represents a batch of rows.
### What changes are included in this PR?
- Renamed the Record interface to RecordBatch in /arrow/record.go
- Updated interface method signatures to use RecordBatch in return types
(SetColumn and NewSlice)
- Added a deprecated type alias type Record = RecordBatch for backward
compatibility to avoid breaking existing
code and ease migration
- Added proper Go deprecation annotation (// Deprecated:) to ensure
tooling support
### Are these changes tested?
All existing tests in ./arrow and ./arrow/array packages are passing.
### Are there any user-facing changes?
Users can now use the semantically correct RecordBatch type name.
---------
Co-authored-by: MANDY Alimaa <[email protected]>
---
.golangci.yaml | 4 ++++
arrow/example_table_creation_test.go | 2 +-
arrow/example_test.go | 4 ++--
arrow/examples/table_creation/main.go | 2 +-
arrow/record.go | 19 +++++++++++++------
5 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/.golangci.yaml b/.golangci.yaml
index 36ed5f0..36443a0 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -31,6 +31,10 @@ linters:
- third_party$
- builtin$
- examples$
+ rules:
+ - linters:
+ - staticcheck
+ text: "SA1019"
issues:
fix: true
formatters:
diff --git a/arrow/example_table_creation_test.go
b/arrow/example_table_creation_test.go
index 4de47eb..1d823e4 100644
--- a/arrow/example_table_creation_test.go
+++ b/arrow/example_table_creation_test.go
@@ -48,7 +48,7 @@ func Example_tableCreation() {
defer rec.Release()
// Create a table from the record
- tbl := array.NewTableFromRecords(schema, []arrow.Record{rec})
+ tbl := array.NewTableFromRecords(schema, []arrow.RecordBatch{rec})
defer tbl.Release()
// Calculate sum of floatField
diff --git a/arrow/example_test.go b/arrow/example_test.go
index d251f7b..822ea9a 100644
--- a/arrow/example_test.go
+++ b/arrow/example_test.go
@@ -515,7 +515,7 @@ func Example_recordReader() {
rec2 := b.NewRecord()
defer rec2.Release()
- itr, err := array.NewRecordReader(schema, []arrow.Record{rec1, rec2})
+ itr, err := array.NewRecordReader(schema, []arrow.RecordBatch{rec1,
rec2})
if err != nil {
log.Fatal(err)
}
@@ -564,7 +564,7 @@ func Example_table() {
rec2 := b.NewRecord()
defer rec2.Release()
- tbl := array.NewTableFromRecords(schema, []arrow.Record{rec1, rec2})
+ tbl := array.NewTableFromRecords(schema, []arrow.RecordBatch{rec1,
rec2})
defer tbl.Release()
tr := array.NewTableReader(tbl, 5)
diff --git a/arrow/examples/table_creation/main.go
b/arrow/examples/table_creation/main.go
index 52e1782..6f923b6 100644
--- a/arrow/examples/table_creation/main.go
+++ b/arrow/examples/table_creation/main.go
@@ -48,7 +48,7 @@ func main() {
defer rec.Release()
// Create a table from the record
- tbl := array.NewTableFromRecords(schema, []arrow.Record{rec})
+ tbl := array.NewTableFromRecords(schema, []arrow.RecordBatch{rec})
defer tbl.Release()
// Calculate sum of floatField
diff --git a/arrow/record.go b/arrow/record.go
index 4fd6b13..010dbe9 100644
--- a/arrow/record.go
+++ b/arrow/record.go
@@ -18,12 +18,12 @@ package arrow
import "github.com/apache/arrow-go/v18/internal/json"
-// Record is a collection of equal-length arrays matching a particular Schema.
-// Also known as a RecordBatch in the spec and in some implementations.
+// RecordBatch is a collection of equal-length arrays matching a particular
Schema.
+// This corresponds to the RecordBatch concept in the Arrow specification.
//
-// It is also possible to construct a Table from a collection of Records that
+// It is also possible to construct a Table from a collection of RecordBatches
that
// all have the same schema.
-type Record interface {
+type RecordBatch interface {
json.Marshaler
Release()
@@ -37,7 +37,7 @@ type Record interface {
Columns() []Array
Column(i int) Array
ColumnName(i int) string
- SetColumn(i int, col Array) (Record, error)
+ SetColumn(i int, col Array) (RecordBatch, error)
// NewSlice constructs a zero-copy slice of the record with the
indicated
// indices i and j, corresponding to array[i:j].
@@ -45,5 +45,12 @@ type Record interface {
//
// NewSlice panics if the slice is outside the valid range of the
record array.
// NewSlice panics if j < i.
- NewSlice(i, j int64) Record
+ NewSlice(i, j int64) RecordBatch
}
+
+// Record as a term typically refers to a single row, but this type represents
a batch of rows, known in Arrow parlance
+// as a RecordBatch. This alias is provided for backwards compatibility.
+//
+// Deprecated: This is deprecated to avoid the confusion of the terminology
where Record refers to a single row,
+// use [RecordBatch] instead.
+type Record = RecordBatch