Skip to content

feat(core): allow unit tests on incremental tables (full-refresh query) - #2515

Open
dmargol1 wants to merge 1 commit into
dataform-co:mainfrom
dmargol1:feat/incremental-unit-tests
Open

dmargol1 wants to merge 1 commit into
dataform-co:mainfrom
dmargol1:feat/incremental-unit-tests

Conversation

@dmargol1

Copy link
Copy Markdown
Contributor

Fixes #2120. Related: #1132, #2117.

This implements the approach @ihistand proposed in #2120 and @kolina agreed to: allow tests on incremental tables, test the full-refresh query, and document the limitation.

Change

  • core/actions/test.ts: remove the "Running tests on incremental datasets is not yet supported" rejection. RefReplacingContext.incremental() is already false, so an incremental table is tested with its full-refresh SELECT.
  • core/session.ts: includeTestsInCompiledGraph rejected incremental tables too ("Tests are only supported for Tables and Views"). It now accepts them, so they depend on their tests like tables and views do.
  • No-query datasets: a test on a dataset with no ahead-of-time query (JiT, or a JS publish() without .query()) now gets a compile error saying so. Before, it crashed with Cannot read properties of undefined (reading 'trim').
  • Docs (core/README.md, the Test doc comment and docs/reference/test.md):
    • only the full-refresh SELECT is tested;
    • refs in either argument of when(incremental(), ...) still need inputs;
    • pre/post operations aren't run, and self(), name(), schema() and database() are empty strings in tests.

Full-refresh testing becomes the default for incremental tables. Testing the incremental query itself, with an input for the current table as @kolina described, could be added later as an opt-in mode without changing existing tests.

Tests

The old "not yet supported" test is replaced by 9 tests in core/actions/test_test.ts. All of them fail on main.

  • Incremental tables: SQLX and JS API tests check the whole test proto. In the SQLX case, pre_operations, incremental_where and post_operations are excluded.
  • Refs in either when() argument: they need an input.
  • includeTestsInCompiledGraph: adds the dependency edge.
  • New compile error: JiT table/view/incremental and query-less JS table/incremental all get it.

bazel test //core/... passes, and ESLint and Prettier are clean on the changed .ts files. dataform test against BigQuery, with a CLI built from this branch and literal inputs, passes and fails the expected cases.

🤖 Generated with Claude Code

@dmargol1
dmargol1 requested a review from a team as a code owner November 27, 2026 23:42
@dmargol1
dmargol1 requested review from apilaskowski and removed request for a team November 27, 2026 23:42
@google-cla

google-cla Bot commented Nov 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Tests on incremental tables were rejected with "Running tests on
incremental datasets is not yet supported", and includeTestsInCompiledGraph
rejected them too. Accept them: RefReplacingContext.incremental() is
false, so the test runs the full-refresh SELECT.

A test on a dataset with no ahead-of-time query (JiT, or a JS publish()
without .query()) now reports a compile error instead of crashing on
undefined.trim().

Document what tests on incremental tables cover.

Fixes dataform-co#2120

This branch has not been deployed

No deployments
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.

feat: support test for incremental tables

2 participants