-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert procedure result to JSON with consistent scalar representations #24
Conversation
As discussed, we should use Extended JSON for values with type |
@dmoverton I disabled |
Yeah I've been wanting to create a more canonical type representation to use, at least while we're doing inference and type unification. It would have its own bottom type. We would then convert into the current |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
I'll merge this once the round-trip test is fixed |
@hallettj I'm happy for you to merge this now |
Implements
bson_to_json
which mostly works as an inverse ofjson_to_bson
. This replaces the bson library's stock serialization implementation which outputs a variation of extjson. We don't want to output extjson (which includes inline type tags) because we keep type information out-of-band, and using extjson would prevent output scalar values from matching input formats despite showing the same scalar types in the graph configuration.I want to apply the same output conversion to normal query responses. That will be in another PR.
I set up round-trip serialization testing to check for consistency between
bson_to_json
andjson_to_bson
.The way it is implemented round-trips do not work with heterogeneous data (cases where we infer a type ofPer our discussions I'll change the representation forAny
at any position). So I configured the round-trip test to avoid those cases. An alternative is to output extjson in cases where we show the type asAny
so we can losslessly convert back and forth - but that has a trade-off where representations would be inconsistent at different parts of the structure. I'm planning to write up a document to discuss the best way to handle this.Any
to extended JSON.For the moment round-trip testing is failing withI fixed these. Round-trip tests caught a bug inDatetime
andDecimal128
types and possibly some others. I intend to fix that before merging this PR.Datetime
conversion, and I added a normalization step when generating arbitraryDecimal128
values.Ticket: https://hasurahq.atlassian.net/browse/MDB-95