xitongsys / parquet-go

pure golang library for reading/writing parquet file
Apache License 2.0
1.27k stars 293 forks source link

first attempt at resolving nil dereference errors #439

Open shlomi-dr opened 2 years ago

shlomi-dr commented 2 years ago

I was battling some nil dereference that was concealed deep in the library. I added a bunch of debug.Stack() calls to retain the original stacktrace, and found that in the following section pT is some times nil:

https://github.com/xitongsys/parquet-go/blob/5f74d27a1b816f8c28105c910526c1a94404a2e3/common/common.go#L667-L671

Not sure why that happens, see below comment for proposed fix

hangxie commented 2 years ago

This PR is related to https://github.com/xitongsys/parquet-go/issues/395 and I'd suggest fix it like https://github.com/xitongsys/parquet-go/pull/407, which changes function signature to return (value, error) instead value only, this is a typical go way to my understanding. Once the function can return error, one can check pT before dereference it, and return error to notify callers.

The preferred way may introduce large scale refactor though.