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 15a989e2 fix(arrow/extensions): compare JSON storage types
semantically (#1150)
15a989e2 is described below
commit 15a989e2650beeb09908c485ab8b46f8c7436d9c
Author: Minh Vu <[email protected]>
AuthorDate: Tue Aug 11 23:17:21 2026 +0200
fix(arrow/extensions): compare JSON storage types semantically (#1150)
## What
NewJSONType used interface equality when checking supported storage
types. A distinct StringType value is semantically the same Arrow type
but could be rejected. This uses arrow.TypeEqual for the supported
storage type check.
## Test
- go test ./arrow/extensions -count=1
---
arrow/extensions/json.go | 10 ++++++++--
arrow/extensions/json_test.go | 11 +++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/arrow/extensions/json.go b/arrow/extensions/json.go
index 3f46b50e..e74ba7f6 100644
--- a/arrow/extensions/json.go
+++ b/arrow/extensions/json.go
@@ -19,7 +19,6 @@ package extensions
import (
"fmt"
"reflect"
- "slices"
"github.com/apache/arrow-go/v18/arrow"
"github.com/apache/arrow-go/v18/arrow/array"
@@ -46,7 +45,14 @@ func (b *JSONType) ParquetLogicalType() schema.LogicalType {
// NewJSONType creates a new JSONType with the specified storage type.
// storageType must be one of String, LargeString, StringView.
func NewJSONType(storageType arrow.DataType) (*JSONType, error) {
- if !slices.Contains(jsonSupportedStorageTypes, storageType) {
+ supported := false
+ for _, typ := range jsonSupportedStorageTypes {
+ if arrow.TypeEqual(typ, storageType) {
+ supported = true
+ break
+ }
+ }
+ if !supported {
return nil, fmt.Errorf("unsupported storage type for JSON
extension type: %s", storageType)
}
return &JSONType{ExtensionBase: arrow.ExtensionBase{Storage:
storageType}}, nil
diff --git a/arrow/extensions/json_test.go b/arrow/extensions/json_test.go
index 26822cdf..73805bd0 100644
--- a/arrow/extensions/json_test.go
+++ b/arrow/extensions/json_test.go
@@ -62,6 +62,17 @@ func TestJSONTypeBasics(t *testing.T) {
assert.Equal(t, "extension<arrow.json[storage_type=string_view]>",
typView.String())
}
+func TestJSONTypeAcceptsSemanticallyEqualStorageType(t *testing.T) {
+ var holder struct {
+ _ byte
+ storage arrow.StringType
+ }
+
+ typ, err := extensions.NewJSONType(&holder.storage)
+ require.NoError(t, err)
+ require.True(t, arrow.TypeEqual(arrow.BinaryTypes.String,
typ.StorageType()))
+}
+
var jsonTestCases = []struct {
Name string
StorageType arrow.DataType