Repository navigation
Description
Why this is needed
Online anomaly baselines and adaptive volatility need gradual forgetting rather than a hard cutoff. Irregular event-time decay and missing samples require explicit half-life/ignoreNA behavior; a fixed ROWS average is not equivalent.
Requested behavior and scope
Provide exponentially weighted mean/variance/std/covariance/correlation with declared alpha/com/span/half-life, adjust, ignoreNA and initialization policies. The verified simple profile is alpha=0.5, adjust=False, no missing samples, first-sample initialization: values 1,2,3,4 produce means 1,1.5,2.25,3.125. A finite historical self-join can emulate that profile, but does not establish a native incremental-state API or performance parity.
Tested revision / existing issue check
- MatrixOne commit:
23d8f61252f3017dff218b530817a240206fd762. - Existing issues were searched before filing; related requests/closed fixes are distinguished above.
- All data below is synthetic. The probe is read-only and requires no persisted tables.
Executable unsupported case
SELECT ewmMean(CAST(1 AS DOUBLE),3) result;Actual MO result, reproduced 3/3:
(20105, "not supported: function or operator 'ewmmean'")
This probe checks entry-name availability only. A rejection does not establish that the business calculation is impossible or that this is a valid DolphinDB script signature. The requested mathematical operation is defined above and checked by the independent profile below.
Additional actually executed cases
Each listed rejection was executed three times on the same synthetic fixture.
| Case | MO result | Declared expected values / scope |
|---|---|---|
ewmMean_entry |
rejected 3/3 | Entry resolution only; no invented engine result |
ewmVar_entry |
rejected 3/3 | Entry resolution only; no invented engine result |
ewmStd_entry |
rejected 3/3 | Entry resolution only; no invented engine result |
ewmCov_entry |
rejected 3/3 | Entry resolution only; no invented engine result |
ewmCorr_entry |
rejected 3/3 | Entry resolution only; no invented engine result |
Working SQL control / alternative
The following control was executed 3/3 and its complete output values were checked, not merely execution success:
WITH raw AS (SELECT *
FROM (
SELECT 1 id,CAST(1 AS DOUBLE) v
UNION ALL SELECT 2,2
UNION ALL SELECT 3,3
UNION ALL SELECT 4,4) fixture) SELECT a.id,SUM(b.v*CASE WHEN b.id=1 THEN POWER(CAST(0.5 AS DOUBLE),a.id-1) ELSE CAST(0.5 AS DOUBLE)*POWER(CAST(0.5 AS DOUBLE),a.id-b.id) END) result FROM raw a JOIN raw b ON b.id<=a.id GROUP BY a.id ORDER BY a.id;| Control | Verified values |
|---|---|
alpha_half_adjust_false_control |
1, 1.5, 2.25, 3.125 |
Acceptance / regression coverage
Retain the self-contained fixture and assert complete values, NULL bits and row alignment. Add partitions, ties, empty/all-NULL frames, frame-entry/exit and type boundaries appropriate to this operator. Validate named/API availability separately from mathematical rewrites. Benchmark any claimed state/performance advantage with identical data and correctness rules; no speedup is asserted by these small tests.
Subsequent SELECT 1 succeeded after the test matrix. DolphinDB references are official documentation; no DolphinDB runtime or all-parameter parity is claimed.
Activity
XuPeng-SH commentedon Oct 12, 2026
Triage decision: defer.
Reason: this is a specialized window/time-series capability. The report establishes a syntax or API gap, but does not show a confirmed customer blocker or near-term roadmap commitment. The umbrella report also notes that many profiles can be composed from existing SQL and does not provide a native-performance comparison.
Promote when a concrete customer workload or roadmap commitment is identified and correctness/performance acceptance criteria are agreed.
gouhongshen commentedon Oct 31, 2026
PR #31941 is trying to fix this issue.
feat(sql): add ewmMean/ewmVar/ewmStd/ewmCov/ewmCorr window functions
feat(sql): add ewmMean/ewmVar/ewmStd/ewmCov/ewmCorr window functions
feat(sql): add ewmMean/ewmVar/ewmStd/ewmCov/ewmCorr window functions (#…
gouhongshen commentedon Oct 31, 2026
PR #31941 has merged and is awaiting manual validation. The issue remains open.
XuPeng-SH commentedon Oct 31, 2026
QA 交接(待验证,不代表验收通过)
关联 PR:#31941,已合入 main;merge SHA:
c699e15c016495276f8fee224fc14316740de059。已核对本 issue 全部评论及 PR/设计范围:五个 EWM window 函数、alpha / event-time half-life、adjust、ignoreNA、minPeriods 与初始化已有实现。com/span/行 half-life 通过设计中明确的 alpha 常量换算表达;不是命名参数 API。旧版本入口缺失及旧 head 的 CASE/IFNULL 常量拒绝不能直接作为合入版本反例;后者已修复并获后续评审确认,目前未发现仍适用的已验证反例或未完开发 follow-up。
真实验证证据(远端作者/评审报告,不是本轮本地实测):作者报告配置/binder 回归及完整 EWM SQL fixture 377/377;后续评审报告真实 MySQL 377 条、prepared CASE 重复执行与 event-time ordering controls 通过,且旧 CASE/IFNULL finding 已闭环。历史数值/lifecycle/race 证据保留其原有适用范围。
请 @Ariznawlll 在合入 main 上独立回归:
边界:仅 window OVER;population variance;显式有限移动 frame、多键或降序 event-time 不在 v1 支持范围,应校验清晰拒绝;不要把这些边界写成全参数兼容或性能验收。本轮未运行本地测试、未重跑全量 CI/多 CN、混合版本或生产规模性能,相关覆盖仍交 QA。无需因本次转测自动要求 4.2 backport。
Ariznawlll commentedon Oct 31, 2026
测试补充
结论
测试不通过。已完成本次功能范围的黑盒和白盒验证;发现的预编译嵌套参数问题已单独提交为 #31952,后续修复及回归在该 bug 中跟踪。按约定,本功能 issue 在记录测试结果后关闭。
关键证据
main@ae40f12a647880a63466de32a9f507c2c72dca0b,源码构建见 构建记录。SQL 黑盒在隔离的 Linux/amd64 Docker 模拟环境执行,分别覆盖 1 CN / 1 TN 和同进程 2 CN / 1 TN;两个实例均无 OOM 或重启,测试库已清理。ewmMean、ewmVar、ewmStd、ewmCov、ewmCorr均校验结果和 NULL:完整 SQL 用例连续 3 轮,每轮 377/377;独立分数计算对照 alpha=0.5 的 180 组全通过。alpha=0.25 和 0.75 的各 180 组在与合入提交源码树一致的构建上通过。基础序列1,2,3,4、alpha=0.5、adjust=false 的均值为1,1.5,2.25,3.125。adjust/ignoreNA、minPeriods、不规则 event-time half-life、极值和亚正规数。独立双 CN 场景中,两个入口各 3 轮逐行核对 12,000 行和五个结果列,行序、值及结果哈希一致。OVER、非法 alpha / half-life /minPeriods、非常量策略、不支持的有限移动窗口以及 event-time 降序和多排序键;检查错误后会话继续可用。文本和二进制预编译覆盖参数变化、非法值后恢复,以及已发现的 CASE / IFNULL 嵌套参数缺陷。KILL QUERY后,同一连接和同一预编译语句重新执行 10/10 正确;二进制语句RESET与复用 10/10 正确。两连接不同参数交替执行 20 次正确。待解决点
IFNULL时均 3/3 在预编译阶段报20203;CASE形式同样复现,显式CAST对照通过。修复和回归由该 bug 继续跟踪。OVER、总体方差;com/span/ 行 half-life 通过 alpha 常量换算,不是命名参数 API。