Module load.tables in plugin tabular v0.5.0
| Author(s) | Markus Binsteiner (markus@frkl.io) |
| Tags | tabular |
| Python class | kiara_plugin.tabular.modules.tables.DeserializeTableModule |
Module configuration options
Configuration class: kiara.modules.included_core_modules.serialization.SerializeConfig
| Name | Description | Type | Required? | Default |
|---|---|---|---|---|
| serialization_profile | The name of the serialization profile used to serialize the source value. | string | true | null |
| target_profile | The profile name of the de-serialization result data. | string | true | null |
| value_type | The value type of the actual (unserialized) value. | string | true | null |
| constants | Value constants for this module. | object | false | null |
| defaults | Value defaults for this module. | object | false | null |
Module source code
class DeserializeTableModule(DeserializeValueModule):
_module_type_name = "load.tables"
@classmethod def retrieve_supported_target_profiles(cls) -> Mapping[str, Type]: return {"python_object": KiaraTables}
@classmethod def retrieve_serialized_value_type(cls) -> str: return "tables"
@classmethod def retrieve_supported_serialization_profile(cls) -> str: return "feather"
def to__python_object(self, data: SerializedData, **config: Any):
import pyarrow as pa
tables: Dict[str, Any] = {}
for column_id in data.get_keys():
if TABLE_COLUMN_SPLIT_MARKER not in column_id: raise KiaraException( f"Invalid serialized 'tables' data, key must contain '{TABLE_COLUMN_SPLIT_MARKER}': {column_id}" ) table_id, column_name = column_id.split( TABLE_COLUMN_SPLIT_MARKER, maxsplit=1 )
chunks = data.get_serialized_data(column_id)
# TODO: support multiple chunks assert chunks.get_number_of_chunks() == 1 files = list(chunks.get_chunks(as_files=True, symlink_ok=True)) assert len(files) == 1
file = files[0] with pa.memory_map(file, "r") as column_chunk: loaded_arrays: pa.Table = pa.ipc.open_file(column_chunk).read_all() column = loaded_arrays.column(column_name) tables.setdefault(table_id, {})[column_name] = column
table = KiaraTables.create_tables(tables) return table