Repository navigation
fix(#11552): _sourceRID is a reserved column of a per-record materialized view; the link always wins - #11554
Conversation
…rialized view An undeclared _sourceRID field on a schemaless source record (or a property declared after the view was created) is copied into the row by SELECT *, and the link the refresh adds overwrites it, on the full and on the delta pass. Regression test pins that, the javadoc states the rule and its mechanism. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
This pull request is merged. |
|
Review: this is a test and javadoc change only. I did not run the tests locally.
LGTM. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
🟢 Coverage ∅ diff coverage · -4.39% coverage variation
Metric Results Coverage variation ✅ -4.39% coverage variation Diff coverage ✅ ∅ diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (95a703e) 282919 249171 88.07% Head commit (3d07d07) 316518 (+33599) 264869 (+15698) 83.68% (-4.39%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#11554) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
… on it Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Review: LGTM. This PR only adds comments and javadoc to main code, plus a regression test that covers the full pass, the delta pass and a property declared after the view was created. The test also reads the stored rows back, which pins the actual behavior. I found no correctness, performance or security concerns, and no new dependencies. Minor notes:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11554 +/- ##
==========================================
- Coverage 80.02% 80.01% -0.02%
==========================================
Files 2461 2461
Lines 282919 282919
Branches 62204 62204
==========================================
- Hits 226400 226368 -32
- Misses 33790 33813 +23
- Partials 22729 22738 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #11552
Summary
The issue offered two options; this PR takes the first:
_sourceRIDis a reserved column of a per-record materialized view, and the link always wins. Measured onmainbefore any change: the link already wins, on both the full pass and the delta pass. Two mechanisms produce that result, and no test pinned either of them:Projection.toStringrenders every*item before the other items, and the derived query (MaterializedViewPerRecordRefresher.buildDerivedQuery) is rendered and parsed again. So@rid AS _sourceRIDalways comes after*.Projection.calculateSinglewrites the items in order. The link therefore overwrites the field that*copied from the record.This PR adds a regression test for that behavior and documents the rule and its mechanism in the javadoc of
buildDerivedQueryandMaterializedViewQueryClassifier.declaresSourceRid. The second javadoc used to describe the case as something "no static reading of the schema can see", with no statement of what happens at runtime. The_sourceRIDvalue stored on the source record is not copied into the view. Choosing "fail the pass" instead would have left the whole view inERRORbecause of one record, until someone removed the field.Test plan
Issue11552PerRecordSourceRidReservedTest(new, 6 cases): every view row is linked to its own source, carries that source'sname, and the view staysVALIDSELECT * FROM P,SELECT FROM PandSELECT *, name AS n FROM P, over a schemaless record whose_sourceRIDis a string and one whose_sourceRIDis the RID of ANOTHER source record (if that field won, two rows would claim the same source). An explicitREFRESHfollows, and each row keeps its RID.CREATE PROPERTY P._sourceRID STRINGafter the view exists (the classifier reads the schema at DDL time only)Projection.calculateSinglewas temporarily changed to evaluate the items in reverse (the field wins), 5 of the 6 cases failed and the sixth errored. The change was then reverted.MaterializedView*Test,Issue11470HandedOffRefreshYieldsTest,Issue11464IncrementalRefreshBoundedOnCommitterTest(154 tests including the new class)Coverage
Invariant: every row of a per-record view carries in
_sourceRIDthe RID of the source record it was computed from. A field of that name on the source record cannot change this.fullPass, view creation,REFRESH MATERIALIZED VIEW, ALTER upgrade, recovery pass): all usederivedQuery(false)deltaPass, RID-list variantderivedQuery(true)) on insert and on updatedeclaresSourceRid(unchanged,MaterializedViewPerRecordClassifierTest)_sourceRIDby name or aliasisPerRecord(unchanged)Known gaps: none in the engine. Documentation: the per-record section in docs PR ArcadeData/arcadedb-docs#530 does not state the reserved-name rule yet. The suggested wording is left as a comment on that PR.
Notes
_sourceRIDproperty still keeps the view on full refresh. An undeclared field gets the link instead. The classifier is deliberately conservative here, and this PR does not change it.SELECT name, * FROM Xis a syntax error in the ANTLR grammar (*must come first).MaterializedViewPerRecordClassifierTest.wholeRecordProjectionOfATypeDeclaringTheReservedNameIsRejectedlists it among the rejected queries. That case therefore passes because of the parse error, not because of the guard.Adversarial pass
No Task/Agent tool was available in this run, so the Phase 1.5 independent subagent could not be spawned. I did the self-check below instead.
_SOURCERID): property names are case-sensitive, so there is no collision in the row. Not a defect.Review cycles
20521a8925. The claude review said LGTM, with one suggestion: add a comment at theProjectionordering that points at the test. Applied in3d07d074df(comments atProjection.toStringandProjection.calculateSingle).3d07d074df. The claude review said LGTM, with no actionable items.Deferred items
Projectionpoints at a test by name. That is acceptable, but it will go stale if the test is renamed." I kept it: the reviewer in cycle 1 asked for exactly that pointer.Final state: clean-approval
🤖 Generated with Claude Code
Summary by CodeRabbit
_sourceRIDto link each view row to its source record. If a source record contains a field with that name, the source link takes precedence._sourceRIDfield.