Skip to content

[SPARK-XXXXX][SQL][TESTS] Add DSv2 temp view with stored plan tests#55540

Open
longvu-db wants to merge 2 commits intoapache:masterfrom
longvu-db:dsv2-classic-pr1-temp-views
Open

[SPARK-XXXXX][SQL][TESTS] Add DSv2 temp view with stored plan tests#55540
longvu-db wants to merge 2 commits intoapache:masterfrom
longvu-db:dsv2-classic-pr1-temp-views

Conversation

@longvu-db
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add 11 new tests to DataSourceV2DataFrameSuite that verify temporary view behavior with stored plans when the underlying DSv2 table changes. The tests cover all 7 scenarios from the DSv2 table refresh design doc:

  1. Session and external writes (scenarios 1.1, 1.2): Temp view with filter reflects new data after session or external writes.
  2. Adding columns with data (scenarios 2.1, 2.2): Temp view preserves original schema after ADD COLUMN, both session and external.
  3. Removing columns (scenario 3.2): Temp view detects external column removal via catalog API.
  4. Drop and recreate table (scenario 4.2): Temp view resolves to externally recreated table.
  5. Drop and re-add column with same type (scenarios 5.1, 5.2): Schema validation passes, view continues working.
  6. Drop and re-add column with different type (scenarios 6.1, 6.2): Temp view detects type change.
  7. Type widening (scenario 7): Temp view detects INT to BIGINT type change.

Each test creates a DSv2 table, inserts initial data, builds a temp view with a filter (salary < 999) to demonstrate stored plan behavior, and verifies the view after table modifications.

External writes use the direct catalog API (loadTable + withData) to simulate writes from outside the session.

Why are the changes needed?

The existing SPARK-53924 tests in DataSourceV2DataFrameSuite cover basic schema change detection for temp views on DSv2 tables but are missing:

  • Filter-based stored plan tests (the design doc uses a filter to demonstrate non-trivial stored plans)
  • External write variants (using catalog API to simulate writes from outside the session)
  • Scenarios 5, 6, 7 (drop+re-add column same/different type, type widening)

These tests provide comprehensive coverage for the DSv2 table refresh design doc's Section 1 (Temp views with stored plans).

Does this PR introduce any user-facing change?

No. This PR only adds tests.

How was this patch tested?

All 11 new tests pass:

build/sbt 'sql/testOnly *DataSourceV2DataFrameSuite -- -z "temp view with stored plan"'

All 21 SPARK-53924 tests (10 existing + 11 new) pass with no regressions:

build/sbt 'sql/testOnly *DataSourceV2DataFrameSuite -- -z "SPARK-53924"'

Was this patch authored or co-authored using generative AI tooling?

Yes.

Add 11 new tests to DataSourceV2DataFrameSuite that verify temp view behavior
with stored plans when the underlying DSv2 table changes. Tests cover all 7
scenarios from the DSv2 table refresh design doc, including both session and
external write variants.

Co-authored-by: Isaac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant