Skip to content

Commit db52c19

Browse files
committed
fix: update extractScalarValue function to return correct integer types and adjust tests accordingly
1 parent a2271f1 commit db52c19

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

flight/doaction_metadata.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -661,23 +661,23 @@ func extractScalarValue(arr arrow.Array, idx int) any {
661661

662662
switch a := arr.(type) {
663663
case *array.Int8:
664-
return int64(a.Value(idx))
664+
return a.Value(idx)
665665
case *array.Int16:
666-
return int64(a.Value(idx))
666+
return a.Value(idx)
667667
case *array.Int32:
668-
return int64(a.Value(idx))
668+
return a.Value(idx)
669669
case *array.Int64:
670670
return a.Value(idx)
671671
case *array.Uint8:
672-
return int64(a.Value(idx))
672+
return a.Value(idx)
673673
case *array.Uint16:
674-
return int64(a.Value(idx))
674+
return a.Value(idx)
675675
case *array.Uint32:
676-
return int64(a.Value(idx))
676+
return a.Value(idx)
677677
case *array.Uint64:
678-
return int64(a.Value(idx))
678+
return a.Value(idx)
679679
case *array.Float32:
680-
return float64(a.Value(idx))
680+
return a.Value(idx)
681681
case *array.Float64:
682682
return a.Value(idx)
683683
case *array.String:
@@ -736,7 +736,7 @@ func extractScalarValue(arr arrow.Array, idx int) any {
736736
}
737737
return result
738738
default:
739-
// For unsupported types, return nil
739+
// For unsupported types, return the array itself
740740
return nil
741741
}
742742
}

flight/doaction_metadata_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestExtractScalarValue_Integers(t *testing.T) {
2626
b.Append(42)
2727
return b.NewArray()
2828
},
29-
expected: int64(42),
29+
expected: int8(42),
3030
},
3131
{
3232
name: "Int16",
@@ -36,7 +36,7 @@ func TestExtractScalarValue_Integers(t *testing.T) {
3636
b.Append(1000)
3737
return b.NewArray()
3838
},
39-
expected: int64(1000),
39+
expected: int16(1000),
4040
},
4141
{
4242
name: "Int32",
@@ -46,7 +46,7 @@ func TestExtractScalarValue_Integers(t *testing.T) {
4646
b.Append(100000)
4747
return b.NewArray()
4848
},
49-
expected: int64(100000),
49+
expected: int32(100000),
5050
},
5151
{
5252
name: "Int64",
@@ -66,7 +66,7 @@ func TestExtractScalarValue_Integers(t *testing.T) {
6666
b.Append(255)
6767
return b.NewArray()
6868
},
69-
expected: int64(255),
69+
expected: uint8(255),
7070
},
7171
{
7272
name: "Uint16",
@@ -76,7 +76,7 @@ func TestExtractScalarValue_Integers(t *testing.T) {
7676
b.Append(65535)
7777
return b.NewArray()
7878
},
79-
expected: int64(65535),
79+
expected: uint16(65535),
8080
},
8181
{
8282
name: "Uint32",
@@ -86,7 +86,7 @@ func TestExtractScalarValue_Integers(t *testing.T) {
8686
b.Append(4294967295)
8787
return b.NewArray()
8888
},
89-
expected: int64(4294967295),
89+
expected: uint32(4294967295),
9090
},
9191
{
9292
name: "Uint64",
@@ -96,7 +96,7 @@ func TestExtractScalarValue_Integers(t *testing.T) {
9696
b.Append(1844674407370955161)
9797
return b.NewArray()
9898
},
99-
expected: int64(1844674407370955161),
99+
expected: uint64(1844674407370955161),
100100
},
101101
}
102102

@@ -124,8 +124,8 @@ func TestExtractScalarValue_Floats(t *testing.T) {
124124
defer arr.Release()
125125

126126
result := extractScalarValue(arr, 0)
127-
if v, ok := result.(float64); !ok || v < 3.13 || v > 3.15 {
128-
t.Errorf("expected ~3.14, got %v", result)
127+
if v, ok := result.(float32); !ok || v < 3.13 || v > 3.15 {
128+
t.Errorf("expected ~3.14 (float32), got %v (%T)", result, result)
129129
}
130130
})
131131

0 commit comments

Comments
 (0)