Skip to content

[doc] Add exponential_moving_average aggregate function documentation#3726

Merged
HappenLee merged 1 commit into
apache:masterfrom
HappenLee:func
May 22, 2026
Merged

[doc] Add exponential_moving_average aggregate function documentation#3726
HappenLee merged 1 commit into
apache:masterfrom
HappenLee:func

Conversation

@HappenLee
Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Problem Summary:
Doris added the exponential_moving_average aggregate function but no documentation existed.

  • English doc with syntax, parameters, return value, and examples (basic, GROUP BY, NULL handling, empty set, window function, constant requirement).
  • Chinese (zh-CN) translation.
  • Sidebar entry in both aggregate-functions and analytic-functions lists.

Release note

None

Check List (For Author)

  • Test: No need to test (docs only)
  • Behavior changed: No
  • Does this need documentation: No (this IS the documentation)

Versions

  • dev
  • 4.x
  • 3.x
  • 2.1 or older (not covered by version/language sync gate)

Languages

  • Chinese
  • English
  • Japanese candidate translation needed

Docs Checklist

  • Checked by AI
  • Test Cases Built
  • Updated required version and language counterparts, or explained why not
  • If only one language changed, confirmed whether source/translation counterparts need sync

@HappenLee
Copy link
Copy Markdown
Contributor Author

run buildall

### What problem does this PR solve?

Problem Summary:
Doris added the exponential_moving_average aggregate function but no
documentation existed.

- English doc with syntax, parameters, return value, and examples
  (basic, GROUP BY, NULL handling, empty set, window function,
   constant requirement).
- Chinese (zh-CN) translation.
- Sidebar entry in both aggregate-functions and analytic-functions
  lists.

### Release note

None

### Check List (For Author)

- Test: No need to test (docs only)
- Behavior changed: No
- Does this need documentation: No (this IS the documentation)
@HappenLee
Copy link
Copy Markdown
Contributor Author

run buildall

@HappenLee
Copy link
Copy Markdown
Contributor Author

/review

HappenLee added a commit to apache/doris that referenced this pull request May 22, 2026
…63499)

    Problem Summary:
    Doris lacked an exponential moving average aggregate function. This
implements `exponential_moving_average(half_decay, value, time)` ported
    from ClickHouse's ExponentialMovingAverage aggregate.

    Algorithm:
    - State stores (value, time, half_decay) as doubles.
    - On add(): scale existing value to the new timestamp via
`2^(-dt/half_decay)`, then accumulate. Store half_decay in state so
      it is available during merge().
    - On merge(): advance both states to the later timestamp, then sum.
      This is commutative and associative, so row order doesn't matter.
    - Result: `value * (1 - 2^(-1/half_decay))` (normalised by sum of
      weights).

    Changes:
- BE: `aggregate_function_ema.h/cpp` — state struct + function class,
      registered in `aggregate_function_simple_factory.cpp`.
- FE: `ExponentialMovingAverage.java` — 3-arg DOUBLE signature, visitor
      method added to `AggregateFunctionVisitor`, registered in
      `BuiltinAggregateFunctions`.
    - Regression test: `query_p0/aggregate/exponential_moving_average/`.

    ### Release note

New aggregate function `exponential_moving_average(half_decay, value,
time)`
computes the exponential moving average over a stream of (value, time)
    pairs with the given half-decay parameter.

    ### Check List (For Author)

- Test: Regression test added
(query_p0/aggregate/exponential_moving_average)
    - Behavior changed: No (new function)
- Does this need documentation:
[docs](apache/doris-website#3726)

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@HappenLee HappenLee merged commit a0b10a0 into apache:master May 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant