candiduslynx commented on code in PR #35457:
URL: https://github.com/apache/arrow/pull/35457#discussion_r1187641029
##########
go/arrow/array/numericbuilder.gen.go:
##########
@@ -3534,7 +3534,29 @@ func (b *DurationBuilder) AppendValueFromString(s
string) error {
b.AppendNull()
return nil
}
- return fmt.Errorf("%w: AppendValueFromString not implemented for
Duration", arrow.ErrNotImplemented)
+ var value arrow.Duration
+ var unitStr string
+ n, err := fmt.Sscanf(s, "%d%s", &value, &unitStr)
+ if err != nil {
+ b.AppendNull()
+ return err
+ }
+ if n != 2 {
+ b.AppendNull()
+ return fmt.Errorf("failed to parse Duration from %q", s)
+ }
+
+ // to ns & back
+ unit, err := arrow.TimeUnitFromString(unitStr)
+ if err != nil {
+ b.AppendNull()
+ return err
+ }
+
+ value *= arrow.Duration(unit.Multiplier())
+ value /= arrow.Duration(b.dtype.Unit.Multiplier())
+
+ b.Append(value)
Review Comment:
Done in d16fc4cdd02fcfed26de2b76dfcd3fb14635b260
--
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]