Skip to content

Commit 5f74d27

Browse files
committed
first attempt at resolving nil dereference errors
1 parent 7857c95 commit 5f74d27

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

marshal/marshal.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package marshal
22

33
import (
44
"errors"
5-
"reflect"
6-
"strings"
7-
5+
"fmt"
86
"github.com/xitongsys/parquet-go/common"
97
"github.com/xitongsys/parquet-go/layout"
108
"github.com/xitongsys/parquet-go/parquet"
119
"github.com/xitongsys/parquet-go/schema"
1210
"github.com/xitongsys/parquet-go/types"
11+
"reflect"
12+
"runtime/debug"
13+
"strings"
1314
)
1415

1516
type Node struct {
@@ -237,6 +238,7 @@ func Marshal(srcInterface []interface{}, schemaHandler *schema.SchemaHandler) (t
237238
case string:
238239
err = errors.New(x)
239240
case error:
241+
fmt.Printf("RECOVER PANIC FROM PARQUET-GO: %s: %s", x, debug.Stack())
240242
err = x
241243
default:
242244
err = errors.New("unkown error")

schema/schemahandler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"reflect"
7+
"runtime/debug"
78

89
"github.com/xitongsys/parquet-go/common"
910
"github.com/xitongsys/parquet-go/parquet"
@@ -234,6 +235,7 @@ func NewSchemaHandlerFromStruct(obj interface{}) (sh *SchemaHandler, err error)
234235
case string:
235236
err = errors.New(x)
236237
case error:
238+
fmt.Printf("RECOVER PANIC FROM PARQUET-GO: %s: %s", x, debug.Stack())
237239
err = x
238240
default:
239241
err = errors.New("error occurred")

writer/writer.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import (
44
"context"
55
"encoding/binary"
66
"errors"
7+
"fmt"
78
"io"
89
"reflect"
10+
"runtime/debug"
911
"sync"
1012

1113
"github.com/apache/thrift/lib/go/thrift"
@@ -259,7 +261,6 @@ func (pw *ParquetWriter) flushObjs() error {
259261
if bgn >= l {
260262
bgn, end = l, l
261263
}
262-
263264
wg.Add(1)
264265
go func(b, e int, index int64) {
265266
defer func() {
@@ -269,6 +270,7 @@ func (pw *ParquetWriter) flushObjs() error {
269270
case string:
270271
errs[index] = errors.New(x)
271272
case error:
273+
fmt.Printf("RECOVER PANIC FROM PARQUET-GO: %s: %s", x, debug.Stack())
272274
errs[index] = x
273275
default:
274276
errs[index] = errors.New("unknown error")
@@ -300,8 +302,10 @@ func (pw *ParquetWriter) flushObjs() error {
300302
}()
301303

302304
} else {
303-
pagesMapList[index][name], _ = layout.TableToDataPages(table, int32(pw.PageSize),
304-
pw.CompressionType)
305+
if table.Schema.Type != nil {
306+
pagesMapList[index][name], _ = layout.TableToDataPages(table, int32(pw.PageSize),
307+
pw.CompressionType)
308+
}
305309
}
306310
}
307311
} else {

0 commit comments

Comments
 (0)