Skip to content

draft: augment yaml definitions with test schema #1659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: v2.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generator/config/accumulator/lastN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: |
arguments:
- name: input
type:
- resolvesToArray
- expression
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was conflicting with the docs, which say that it can be any expression. It was particularly problematic in the $group example since the actual input field doesn't need to be an array, it only becomes one in the context of a $group, which is hard to statically enforce. I've relaxed the requirement in the interest of reducing the false negatives, at the cost of potentially accepting more false positives.

description: |
An expression that resolves to the array from which to return n elements.
- name: n
Expand Down
6 changes: 2 additions & 4 deletions generator/config/expression/avg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ tests:
pipeline:
- $project:
quizAvg:
$avg:
- $quizzes
$avg: $quizzes
labAvg:
$avg:
- $labs
$avg: $labs
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem to have been errors, right? At least in the docs, those are field expressions rather than arrays.

examAvg:
$avg:
- $final
Expand Down
3 changes: 3 additions & 0 deletions generator/config/expression/dateAdd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ tests:
purchaseDate:
types:
- bsonType: Date
deliveryDate:
types:
- bsonType: Date
- name: Adjust for Daylight Savings Time
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#adjust-for-daylight-savings-time
pipeline:
Expand Down
2 changes: 1 addition & 1 deletion generator/config/expression/let.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: |
arguments:
- name: vars
type:
- object
- expressionMap
description: |
Assignment block for the variables accessible in the in expression. To assign a variable, specify a string for the variable name and assign a valid expression for the value.
The variable assignments have no meaning outside the in expression, not even within the vars block itself.
Expand Down
8 changes: 8 additions & 0 deletions generator/config/expression/reduce.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ arguments:
- name: in
type:
- expression
- expressionMap
syntheticVariables:
- name: this
description: |
The variable that represents the cumulative value of the expression.
- name: value
description: |
The variable that refers to the element being processed.
description: |
A valid expression that $reduce applies to each element in the input array in left-to-right order. Wrap the input value with $reverseArray to yield the equivalent of applying the combining expression from right-to-left.
During evaluation of the in expression, two variables will be available:
Expand Down
21 changes: 21 additions & 0 deletions generator/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@
"pipeline",
"window",
"expression",
"expressionMap",
"geometry",
"fieldPath",
"unprefixedFieldPath",
"timeUnit",
"sortSpec",
"any",
Expand Down Expand Up @@ -228,6 +230,25 @@
"$comment": "Skip the name in object encoding and merge the properties of the value into the operator",
"type": "boolean",
"default": false
},
"syntheticVariables": {
"$comment": "A list of variables that are automatically made available during evaluation",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"pattern": "^[$]?[a-zA-Z0-9]*$"
},
"description": {
"type": "string"
}
},
"required": [
"name"
]
}
}
},
"required": [
Expand Down
1 change: 1 addition & 0 deletions generator/config/stage/group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ arguments:
- name: _id
type:
- expression
- expressionMap
description: |
The _id expression specifies the group key. If you specify an _id value of null, or any other constant value, the $group stage returns a single document that aggregates values across all of the input documents.
- name: field
Expand Down
2 changes: 1 addition & 1 deletion generator/config/stage/unset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: |
arguments:
- name: field
type:
- fieldPath
- unprefixedFieldPath
variadic: array
tests:
- name: Remove a Single Field
Expand Down
Loading