refactor(dynamictable): derive schema-defined column routing from the schema - #858
Open
ehennestad wants to merge 6 commits into
Open
refactor(dynamictable): derive schema-defined column routing from the schema#858ehennestad wants to merge 6 commits into
ehennestad wants to merge 6 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #858 +/- ##
==========================================
- Coverage 95.17% 95.16% -0.01%
==========================================
Files 230 232 +2
Lines 8199 8198 -1
==========================================
- Hits 7803 7802 -1
Misses 396 396 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Three of the four cases in DynamicTableColumnStorageTest duplicated existing coverage in dynamicTableTest, and the file did no export or read round-trip, so it did not belong under +tests/+system. Move the one new case - a ragged schema column pair routing to its generated properties with only the data column in colnames - into dynamicTableTest alongside the other addColumn routing tests, and drop the system test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Removed test that needs full type generation for rare edge case
ehennestad
enabled auto-merge
July 30, 2026 09:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Background — #811 taught
addColumnto route schema-defined columns to their generated property instead of the genericvectordataset.Problem — it answered "is this property a table column?" at runtime, by constructing a throwaway table plus throwaway
VectorData/VectorIndex/DynamicTableRegionobjects and testing which ones the property setter would accept. That is an expensive and roundabout way to ask a question the schema already answers, and it drags a pile of probe helpers intoresolveColumnStorage. It is also inexact: an emptyVectorDatais a validData, so a dataset that merely accepts a column object was indistinguishable from one that is a column.Solution — decide it from the schema, at code-generation time. A property is a table column when its dataset type descends from
VectorData. Each generatedDynamicTableclass records its own column names, andaddColumnreads that list — no dummy objects, no try-assign probing, and one shared definition of what counts as a column.What changed
Refactor
resolveColumnStorageno longer instantiates throwaway objects; the probe helpers are gone and the routing decision is a lookup.DynamicTablegain a private constant listing their schema-defined columns.TimeIntervalsandUnitsbehave exactly as before:start_timestill lands on the generated property,custom_columnstill goes to thevectordataset.Bug fixes — neither of these was reported by a user; both surfaced once the column definition became exact.
DynamicTableextension were treated as columns. An extension may declare a dataset inside aDynamicTablethat is not a column — per-table metadata, a lookup table, anything typedDatarather thanVectorData. Setting one registered its name incolnames, so the table advertised a column that does not exist. It no longer does, andaddColumnon a name that collides with such a dataset now fails withNWB:DynamicTable:AddColumn:InvalidPropertyCollisionnaming the property and class, instead of a generic type-conversion error from inside the setter.colnameswas unvalidated whereDynamicTablelives in thecorenamespace (NWB ≤ 2.1.0). Assigning duplicate column names tocolnameswas silently accepted on those schema versions. It is now rejected on everyDynamicTable, matching the behavior on current schemas.Implementation notes
file.internal.isSchemaDefinedTableColumnis the single definition of "this property is a table column": a scalar, non-constrainedfile.Datasetwhose type descends fromVectorData. BothfillClassandgetPropertyHooksuse it, so the generatedsyncNamedColumnpost-set hooks and the column list can no longer disagree.fillClassemits a privateDeclaredSchemaColumnsconstant per class;DynamicTableBase.getSchemaDefinedColumnsaggregates it across the generated hierarchy viamatnwb.neurodata.internal.collectConstantPropertiesAcrossHierarchy, so inherited columns count. Index columns are included there (they are storage targets) but excluded from thesyncNamedColumnhook, so they still do not appear incolnames.resolveColumnStoragenow returns both a storage target and a storage name, resolved throughio.internal.getPropertyNameForSchemaName. The name mapping exists because the schema addedeventstoNWBFileandeventscollides with a MATLAB classdef keyword; routing every property lookup through the remapper is the consistent direction, so a column whose schema name needs remapping resolves correctly. This is defensive generalization — no shipped schema has such a column today.getPropertyHookscheck for thecolnamesvalidator now keying on the type name rather than the fully qualified class name, so it applies whereverDynamicTableis defined.Examples
The examples below use the test extension added in this PR (
+tests/test-schema/dynamicTableColumnSchema): aDynamicTablewith oneVectorDatadataset (schema_column, a real column) and oneDatadataset (table_metadata, not a column).A non-column dataset is no longer registered as a column
Before
After
Adding a colliding column reports the collision
Before
After
Duplicate column names are caught on core-namespace
DynamicTableWith types generated for NWB 2.1.0, where
DynamicTableis defined in thecorenamespace:Before
After
How to test
Expected output:
Checklist
fix #XXwhereXXis the issue number?🤖 Generated with Claude Code