Skip to content

Display View

Experimental

The Workbench View classes are currently in experimental mode so have fun but expect issues and API changes going forward.

Note: This class will be used in the future to fine tune what columns get displayed. For now just use the DataSource/FeatureSet set_computation_columns() DataSource or FeatureSet

DisplayView Class: Create a View with a subset of columns for display purposes

DisplayView

Bases: ColumnSubsetView

DisplayView Class: Create a View with a subset of columns for display purposes

Common Usage
# Create a default DisplayView
fs = FeatureSet("test_features")
display_view = DisplayView.create(fs)
df = display_view.pull_dataframe()

# Create a DisplayView with a specific set of columns
display_view = DisplayView.create(fs, column_list=["my_col1", "my_col2"])

# Query the view
df = display_view.query(f"SELECT * FROM {display_view.table} where awesome = 'yes'")
Source code in src/workbench/core/views/display_view.py
class DisplayView(ColumnSubsetView):
    """DisplayView Class: Create a View with a subset of columns for display purposes

    Common Usage:
        ```python
        # Create a default DisplayView
        fs = FeatureSet("test_features")
        display_view = DisplayView.create(fs)
        df = display_view.pull_dataframe()

        # Create a DisplayView with a specific set of columns
        display_view = DisplayView.create(fs, column_list=["my_col1", "my_col2"])

        # Query the view
        df = display_view.query(f"SELECT * FROM {display_view.table} where awesome = 'yes'")
        ```
    """

    @classmethod
    def create(
        cls,
        artifact: Union[DataSource, FeatureSet],
        source_table: str = None,
        column_list: Union[list[str], None] = None,
        column_limit: int = 30,
    ) -> Union[View, None]:
        """Factory method to create and return a DisplayView instance.

        Args:
            artifact (Union[DataSource, FeatureSet]): The DataSource or FeatureSet object
            source_table (str, optional): The table/view to create the view from. Defaults to None
            column_list (Union[list[str], None], optional): A list of columns to include. Defaults to None.
            column_limit (int, optional): The max number of columns to include. Defaults to 30.

        Returns:
            Union[View, None]: The created View object (or None if failed to create the view)
        """
        # Use the create logic directly from ColumnSubsetView with the "display" view name
        return ColumnSubsetView.create("display", artifact, source_table, column_list, column_limit)

create(artifact, source_table=None, column_list=None, column_limit=30) classmethod

Factory method to create and return a DisplayView instance.

Parameters:

Name Type Description Default
artifact Union[DataSource, FeatureSet]

The DataSource or FeatureSet object

required
source_table str

The table/view to create the view from. Defaults to None

None
column_list Union[list[str], None]

A list of columns to include. Defaults to None.

None
column_limit int

The max number of columns to include. Defaults to 30.

30

Returns:

Type Description
Union[View, None]

Union[View, None]: The created View object (or None if failed to create the view)

Source code in src/workbench/core/views/display_view.py
@classmethod
def create(
    cls,
    artifact: Union[DataSource, FeatureSet],
    source_table: str = None,
    column_list: Union[list[str], None] = None,
    column_limit: int = 30,
) -> Union[View, None]:
    """Factory method to create and return a DisplayView instance.

    Args:
        artifact (Union[DataSource, FeatureSet]): The DataSource or FeatureSet object
        source_table (str, optional): The table/view to create the view from. Defaults to None
        column_list (Union[list[str], None], optional): A list of columns to include. Defaults to None.
        column_limit (int, optional): The max number of columns to include. Defaults to 30.

    Returns:
        Union[View, None]: The created View object (or None if failed to create the view)
    """
    # Use the create logic directly from ColumnSubsetView with the "display" view name
    return ColumnSubsetView.create("display", artifact, source_table, column_list, column_limit)

Questions?

The SuperCowPowers team is happy to answer any questions you may have about AWS and Workbench. Please contact us at workbench@supercowpowers.com or on chat us up on Discord