ds_provider_xledger_py_lib.serde.deserializer¶
File: deserializer.py
Region: ds_provider_xledger_py_lib/serde
Description¶
Deserialize GraphQL responses into tabular dataframe outputs.
Classes¶
Parse GraphQL responses into dataframes using operation metadata. |
Functions¶
|
Extract operation root payload under |
|
Extract standardized connection payload for read operations. |
|
Resolve output columns from operation settings and metadata. |
Module Contents¶
- class ds_provider_xledger_py_lib.serde.deserializer.XledgerDeserializer[source]¶
Bases:
ds_resource_plugin_py_lib.common.serde.deserialize.base.DataDeserializerParse GraphQL responses into dataframes using operation metadata.
- __call__(value: Any, **kwargs: Any) pandas.DataFrame[source]¶
Deserialize a GraphQL response body.
- Parameters:
value – GraphQL response body.
**kwargs – Compatibility kwargs. Requires
metadataandoperation_settings.
- Returns:
Parsed dataframe output.
- get_next(value: Any, **kwargs: Any) bool[source]¶
Return
hasNextPagefrom a read response payload.- Parameters:
value – GraphQL response body.
**kwargs – Compatibility kwargs. Requires
metadata.
- Returns:
Truewhen there is a next page.
- get_end_cursor(value: Any, **kwargs: Any) str | None[source]¶
Return last edge cursor from a read response payload.
- Parameters:
value – GraphQL response body.
**kwargs – Compatibility kwargs. Requires
metadata.
- Returns:
Last cursor when available, otherwise
None.
- get_incremental_watermark(value: Any, *, metadata: ds_provider_xledger_py_lib.utils.introspection.MetaData) Any[source]¶
Return the highest incremental field value from a read response.
Uses
metadata.incrementalfor the node field name and strategy (kind). When read metadata has no incremental section, returnsNonewithout inspecting the payload.- Parameters:
value – GraphQL response body.
metadata – Read operation metadata.
- Returns:
The highest field value found in the current page, or
Nonewhen incremental is not configured or the page has no comparable values.- Raises:
IncrementalFieldMissingException – If rows are present but the incremental field is missing from every returned node.
InvalidIncrementalWatermarkException – If watermark values are invalid for the configured strategy (via
greatest_incremental_value).UnsupportedIncrementalKindException – If incremental
kindis not supported (viagreatest_incremental_value).
- ds_provider_xledger_py_lib.serde.deserializer._root_payload(*, payload: dict[str, Any], metadata: ds_provider_xledger_py_lib.utils.introspection.MetaData) Any[source]¶
Extract operation root payload under
data[metadata.name].- Parameters:
payload – GraphQL response payload.
metadata – Operation metadata carrying the root field name.
- Returns:
Root payload object when present; otherwise
None.
- ds_provider_xledger_py_lib.serde.deserializer._connection_payload(*, payload: dict[str, Any], metadata: ds_provider_xledger_py_lib.utils.introspection.MetaData) dict[str, Any][source]¶
Extract standardized connection payload for read operations.
- Parameters:
payload – GraphQL response payload.
metadata – Read operation metadata.
- Returns:
Connection object when found; otherwise an empty dictionary.
- ds_provider_xledger_py_lib.serde.deserializer._resolve_output_columns(*, metadata: ds_provider_xledger_py_lib.utils.introspection.MetaData, operation_settings: Any) list[str][source]¶
Resolve output columns from operation settings and metadata.
- Parameters:
metadata – Loaded operation metadata.
operation_settings – Operation settings object.
- Returns:
Ordered output columns to apply in dataframe construction.