Skip to content

Iceberg: re-plan views from their SQL so they read the latest table version #2726

Closed

Description

@NoahKusaba

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

Follow-up from this review comment on #2638.

ballista-iceberg pins each catalog-backed Iceberg table to the version its catalog serves when a query is planned, so every scan in the query, such as each side of a self-join, reads the same version, and encoding plans needs no I/O.

A view stores a planned query, so it keeps the version from when it was created. In single-process DataFusion, a view over IcebergCatalogTableProvider picks up new commits each time it runs. On Ballista it doesn't, so the same code gives different results once it moves to Ballista. The same goes for a DataFrame or a Flight SQL prepared statement run more than once. This is documented as a limitation in #2638.

Describe the solution you'd like

Re-plan a view from its SQL each time a query uses it, as Spark does: Spark stores a view's SQL text and analyzes it again for every query that references it, so its tables resolve to their current versions.

DataFusion's ViewTable already keeps the SQL it was created from (ViewTable::definition()). ballista-iceberg's pinning schema wrapper, which already sees every table lookup, could re-plan a view that has a definition when it's looked up, pinning its Iceberg tables to the versions current at that time.

Open questions:

  • SchemaProvider::table gets no session state to plan the SQL with.
  • A view created without SQL, such as from a DataFrame, has no definition to re-plan.
  • Whether reused DataFrames and prepared statements should re-plan too, and how.

Describe alternatives you've considered

  • Pin tables when the scheduler receives the plan rather than when the client plans it. Views would still hold the client's plan, and encoding would need catalog I/O.
  • Leave it as a documented limitation, as feat(iceberg): scan Iceberg tables in Ballista #2638 does.

Additional context

Part of #2174.

Activity

  1. NoahKusaba commented on Nov 3, 2026

    @NoahKusaba
    ContributorAuthor

    Fixed in 9025298 on #2638.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions