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 32323185 test(arrow/util): cover zero-field protobuf records (#1085)
32323185 is described below

commit 32323185d3759350f932180e1d9840f011836f42
Author: Minh Vu <[email protected]>
AuthorDate: Fri Aug 7 17:58:26 2026 +0200

    test(arrow/util): cover zero-field protobuf records (#1085)
    
    ### Rationale for this change
    
    The zero-field record behavior is already present on main. When protobuf
    reflection produces a schema with no fields, one protobuf message still
    becomes one record with zero columns.
    
    ### What changes are included in this PR?
    
    Add regression coverage for empty protobuf messages and exclusion
    policies that remove every field. This PR is test-only.
    
    ### Are these changes tested?
    
    - `go test ./arrow/util`
    
    ### Are there any user-facing changes?
    
    No. This PR only adds regression coverage. The zero-field record
    behavior is already present on main.
---
 arrow/util/protobuf_reflect_test.go | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arrow/util/protobuf_reflect_test.go 
b/arrow/util/protobuf_reflect_test.go
index 723916e1..1f414405 100644
--- a/arrow/util/protobuf_reflect_test.go
+++ b/arrow/util/protobuf_reflect_test.go
@@ -31,6 +31,7 @@ import (
        "github.com/stretchr/testify/require"
        "google.golang.org/protobuf/proto"
        "google.golang.org/protobuf/types/known/anypb"
+       "google.golang.org/protobuf/types/known/emptypb"
 )
 
 type Fixture struct {
@@ -373,6 +374,25 @@ func TestRecordReleasesConstructionBuffers(t *testing.T) {
        mem.AssertSize(t, 0)
 }
 
+func TestRecordWithAllFieldsExcluded(t *testing.T) {
+       pmr := NewProtobufMessageReflection(AllTheTypesNoAnyFixture().msg,
+               WithExclusionPolicy(func(*ProtobufFieldReflection) bool { 
return true }))
+       rec := pmr.Record(nil)
+       defer rec.Release()
+
+       assert.EqualValues(t, 1, rec.NumRows())
+       assert.Zero(t, rec.NumCols())
+}
+
+func TestRecordFromEmptyMessage(t *testing.T) {
+       pmr := NewProtobufMessageReflection(&emptypb.Empty{})
+       rec := pmr.Record(nil)
+       defer rec.Release()
+
+       assert.EqualValues(t, 1, rec.NumRows())
+       assert.Zero(t, rec.NumCols())
+}
+
 func TestNullRecordFromProtobuf(t *testing.T) {
        pmr := NewProtobufMessageReflection(&util_message.AllTheTypes{})
        CheckRecord(t, pmr, `[{

Reply via email to