Skip to content

Testing Warehouse data

The first Table and View ended with two passing validations. This page explains what they check and what a failure looks like. Use the same parcel project; if you are starting here, run the Table and View task first.

Check the result without repeating the ranking query

Open the generated Warehouse/Operations/tests/Parcel.CurrentStatusMatches.sql:

/*
Test ID: Parcel.CurrentStatusMatches

Description: Latest parcel status matches the independently expected rows.

Primary key: Parcel ID
*/
select v.[Parcel ID]
     , v.[Status]
     , v.[Depot]
from (values
    ('P-1001', 'In transit', 'Central'),
    ('P-1002', 'Delivered', 'South')
) as v ([Parcel ID], [Status], [Depot]);

select [Parcel ID]
     , [Status]
     , [Depot]
from [Parcel].[CurrentStatus];

A Test has two result sets: expected first, then actual. The expected rows state what the sample events mean instead of repeating the View's window function, so a defect in that function shows up as a discrepancy.

Find events outside the accepted vocabulary

Open the generated Warehouse/Operations/assumptions/Parcel.StatusIsKnown.sql:

/*
Assumption ID: Parcel.StatusIsKnown

Description: Every recorded parcel event has a recognised status.
*/
select [Parcel ID]
     , [Event sequence]
     , [Status]
from [Parcel].[StatusEvent]
where [Status] is null
   or [Status] not in ('Accepted', 'In transit', 'Delivered');

Every returned row violates the description. No returned rows means the Assumption passes. This check reads all events, including those hidden by the latest-status View, and its relation reference establishes the dependency on Parcel.StatusEvent.

Run both validations

Initialise wrote both files and the first Build installed them, so there is nothing to build. Run them against the loaded data:

weaver test Warehouse/Operations

The command returned:

Terminal output exit 0
Test

  Read catalogue                                                                                           3.0s
Workspace  Parcel Development
Catalogue  Warehouse/Catalogue
Targets
  Warehouse/Operations

  Build run graph                                                                                          0.0s
→   Test Warehouse/Operations/Parcel.CurrentStatusMatches
→   Test Warehouse/Operations/Parcel.StatusIsKnown
✓   Test Warehouse/Operations/Parcel.StatusIsKnown                                                         1.7s
✓   Test Warehouse/Operations/Parcel.CurrentStatusMatches                                                  7.7s
  Execute                                                                                                  7.9s
  Record what the run did                                                                                  0.9s
✓ Test                                                                                                    11.8s

test passed

Test summary
    2 passed
    0 failed
  Workflow: 487b69ed9b984916b74bdc7e3243fcd7

from pathlib import Path

import weaver

project = Path("builtin") / "project"
test_result = weaver.test(
    items=['Warehouse/Operations'],
    source=project,
    workspace='Parcel Development',
    catalogue='Warehouse/Catalogue',
)
test_result.report()

The command returned:

Notebook output
{'status': 'passed',
 'nodes': [{'logical_id': 'Warehouse/Operations/Parcel.CurrentStatusMatches',
            'kind': 'test',
            'physical_target': 'Warehouse/Operations',
            'primitive_kind': 'warehouse_procedure',
            'dispatch_location': 'Warehouse/Operations/[_].[Load Parcel.CurrentStatusMatches]',
            'status': 'passed',
            'executed': True,
            'messages': [],
            'started_at': '2026-10-17T07:26:13.615758+00:00',
            'finished_at': '2026-10-17T07:26:18.358925+00:00',
            'missing_count': 0,
            'unexpected_count': 0,
            'failure_count': 0,
            'error_message': None},
           {'logical_id': 'Warehouse/Operations/Parcel.StatusIsKnown',
            'kind': 'assumption',
            'physical_target': 'Warehouse/Operations',
            'primitive_kind': 'warehouse_procedure',
            'dispatch_location': 'Warehouse/Operations/[_].[Load Parcel.StatusIsKnown]',
            'status': 'passed',
            'executed': True,
            'messages': [],
            'started_at': '2026-10-17T07:26:13.618396+00:00',
            'finished_at': '2026-10-17T07:26:14.944292+00:00',
            'violation_count': 0,
            'error_message': None}],
 'totals': {'planned': 2,
            'executed': 2,
            'passed': 2,
            'failed': 0,
            'invalid': 0,
            'missing_count': 0,
            'unexpected_count': 0,
            'violation_count': 0},
 'workflow_id': '[run-id]',
 'started_at': '2026-10-17T07:26:13.475160+00:00',
 'finished_at': '2026-10-17T07:26:18.798465+00:00'}

Test runs installed validations; it does not load their inputs. A failed validation ran and found a discrepancy or violation. An invalid result means the validation could not run, which is neither a finding nor a pass. Test behaviour owns the exact outcome and recording rules.

When you add or edit a validation, weaver check and weaver build --item Warehouse/Operations install it first. Data that has not changed needs no Load.

Optional: inspect a failed Test, restore it and try source-file testing

Optional: make one discrepancy visible

Replace Warehouse/Operations/tests/Parcel.CurrentStatusMatches.sql with this complete version. It deliberately expects the wrong status for P-1002:

/*
Test ID: Parcel.CurrentStatusMatches

Description: Latest parcel status matches the independently expected rows.

Primary key: Parcel ID
*/
select v.[Parcel ID]
     , v.[Status]
     , v.[Depot]
from (values
    ('P-1001', 'In transit', 'Central'),
    ('P-1002', 'In transit', 'South')
) as v ([Parcel ID], [Status], [Depot]);

select [Parcel ID]
     , [Status]
     , [Depot]
from [Parcel].[CurrentStatus];

Install the edited Test and select it for diagnostics:

weaver check
weaver build --item Warehouse/Operations
weaver test Warehouse/Operations --name 'Parcel[.]CurrentStatusMatches'

The command returned:

Terminal output exit 1
Test

  Read catalogue                                                                                           2.8s
Workspace  Parcel Development
Catalogue  Warehouse/Catalogue
Targets
  Warehouse/Operations

  Build run graph                                                                                          0.0s
→   Test Warehouse/Operations/Parcel.CurrentStatusMatches
✗   Test Warehouse/Operations/Parcel.CurrentStatusMatches  (1 missing, 1 unexpected)                       6.1s
  Execute                                                                                                  6.2s
  Record what the run did                                                                                  0.5s
✗ Test                                                                                                     9.5s

test failed

  failed     Test        Warehouse/Operations/Parcel.CurrentStatusMatches  (1 missing, 1 unexpected)

Test summary
    0 passed
    1 failed
  Workflow: c70289748d8d4bbab7172dcdd44a003e

  Warehouse/Operations/Parcel.CurrentStatusMatches:
    {'_weaver_side': 'expected', '_weaver_sk': 1, 'Parcel ID': 'P-1002', 'Status': 'In transit', 'Depot': 'South'}
    {'_weaver_side': 'actual', '_weaver_sk': 1, 'Parcel ID': 'P-1002', 'Status': 'Delivered', 'Depot': 'South'}
weaver health --item Warehouse/Operations

The command returned:

Terminal output exit 1
Health

  Read catalogue                                                                                           2.6s
  Check installed items                                                                                    0.1s
  Read installed objects                                                                                   0.7s
✓ Health                                                                                                   3.4s

Weaver Health  Red

Load    Green
  Last load activity   0h 1m ago
  1 succeeded

Tests   Red
  1 failed · 1 succeeded
  Red    Warehouse/Operations/Parcel.CurrentStatusMatches
          the last run failed

Build   Green
  Installed estate consistent (10 objects)

Slowest loads
  Warehouse/Operations/Parcel.StatusEvent     4.9s

Largest changes
  Warehouse/Operations/Parcel.StatusEvent     read 3  +3 ~0 -0 !0

1
2
3
4
5
6
7
import weaver
health_result = weaver.health(
    items=['Warehouse/Operations'],
    workspace='Parcel Development',
    catalogue='Warehouse/Catalogue',
)
health_result.report()

The command returned:

Notebook output
{'format_version': 3,
 'generated_at': '2026-10-17T07:24:24.578626+00:00',
 'as_of': '2026-10-16T07:24:24.578626+00:00',
 'status': 'green',
 'targets': ['Warehouse/Operations'],
 'sections': {'load': {'status': 'green',
                       'subjects': 9,
                       'counts': {'succeeded': 9},
                       'findings': []},
              'tests': {'status': 'green',
                        'subjects': 2,
                        'counts': {'succeeded': 2},
                        'findings': []},
              'build': {'status': 'green', 'subjects': 20, 'counts': {}, 'findings': []}},
 'current_load': {'workflow_ids': ['[run-id]'],
                  'started_at': '2026-10-16T16:53:41.564253+00:00',
                  'completed_at': '2026-10-16T16:54:00.580059+00:00',
                  'counts': {'succeeded': 9}},
 'load_activity': [{'object_id': 'Warehouse/Operations/Parcel.Daily',
                    'target': 'Warehouse/Operations',
                    'workflow_id': '[run-id]',
                    'started_at': '2026-10-16T16:53:45.134094+00:00',
                    'completed_at': '2026-10-16T16:53:46.630224+00:00',
                    'duration_ms': 1496,
                    'rows_read': 1,
                    'rows_inserted': 1,
                    'rows_updated': 0,
                    'rows_deleted': 0,
                    'rows_rejected': 0,
                    'is_reload': False,
                    'is_static_skip': False},
                   {'object_id': 'Warehouse/Operations/Parcel.Events',
                    'target': 'Warehouse/Operations',
                    'workflow_id': '[run-id]',
                    'started_at': '2026-10-16T16:53:43.841515+00:00',
                    'completed_at': '2026-10-16T16:53:45.133378+00:00',
                    'duration_ms': 1291,
                    'rows_read': 1,
                    'rows_inserted': 1,
                    'rows_updated': 0,
                    'rows_deleted': 0,
                    'rows_rejected': 0,
                    'is_reload': False,
                    'is_static_skip': False},
                   {'object_id': 'Warehouse/Operations/Parcel.LakehouseCurrentStatus',
                    'target': 'Warehouse/Operations',
                    'workflow_id': '[run-id]',
                    'started_at': '2026-10-16T16:53:58.872352+00:00',
                    'completed_at': '2026-10-16T16:54:00.580059+00:00',
                    'duration_ms': 1707,
                    'rows_read': 2,
                    'rows_inserted': 2,
                    'rows_updated': 0,
                    'rows_deleted': 0,
                    'rows_rejected': 0,
                    'is_reload': False,
                    'is_static_skip': False},
                   {'object_id': 'Warehouse/Operations/Parcel.LiveStatus',
                    'target': 'Warehouse/Operations',
                    'workflow_id': '[run-id]',
                    'started_at': '2026-10-16T16:53:41.564857+00:00',
                    'completed_at': '2026-10-16T16:53:46.973535+00:00',
                    'duration_ms': 5408,
                    'rows_read': 1,
                    'rows_inserted': 1,
                    'rows_updated': 0,
                    'rows_deleted': 0,
                    'rows_rejected': 0,
                    'is_reload': False,
                    'is_static_skip': False},
                   {'object_id': 'Warehouse/Operations/Parcel.RawEvents',
                    'target': 'Warehouse/Operations',
                    'workflow_id': '[run-id]',
                    'started_at': '2026-10-16T16:53:41.564253+00:00',
                    'completed_at': '2026-10-16T16:53:43.841173+00:00',
                    'duration_ms': 2276,
                    'rows_read': 1,
                    'rows_inserted': 1,
                    'rows_updated': 0,
                    'rows_deleted': 0,
                    'rows_rejected': 0,
                    'is_reload': False,
                    'is_static_skip': False},
                   {'object_id': 'Warehouse/Operations/Parcel.StatusEvent',
                    'target': 'Warehouse/Operations',
                    'workflow_id': '[run-id]',
                    'started_at': '2026-10-16T16:53:41.564999+00:00',
                    'completed_at': '2026-10-16T16:53:44.280522+00:00',
                    'duration_ms': 2715,
                    'rows_read': 3,
                    'rows_inserted': 3,
                    'rows_updated': 0,
                    'rows_deleted': 0,
                    'rows_rejected': 0,
                    'is_reload': False,
                    'is_static_skip': False},
                   {'object_id': 'Warehouse/Operations/Parcel.Summary',
                    'target': 'Warehouse/Operations',
                    'workflow_id': '[run-id]',
                    'started_at': '2026-10-16T16:53:46.631862+00:00',
                    'completed_at': '2026-10-16T16:53:47.936424+00:00',
                    'duration_ms': 1304,
                    'rows_read': 1,
                    'rows_inserted': 1,
                    'rows_updated': 0,
                    'rows_deleted': 0,
                    'rows_rejected': 0,
                    'is_reload': False,
                    'is_static_skip': False},
                   {'object_id': 'Warehouse/Operations/Reference.Depot',
                    'target': 'Warehouse/Operations',
                    'workflow_id': '[run-id]',
                    'started_at': '2026-10-16T16:53:41.565295+00:00',
                    'completed_at': '2026-10-16T16:53:43.823659+00:00',
                    'duration_ms': 2258,
                    'rows_read': 1,
                    'rows_inserted': 1,
                    'rows_updated': 0,
                    'rows_deleted': 0,
                    'rows_rejected': 0,
                    'is_reload': False,
                    'is_static_skip': False},
                   {'object_id': 'Warehouse/Operations/Reference.Service',
                    'target': 'Warehouse/Operations',
                    'workflow_id': '[run-id]',
                    'started_at': '2026-10-16T16:53:43.827082+00:00',
                    'completed_at': '2026-10-16T16:53:45.104187+00:00',
                    'duration_ms': 1277,
                    'rows_read': 1,
                    'rows_inserted': 1,
                    'rows_updated': 0,
                    'rows_deleted': 0,
                    'rows_rejected': 0,
                    'is_reload': False,
                    'is_static_skip': False}]}

The finding is one missing row (P-1002, In transit, South) and one unexpected row (P-1002, Delivered, South). Test exits non-zero; Health records Tests as Red. The selector is a case-insensitive whole-name regular expression, so [.] matches the literal dot.

Change P-1002 back to Delivered, then install and rerun the Test:

weaver check
weaver build --item Warehouse/Operations
weaver test Warehouse/Operations
weaver health --item Warehouse/Operations

The command returned:

Terminal output exit 0
Health

  Read catalogue                                                                                           2.6s
  Check installed items                                                                                    0.1s
  Read installed objects                                                                                   0.7s
✓ Health                                                                                                   3.4s

Weaver Health  Green

Load    Green
  Last load activity   0h 1m ago
  1 succeeded

Tests   Green
  2 succeeded

Build   Green
  Installed estate consistent (10 objects)

Slowest loads
  Warehouse/Operations/Parcel.StatusEvent     4.9s

Largest changes
  Warehouse/Operations/Parcel.StatusEvent     read 3  +3 ~0 -0 !0

Both validations passed and the item returned to Green.

To try edited SQL against deployed data before installing it, use file mode:

weaver test Warehouse/Operations --source . --file 'Warehouse/Operations/tests/Parcel.CurrentStatusMatches.sql'

The command returned:

Terminal output exit 0
Test

  Read validations                                                                                         0.1s
  Execute                                                                                                  6.0s
✓ Test                                                                                                     6.1s

test passed

Test summary
    1 passed
    0 failed

from pathlib import Path

import weaver

project = Path("builtin") / "project"
test_result = weaver.test(
    items=['Warehouse/Operations'],
    files=['Warehouse/Operations/tests/Parcel.CurrentStatusMatches.sql'],
    source=project,
    workspace='Parcel Development',
    catalogue='Warehouse/Catalogue',
)
test_result.report()

The command returned:

Notebook output
{'status': 'passed',
 'nodes': [{'logical_id': 'Warehouse/Operations/Parcel.CurrentStatusMatches',
            'kind': 'test',
            'physical_target': 'Warehouse/Operations',
            'primitive_kind': 'warehouse_procedure',
            'dispatch_location': 'Warehouse/Operations/tests/Parcel.CurrentStatusMatches.sql',
            'status': 'passed',
            'executed': True,
            'messages': [],
            'started_at': '2026-10-17T07:26:22.794447+00:00',
            'finished_at': '2026-10-17T07:26:28.295378+00:00',
            'missing_count': 0,
            'unexpected_count': 0,
            'failure_count': 0,
            'error_message': None}],
 'totals': {'planned': 1,
            'executed': 1,
            'passed': 1,
            'failed': 0,
            'invalid': 0,
            'missing_count': 0,
            'unexpected_count': 0,
            'violation_count': 0},
 'workflow_id': None,
 'started_at': '2026-10-17T07:26:22.794447+00:00',
 'finished_at': '2026-10-17T07:26:28.295828+00:00'}

--file selects file mode even with a catalogue configured. File mode records no Test status or history, which is why its output has no workflow identifier. --source alone does not select file mode. Test CLI covers repeatable file and name selectors. Test and Assumption define the complete SQL forms.

A row only in expected is missing; a row only in actual is unexpected. A changed row produces one of each. The optional Primary key correlates the diagnostic rows without changing that comparison. The actual query establishes the dependency on Parcel.CurrentStatus.

These checks now describe the result you expect, but the event feed is still a constant in a SQL file. Loading changes uses a changing-source example: the same parcels arrive through an external Warehouse, and a keyed Table consumes updates and cancellations without rebuilding its definition.