Conversation
Contributor
Author
|
using https://github.com/Khady/modern-ocaml/tree/main/.github as template |
Contributor
|
i don't have opinion on this and i cannot read yaml so merge when you see fit |
The _shards type was added to search results in PR #15 but the test expected outputs were not regenerated. Update all test output.atd files to match the current code generation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements GitHub issue #5. The multi_terms aggregation groups documents by multiple fields simultaneously (like SQL GROUP BY a, b), returning composite keys as JSON arrays. Changes: - common.ml: Add Tuple variant to result_type for composite keys - aggregations.ml: Add Multi_terms variant, parsing, and type inference - atdgen.ml: Map Tuple to ATD tuple type (serialized as JSON array) - test/multi_terms_agg: Test with keyword and numeric fields, variable size The composite key is represented as an ATD tuple, which naturally maps to JSON arrays matching the ES multi_terms response format. Closes #5 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Include shard failure details (reason type+text, shard, index, node, status) as optional fields in the generated _shards ATD type for Search queries, matching the ES ShardStatistics spec: - failures: optional (may be absent even when failed > 0) - reason: required on each failure (ErrorCause) - reason.type: required string (becomes type_ in OCaml) - reason.reason: optional string (human-readable message) - shard, index, node, status: all optional Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All search query output.atd files updated to include the new reason, failure types and expanded _shards type. Get/Mget tests unaffected. Note: other_bucket gains failure (shard) and failure1 (aggregation bucket) types — automatic deduplication when a query already had a field named 'failure' in its aggregations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Support $(var:field:<type>) syntax alongside existing $(var:list). No behavioral changes yet — field_type is parsed but unused. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Field_var carries a Tjson.var and a simple_type parsed from the
field type annotation. typeof_value returns Simple typ directly,
bypassing the mapping lookup.
Also adds parse_field_type helper to convert user-facing type
strings ("string", "int", "float", "int64") to simple_type.
Note: the value type definition was moved after pp_simple_type
because [@@deriving show] on Field_var needs the printer in scope.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Parse $(var:field:<type>) in aggregation field position - Register field variables as string input parameters - Skip numeric/date field validation for dynamic fields Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests $(group_by:field:string) syntax: verifies string input parameter and string bucket key output type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add field variable section under Variables with usage example and supported type annotations.
Use descriptive names like _typ, _name, _metric, _keys etc. instead of bare _ in pattern matches added by this PR.
Type annotations now use ES type names (keyword, long, double) instead of custom names (string, int, float). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The :field: segment was redundant — the type annotation is useful regardless of context, and the usage site already determines semantics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The annotated type is known at codegen time, so we can warn when a non-numeric type is used in a numeric context — same as Field. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Eliminates redundant second match on aggregation type. Each arm now handles its own field_var_constraints inline, matching the existing pattern for on_int_var and Field_num/Field_date constraints. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
String is the type of the variable value (field name passed at runtime), not the aggregation result type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
External users don't know what simple_of_es_type is. List supported types directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The field is no longer field-specific after the syntax simplification. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The parser branches already prevent this, but the explicit check makes the invariant visible. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests $(bucket_field:long) in a histogram aggregation, exercising the Field_num constraint validation path and float bucket key output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add variable field support in aggregations
rr0gi
reviewed
Mar 27, 2026
Comment on lines
+20
to
+24
| let ends_with s suffix = | ||
| let s_len = Stdlib.String.length s in | ||
| let suffix_len = Stdlib.String.length suffix in | ||
| s_len >= suffix_len | ||
| && Stdlib.String.sub s (s_len - suffix_len) suffix_len = suffix |
Contributor
There was a problem hiding this comment.
but i have an opinion on copy-pasting stdlib functions inline multiple times and you don't want to hear it
fe4d76e to
131cba2
Compare
Contributor
Author
|
sorry I had an agent running in a loop to fix the CI and wasn't looking at all at its output, I should have switched to draft PR before to run it. Still haven't done a human review of the changes |
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.
Probably needs to be updated. For an unknown reason I created the branch but not a corresponding PR at the time.