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
I am trying to use Avro to store data that is used by multiple systems. We are storing analytics data in Big Table as a textual Avro representation. We have defined a schema for how the data is stored. We can parse it using this library, and validate the stored data matches the schema, but when we read the payload in the stored data we cannot find how to parse the data to get a JSON representation of it.
The dimension values are wrapped inside an extra object to keep track of their type. JavaScript doesn't have typed numbers the same way other languages (e.g. Java) do: everything is a double. With the representation you expected, we wouldn't be able to know whether the 1 values are longs or doubles -- at least without additional context-specific information. This section of the API doc has more information in case you are curious.
Note that in your case, it looks like you can use additional information present in your record to infer the type. IIUC, the valueType enum indicates what branch is used in the dimensions of the same metric. You can use this in combination with logical types to achieve your ideal representation. This comment has an example of how to do so as well as a bit more context.
Thank you for the detailed reply. We figured this was the case. I will look into the notes you provided.
I tried getting logical types to work using a resolver, but without luck. I think I was trying to parse the whole value, not just the single doubles. I ended up using a map with the lower case valueType as a selector. I’ll try to get it working the correct way.
Hi there,
I am trying to use Avro to store data that is used by multiple systems. We are storing analytics data in Big Table as a textual Avro representation. We have defined a schema for how the data is stored. We can parse it using this library, and validate the stored data matches the schema, but when we read the payload in the stored data we cannot find how to parse the data to get a JSON representation of it.
We have this avsc:
This raw data in Big Table:
And this result:
We used this process:
Are we misunderstanding how to process the value array into regular json? We would expect:
Thanks!
The text was updated successfully, but these errors were encountered: