koladata

Home
Overview
Fundamentals
Glossary
Cheatsheet
API Reference
Quick Recipes
Deep Dive
Common Pitfalls and Gotchas
Persistent Storage

View the Project on GitHub google/koladata

kd_ext.storage.data_slice_path.DataSliceAction API

An action to perform on a data slice. All instances are immutable.

DataSliceAction.debug_string(self) -> str

No description

DataSliceAction.evaluate(self, data_slice: kd.types.DataSlice) -> kd.types.DataSlice

Evaluates the action on the given data slice.

DataSliceAction.get_subschema(self, schema: kd.types.DataItem) -> kd.types.DataItem

Returns the schema after applying the action on a DataSlice with `schema`.

Args:
  schema: the schema of a hypothetical DataSlice.

Returns:
  The schema after applying the action on an arbitrary DataSlice with schema
  `schema`.

Raises:
  IncompatibleSchemaError: if the action is not compatible with the given
    schema.

DataSliceAction.get_subschema_bag(self, schema: kd.types.DataItem) -> kd.types.DataBag

Returns the minimal schema bag needed for the subschema operation.

Args:
  schema: the schema of a hypothetical DataSlice.

Returns:
  The minimal schema bag needed for self.get_subschema_operation() to
  succeed on `schema`.

DataSliceAction.get_subschema_operation(self) -> str

Returns the operation to obtain the subschema in get_subschema.

This is decoupled from str(self), because conceptually the operation on the
schema has a coarser granularity. For example, "[:4]" is a conceptually
valid action on a data slice, but its corresponding schema operation is
the same as that of "[:]", namely ".get_item_schema()".

DataSliceAction.parse_from_data_slice_path_prefix(data_slice_path: str) -> tuple[DataSliceAction, str] | None

Parses the given path to return an action and the remaining path.

Args:
  data_slice_path: the data slice path from which to parse a prefix.

Returns:
  A tuple of the parsed action and the remaining part of the data slice
  path. If the action does not apply, then None is returned. If the action
  is applicable but cannot be parsed, then an ActionParsingError is raised.

Raises:
  ActionParsingError: if the action is applicable but it cannot be parsed.