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

PHPLIB-1362 Add tests on Window Operators #51

Merged
merged 2 commits into from
Jan 26, 2024
Merged

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Jan 24, 2024

Fix PHPLIB-1362

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

  • $addToSet
  • $avg
  • $bottom
  • $bottomN
  • $count
  • $covariancePop
  • $covarianceSamp
  • $denseRank
  • $derivative
  • $documentNumber
  • $expMovingAvg
  • $first
  • $integral
  • $last
  • $linearFill
  • $locf
  • $max
  • $min
  • $minN
  • $push
  • $rank
  • $shift
  • $stdDevPop
  • $stdDevSamp
  • $sum
  • $top
  • $topN

I moved some operators from Expression to Accumulator.

@GromNaN GromNaN requested a review from jmikola January 24, 2024 10:19
Comment on lines +29 to +31
denseRankOrderDateForState: Accumulator::outputWindow(
Accumulator::denseRank(),
),
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 outputWindow is optional when no window property is set. I omitted it in the next test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added this note as a comment in the code.

output: object(
expMovingAvgForStock: Accumulator::expMovingAvg(
input: Expression::numberFieldPath('price'),
N: 2,
Copy link
Member

Choose a reason for hiding this comment

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

I noted that $expMovingAvg indeed uses an uppercase single-letter parameter name. I'm sure that won't be confusing for people. No need to do something about this now, but I can see ourselves adding some kind of fallback for folks that aren't used to this and use n out of habit.

Copy link
Member Author

Choose a reason for hiding this comment

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

PHP is case-insensible for method names but not for property or argument names. Static analysis and PHP error will help:

Fatal error: Uncaught Error: Unknown named parameter $n

Copy link
Member

Choose a reason for hiding this comment

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

Yep, that will indeed help :D

@GromNaN GromNaN merged commit aa7cffc into mongodb:0.1 Jan 26, 2024
@GromNaN GromNaN deleted the PHPLIB-1362 branch January 26, 2024 08:51
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