Skip to content

featurebyte.View.create_observation_table

create_observation_table(
name: str,
sample_rows: Optional[int]=None,
columns: Optional[list[str]]=None,
columns_rename_mapping: Optional[dict[str, str]]=None,
context_name: Optional[str]=None,
skip_entity_validation_checks: Optional[bool]=False,
primary_entities: Optional[List[str]]=None
) -> ObservationTable

Description

Creates an ObservationTable from the View. When you specify the columns and the columns_rename_mapping parameters, make sure that the table has:

  • a column containing entity values with an accepted serving name.
  • a column containing historical points-in-time in UTC. The column name must be "POINT_IN_TIME".

Parameters

  • name: str
    Name of the ObservationTable.

  • sample_rows: Optional[int]
    Optionally sample the source table to this number of rows before creating the observation table.

  • columns: Optional[list[str]]
    Include only these columns in the view when creating the observation table. If None, all columns are included.

  • columns_rename_mapping: Optional[dict[str, str]]
    Rename columns in the view using this mapping from old column names to new column names when creating the observation table. If None, no columns are renamed.

  • context_name: Optional[str]
    Context name for the observation table.

  • skip_entity_validation_checks: Optional[bool]
    default: False
    Skip entity validation checks when creating the observation table.

  • primary_entities: Optional[List[str]]
    List of primary entities for the observation table. If None, the primary entities are inferred from the view.

Returns

  • ObservationTable
    ObservationTable object.

Raises

  • ValueError
    If no primary entities are found.

Examples

>>> observation_table = view.create_observation_table(
...   name="<observation_table_name>",
...   sample_rows=10000,
...   columns=["timestamp", "<entity_serving_name>"],
...   columns_rename_mapping={"timestamp": "POINT_IN_TIME"},
...   context_id=context_id,
... )