Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

PHPLIB-1342 Add tests on Arithmetic Expression Operators #52

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Jan 24, 2024

Fix PHPLIB-1342

https://www.mongodb.com/docs/manual/reference/operator/aggregation/#arithmetic-expression-operators

  • $abs
  • $add
  • $ceil
  • $divide
  • $exp
  • $floor
  • $ln
  • $log
  • $log10
  • $mod
  • $multiply
  • $pow
  • $round
  • $sqrt
  • $subtract
  • $trunc

Nothing special

@GromNaN GromNaN requested a review from jmikola January 24, 2024 13:27
variance:
$pow:
-
# $stdDevPop: '$scores.score'
Copy link
Member Author

Choose a reason for hiding this comment

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

I've checked the result is the same if the value is in an array or a single value

Copy link
Member

Choose a reason for hiding this comment

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

Is this because StdDevPopOperator encodes as a single element, which utilizes its only $expression property (a list)? I suppose $expressions would be a more descriptive name for the property but I realize the class is auto-generated and derived from the name of the variadic arg itself.

In any event, I think it makes sense to capture this explanation in a YAML comment here to explain exactly why you're changing the expected pipeline.

IIRC, this kind of thing came up in previous PRs, since there are other operators that omit logic to encode using the "short" form.

Copy link
Member Author

Choose a reason for hiding this comment

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

The argument is variadic so we always get an array. That's one reason why I made an accumulator operator distrinct from the expression operator.
Comment added.

Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

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

LGTM with comment explaining why $stdDevPop example was changed.

variance:
$pow:
-
# $stdDevPop: '$scores.score'
Copy link
Member

Choose a reason for hiding this comment

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

Is this because StdDevPopOperator encodes as a single element, which utilizes its only $expression property (a list)? I suppose $expressions would be a more descriptive name for the property but I realize the class is auto-generated and derived from the name of the variadic arg itself.

In any event, I think it makes sense to capture this explanation in a YAML comment here to explain exactly why you're changing the expected pipeline.

IIRC, this kind of thing came up in previous PRs, since there are other operators that omit logic to encode using the "short" form.

@GromNaN GromNaN merged commit a99f472 into mongodb:0.1 Jan 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants