You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// MarshalJSON implements the json.Marshaler interface.
// The time is a quoted string in RFC 3339 format, with sub-second precision added if present.
Which means if you're generating an avro file and specify a default of time.Time{} it will marshal that as a string and then you get:
cannot create OCFWriter: cannot create OCF header: Record "analytics.submission" field "ts": default value ought to encode using field schema: cannot transform binary timestamp-micros, expected time.Time, received string
Since NewCodec unmarshalling the schema into an interface{} there's no way for the json package to know that it should be a time.Time to unmarshal into and not a plain string. I think timeStampMillisFromNative (and other timestamp types) should check to see if the value is a string and then unmarshal into a time.Time and that should fix the issue.
Apologies for the oversight! We didn't have a requirement for default values and it slipped my mind.
I certainly have no objections to your suggestion and it sounds like the correct approach to me. I'm afraid I don't to have time to add this functionality at the moment due to impending holiday + deadlines.
Thanks for pointing this out and feel free to ping me if you need anything.
The
MarshalJSON
method for thetime.Time
struct:Which means if you're generating an avro file and specify a default of
time.Time{}
it will marshal that as a string and then you get:Since
NewCodec
unmarshalling the schema into an interface{} there's no way for the json package to know that it should be atime.Time
to unmarshal into and not a plain string. I thinktimeStampMillisFromNative
(and other timestamp types) should check to see if the value is a string and then unmarshal into a time.Time and that should fix the issue.@kdvy, what do you think?
The text was updated successfully, but these errors were encountered: