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.git


The following commit(s) were added to refs/heads/main by this push:
     new f710ac52b0 GH-40719: [Go] Make `arrow.Null` non-null for 
`arrow.TypeEqual` to work properly with `new(arrow.NullType)` (#40802)
f710ac52b0 is described below

commit f710ac52b049806515a14445b242c3ec819fb99d
Author: Alex Shcherbakov <[email protected]>
AuthorDate: Tue Mar 26 21:17:04 2024 +0200

    GH-40719: [Go] Make `arrow.Null` non-null for `arrow.TypeEqual` to work 
properly with `new(arrow.NullType)` (#40802)
    
    ### Rationale for this change
    
    Currently creating a record with a `null` type via `new(arrow.NullType)` in 
the schema will fail the schema validation.
    
    ### What changes are included in this PR?
    
    Made `arrow.Null` a non-null value instead of just a declaration.
    
    ### Are these changes tested?
    
    Yes, see cd4253a24e6d828128fbb7854da3c37951d74885
    
    ### Are there any user-facing changes?
    
    `arrow.Null` became non-null, but the type is the same.
    * GitHub Issue: #40719
    
    Authored-by: Alex Shcherbakov <[email protected]>
    Signed-off-by: Matt Topol <[email protected]>
---
 go/arrow/compare_test.go  | 3 +++
 go/arrow/datatype_null.go | 6 ++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/go/arrow/compare_test.go b/go/arrow/compare_test.go
index 62e30e634e..ca87621ead 100644
--- a/go/arrow/compare_test.go
+++ b/go/arrow/compare_test.go
@@ -42,6 +42,9 @@ func TestTypeEqual(t *testing.T) {
                {
                        Null, Null, true, false,
                },
+               {
+                       Null, new(NullType), true, false,
+               },
                {
                        &BinaryType{}, &StringType{}, false, false,
                },
diff --git a/go/arrow/datatype_null.go b/go/arrow/datatype_null.go
index 2d2454c652..c852b854a7 100644
--- a/go/arrow/datatype_null.go
+++ b/go/arrow/datatype_null.go
@@ -27,7 +27,5 @@ func (*NullType) Layout() DataTypeLayout {
        return DataTypeLayout{Buffers: []BufferSpec{SpecAlwaysNull()}}
 }
 
-var (
-       Null *NullType
-       _    DataType = Null
-)
+// Null gives us both the compile-time assertion of DataType interface as well 
as serving a good element for use in schemas.
+var Null DataType = new(NullType)

Reply via email to