Skip to content

Commit 6d71d18

Browse files
authored
fix: Don't use ValueStr, get raw bytes instead (#2220)
Follow up to #2217 Apparently `ValueStr` calls the same code that generated the original panic. Hopefully this works ---
1 parent 0453cbe commit 6d71d18

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

plugin/diff.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package plugin
22

33
import (
4+
"encoding/base64"
45
"fmt"
56
"strings"
67

@@ -17,16 +18,20 @@ func getUnifiedDiff(edits array.Edits, wantCol, haveCol arrow.Array) string {
1718
defer func() {
1819
if r := recover(); r != nil {
1920
wantDataType := wantCol.DataType()
20-
wantData := make([]string, wantCol.Len())
21-
for i := 0; i < wantCol.Len(); i++ {
22-
wantData[i] = wantCol.ValueStr(i)
21+
wantData := make([]byte, wantCol.Len())
22+
for _, buffer := range wantCol.Data().Buffers() {
23+
wantData = append(wantData, buffer.Bytes()...)
2324
}
2425
haveDataType := haveCol.DataType()
25-
haveData := make([]string, haveCol.Len())
26-
for i := 0; i < haveCol.Len(); i++ {
27-
haveData[i] = haveCol.ValueStr(i)
26+
haveData := make([]byte, haveCol.Len())
27+
for _, buffer := range haveCol.Data().Buffers() {
28+
haveData = append(haveData, buffer.Bytes()...)
2829
}
29-
panic(fmt.Errorf("panic in getUnifiedDiff: %s, want: [%s], have: [%s], want type: %s, have type: %s", r, strings.Join(wantData, ", "), strings.Join(haveData, ", "), wantDataType, haveDataType))
30+
31+
wantBase64 := base64.StdEncoding.EncodeToString(wantData)
32+
haveBase64 := base64.StdEncoding.EncodeToString(haveData)
33+
34+
panic(fmt.Errorf("panic in getUnifiedDiff: %s, want: (%s), have: (%s), want type: %s, have type: %s", r, wantBase64, haveBase64, wantDataType, haveDataType))
3035
}
3136
}()
3237
return edits.UnifiedDiff(wantCol, haveCol)

0 commit comments

Comments
 (0)