Skip to content

Improve json serialization #2430

@Ariana-B

Description

@Ariana-B

The jsonify_document function is used in several places (including other odc packages) to convert certain value types to strings - notably, it is part of the json serializer function passed to create_engine for both the postgres and postgis drivers. Per the comment in _to_json, this seems to be due to postgres<=9.5 not supporting nan and infinite values, and so should no longer be necessary as part of indexing.
However, removing these string conversions will create an issue with the use of orjson, which serialises nan and +/-inf as null and does not provide any option to alter this behaviour, so it will need to be replaced with a different json library such as rapidjson. This would be slower than orjson, but it may very well be that any performance benefits provided by orjson are currently being offset by the performance hit of jsonify_document anyway.
It is also worth noting that jsonify_document is used to compare existing metadata type/product/dataset definition/metadata documents with new ones, so we would need to update the affected entries or implement some extra comparison logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions