feat(nql): GROUP BY aggregates + VALID AS OF + TRACE in browser mock parser#2
Open
Eth-Interchained wants to merge 1 commit into
Open
feat(nql): GROUP BY aggregates + VALID AS OF + TRACE in browser mock parser#2Eth-Interchained wants to merge 1 commit into
Eth-Interchained wants to merge 1 commit into
Conversation
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.
Summary
src/lib/nql.tsmock NQL parser to handle three clauses the engine has supported since v1.0.0 but the browser parser rejected with"unexpected trailing input":GROUP BY+ aggregates,VALID AS OF(both positions), andTRACE [REVERSE].Planinterface grows five new fields:validAsOf,trace,traceReverse,groupBy,aggregate.executeNqlnow runs all five aggregate functions (COUNT,SUM,AVG,MIN,MAX) against seed data in-browser.TRACEexecutes a forward/reverse linked-list walk via the named field in mock mode; adds a note directing users to the live engine for full sealed causal chains.VALID AS OFadds an informational note in mock mode (full valid-time indexing needs nedbd).COMMITS.mdandideas.mdfor the next maintenance turn.Why this matters
Queries like
FROM orders GROUP BY status COUNTorFROM events TRACE caused_by REVERSEare valid NQL that the live engine handles correctly. Before this PR they threw a parse error in Studio mock/offline mode, breaking the playground experience for these three clause families. Post-PR, Group By aggregations execute fully in-browser; VALID AS OF and TRACE pass through with informational notes.Engine impact
None — pure Studio TypeScript change, no nedbd routes affected.
Studio impact
src/lib/nql.ts— parser + executor extended;Plantype widened.Planbenefits immediately: the console no longer shows red parse errors for GROUP BY / VALID AS OF / TRACE queries.Tests run
25 new mock tests pass (Node ESM, no build step required):
TypeScript types are consistent — no new
anycasts introduced;AggFuncunion type exported for downstream use.Follow-up work
/files+/files/:filename+/files/:filename/rootthrough Studio Express; add Files tab in Databases page (Merkle root display enables ITC/BSC anchoring).POST /:name/checkpointproxy + UI button in Database detail view.pyproject.tomllicense — still declaresApache-2.0but LICENSE is BSL; fix metadata to avoid package-index confusion.