Skip to content

[SPARK-56643][CONNECT][TESTS] Add DSv2 temp view with stored plan tests using Spark Connect mode#55455

Closed
longvu-db wants to merge 5 commits intoapache:masterfrom
longvu-db:dsv2-connect-pr1-temp-views
Closed

[SPARK-56643][CONNECT][TESTS] Add DSv2 temp view with stored plan tests using Spark Connect mode#55455
longvu-db wants to merge 5 commits intoapache:masterfrom
longvu-db:dsv2-connect-pr1-temp-views

Conversation

@longvu-db
Copy link
Copy Markdown
Contributor

@longvu-db longvu-db commented Apr 21, 2026

What changes were proposed in this pull request?

Add 11 new tests in DataSourceV2TempViewConnectSuite that verify temporary view behavior with stored plans when the underlying DSv2 table changes, using Spark Connect. 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 via a Connect session, 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.

This is the Spark Connect counterpart of #55540.

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), exercised through Spark Connect.

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 'connect/testOnly *DataSourceV2TempViewConnectSuite'

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

Yes.

@longvu-db longvu-db marked this pull request as draft April 21, 2026 20:48
@longvu-db longvu-db changed the title [SPARK-XXXXX][CONNECT][TESTS] Add Connect temp view refresh tests [SPARK-56643][CONNECT][TESTS] Add Connect temp view refresh tests Apr 27, 2026
@longvu-db longvu-db changed the title [SPARK-56643][CONNECT][TESTS] Add Connect temp view refresh tests [SPARK-56643][CONNECT][TESTS] Add DSv2 temp view with stored plan tests for Spark Connect Apr 27, 2026
Remove all irrelevant files (catalog helpers, DataFrameWriter changes,
base traits). Add DataSourceV2TempViewConnectSuite with 11 tests
matching the classic PR structure exactly.

Co-authored-by: Isaac
@longvu-db longvu-db force-pushed the dsv2-connect-pr1-temp-views branch from 0c52d1b to d13fa35 Compare April 27, 2026 21:03
@longvu-db longvu-db marked this pull request as ready for review April 27, 2026 21:08
@longvu-db longvu-db changed the title [SPARK-56643][CONNECT][TESTS] Add DSv2 temp view with stored plan tests for Spark Connect [SPARK-56643][CONNECT][TESTS] Add DSv2 temp view with stored plan tests in Spark Connect Apr 27, 2026
@longvu-db longvu-db changed the title [SPARK-56643][CONNECT][TESTS] Add DSv2 temp view with stored plan tests in Spark Connect [SPARK-56643][CONNECT][TESTS] Add DSv2 temp view with stored plan tests using Spark Connect mode Apr 27, 2026
…s in S5

Add session variants for scenarios 3 (column removal) and 4 (table
recreate). Add v_unfiltered view to scenario 5. Include InMemoryBaseTable
fix for column drop data migration. Add section comments for all 7
scenarios. Use separate alterTable calls for external variants.

Co-authored-by: Isaac
Remove InMemoryBaseTable change, extra session tests, v_unfiltered,
and section comments to match the current PR apache#55540 structure exactly.

Co-authored-by: Isaac
@longvu-db longvu-db closed this Apr 28, 2026
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