Repository navigation
feat(zero-swift): aggregates, groupBy and JSON paths in the AST; JSON path filters - #68
Merged
Merged
Conversation
tmm
force-pushed
the
swift-aggregates-ast
branch
from
November 2, 2026 17:09
81040bd to
75edf80
Compare
… path filters The AST gets the query features of sync protocols 54-57: aggregate on a query and on a relationship, groupBy, and JSON path references in conditions, with JS's wire checks, normalization, hashes and name mapping, and Format.aggregate. where() can compare a value inside a json column, in the untyped builder (eb.json) and the typed one ($0.json(\.metadata, ...)), type-strict as in JS. Building a pipeline for an aggregate or a groupBy throws until the IVM operators land. New vectors from JS: ast-features (strictASTSchema's verdict, normalizeAST, hashOfAST and mapAST), query-internals-hash (Format.aggregate), and ivm-features (JSON path filters over datasets with varied metadata, including the builder's errors). Amp-Thread-ID: https://ampcode.com/threads/T-01a19a37-5aa9-7256-bff5-cdc47c01a1fe Co-authored-by: tmm <tmm@tmm.dev>
tmm
force-pushed
the
swift-aggregates-ast
branch
from
November 2, 2026 20:32
75edf80 to
c733aa4
Compare
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.
First of the stacked PRs that port upstream's aggregates,
groupBy,distinctand JSON paths to the Swift client (plan).aggregateon a query and on a relationship,groupBy, andAST.ValuePosition.json. Decoding applies JS's wire checks (non-empty paths, integer indices from 0 to 2^31-1,pathonly with a field and not oncount,distinctonly on a fieldlesscount, JSON-pathINlists of one type). Strict decoding, normalization, the query hash (absent fields write nothing, so existing hashes are unchanged) and name mapping (a junction aggregate's field maps on the destination; a JSON path needs ajsoncolumn) are all covered, plusFormat.aggregate.$0.json(\.metadata, "tags", 0) == "bug"in the typed builder andeb.cmp(eb.json("metadata", "tags", 0), "bug")in the untyped one, with JS's type-strict predicate. Builder misuse JS throws for makes the query invalid, with JS's message.groupBythrows until the next PR adds the operators.I folded the plan's second PR (JSON path filters) into this one, because the new
.jsonvalue position needs its predicate anyway.The vectors are generated from JS:
ast-features.json:strictASTSchema's verdict on 70 ASTs, plusnormalizeAST,hashOfASTandmapAST(or its error) for the valid ones.query-internals-hash.json: hashes of formats that carryaggregate.ivm-features.json: 34 JSON-filter programs over datasets with varieduser.metadata, including the builder's errors.To check the vectors catch mistakes, I made the predicate return
falseinstead ofnegatedfor a type mismatch; 12 cases then failed.Breaking:
AST.ValuePositiongains a case, so this has a minor changeset.