xitongsys / parquet-go

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

`StrToParquetType` ignores `Sscanf` error #423

Closed ryota717 closed 2 years ago

ryota717 commented 2 years ago

hi, i'm using parquet-go with JSON input records. eacn JSON columns convert to appropriate parquet type by StrToParquetType with fmt.Sscanf function.

but this conversion ignores fmt.Sscanf errors. for example, when we define an integer column in parquet schema and actual JSON value is a string "abc", we get the record value 0.

func main() {
    var str = "abc"
    var v int32
    n, err := fmt.Sscanf(str, "%d", &v)

    fmt.Println(v)
    fmt.Println(err)
}

gets result below.

0
expected integer

in my opinion, this behavior is weird for developers and wanna catch cases like this.

xitongsys commented 2 years ago

fixed.