Skip to content

featurebyte.SCDTable.get_change_view

get_change_view(
track_changes_column: str,
default_feature_job_setting: Optional[FeatureJobSetting]=None,
prefixes: Optional[Tuple[Optional[str], Optional[str]]]=None,
view_mode: Literal[ViewMode.AUTO, ViewMode.MANUAL]="auto",
drop_column_names: Optional[List[str]]=None,
column_cleaning_operations: Optional[List[ColumnCleaningOperation]]=None
) -> ChangeView

Description

Gets a ChangeView from a Slowly Changing Dimension (SCD) table. The view offers a method to examine alterations that occur in a specific attribute within the natural key of the SCD table.

To create the ChangeView, you need to provide the name of the SCD column for which you want to track changes through the track_changes_column parameter.

Optionally,

  • you can define the default Feature Job Setting for the View. Default is once a day, at the time of the creation of the view.
  • you can provide a prefix parameter to control how the views columns are named.

The resulting view has 5 columns:

  • the natural key of the SCDView
  • past_: value of the column before the change
  • new_: value of the column after the change
  • past_valid_from_timestamp (equal to the effective timestamp of the SCD before the change)
  • new_valid_from_timestamp (equal to the effective timestamp of the SCD after the change)

The ChangeView can be used to create Aggregates of Changes Over a Window features, similar to Aggregates Over a Window features created from an Event View.

Parameters

  • track_changes_column: str
    Name of the column to track changes for.

  • default_feature_job_setting: Optional[FeatureJobSetting]
    Default feature job setting to set with the FeatureJobSetting constructor. If not provided, the default feature job setting is daily, aligning with the view's creation time.

  • prefixes: Optional[Tuple[Optional[str], Optional[str]]]
    Optional prefixes where each element indicates the prefix to add to the new column names for the name of the column that we want to track. The first prefix will be used for the old, and the second for the new. If not provided, the column names will be prefixed with the default values of "past_", and "new_". At least one of the values must not be None. If two values are provided, they must be different.

  • view_mode: Literal[ViewMode.AUTO, ViewMode.MANUAL]
    default: "auto"
    View mode to use. When auto, the view will be constructed with cleaning operations.

  • drop_column_names: Optional[List[str]]
    List of column names to drop (manual mode only).

  • column_cleaning_operations: Optional[List[ColumnCleaningOperation]]
    List of cleaning operations to apply per column in manual mode only. Each element in the list indicates the cleaning operations for a specific column. The association between this column and the cleaning operations is established via the ColumnCleaningOperation constructor.

Returns

  • ChangeView
    ChangeView object constructed from the SCD source table.

Examples

Get a ChangeView to track changes in Customer's State.

>>> scd_table = catalog.get_table("GROCERYCUSTOMER")
>>> change_view = scd_table.get_change_view(
...   track_changes_column="State",
...   prefixes=("previous_", "next_"),
... )