zeroshade commented on code in PR #14504:
URL: https://github.com/apache/arrow/pull/14504#discussion_r1010534526


##########
go/arrow/csv/reader.go:
##########
@@ -681,6 +691,36 @@ func (r *Reader) parseTime32(field array.Builder, str 
string, unit arrow.TimeUni
        field.(*array.Time32Builder).Append(val)
 }
 
+func (r *Reader) parseDecimal128(field array.Builder, str string, prec, scale 
int32) {
+       if r.isNull(str) {
+               field.AppendNull()
+               return
+       }
+
+       val, err := decimal128.FromString(str, prec, scale)
+       if err != nil && r.err == nil {
+               r.err = err
+               field.AppendNull()
+               return
+       }
+       field.(*array.Decimal128Builder).Append(val)
+}
+
+func (r *Reader) parseDecimal256(field array.Builder, str string, prec, scale 
int32) {
+       if r.isNull(str) {
+               field.AppendNull()
+               return
+       }
+
+       val, err := decimal256.FromString(str, prec, scale)
+       if err != nil && r.err == nil {
+               r.err = err
+               field.AppendNull()
+               return
+       }
+       field.(*array.Decimal256Builder).Append(val)

Review Comment:
   the reason for the `r.err == nil` check is so that we don't lose the first 
error we find. The assumption being that if we get an error we're going to stop 
reading after this record and the data is bad anyways.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to