You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/01 03:18:57 UTC

[GitHub] [arrow] cyb70289 commented on a diff in pull request #14504: ARROW-17899: [Go][CSV] Add Decimal support to CSV reader

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


##########
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:
   Will it be called if `r.err != nil`?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org