perspective-dev/perspective · error · TypeError

Views cannot be loaded directly, load a table or raw data…

Error message

Views cannot be loaded directly, load a table or raw data instead

What it means

PerspectiveViewer.load() accepts a Table, AsyncTable, raw data, or a schema — but not an already-created View. A View is derived viewer state, not a data source; loading one would create circular/conflicting configuration, so the method guards against it before dispatching to the table-loading path.

Solutions

  1. Load the underlying table: viewer.load(view.table)
  2. Load raw data or a schema instead of a View object
  3. Create a new viewer and copy the View's config (group_by, aggregates, etc.) onto it via restore()
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at rust/perspective-python/perspective/widget/viewer/viewer.py:227 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of perspective-dev/perspective@11c8238c0c (2026-09-09). Data as JSON: /api/errors/2a7a360372d8096b. Report an issue: GitHub.

Appendix: source

Thrown at rust/perspective-python/perspective/widget/viewer/viewer.py:227

        if self.table is not None:
            self.reset()

        if isinstance(data, perspective.perspective.AsyncTable):
            self._table = data
            async def load_table():
                self._client = await self.table.get_client()
                self.table_name = self.table.get_name()
                # If the user does not set columns to show, synchronize viewer state
                # with dataset.
                if len(self.columns) == 0:
                    self.columns = await self.table.columns()

            return load_table()
        elif isinstance(data, perspective.perspective.Table):
            self._table = data
            self._client = data.get_client()
        elif isinstance(data, perspective.perspective.View) or isinstance(data, perspective.perspective.AsyncView):
            raise TypeError(
                "Views cannot be loaded directly, load a table or raw data instead"
            )
        else:
            self._table = perspective.table(data, name=name, **options)
            self._client = perspective.GLOBAL_CLIENT

        # If the user does not set columns to show, synchronize viewer state
        # with dataset.
        if len(self.columns) == 0:
            self.columns = self.table.columns()

        self.table_name = self.table.get_name()

    def update(self, data):
        """Update the table under management by the viewer with new data.
        This function follows the semantics of `Table.update()`, and will be
        affected by whether an index is set on the underlying table.

View on GitHub (pinned to 11c8238c0c)