You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: LATERAL and derived-table outer references are not supported like MySQL #25376
MySQL 8.0 supports LATERAL derived tables, and MySQL 8.0.14+ also allows derived tables inside subqueries to contain outer references in supported contexts. MatrixOne currently rejects these MySQL-compatible Model 10 join/subquery shapes.
dropdatabase if exists mysql_compat_model10_min;
createdatabasemysql_compat_model10_min;
use mysql_compat_model10_min;
createtablet1 (id intprimary key, grp int);
createtablet2 (id intprimary key, t1_id int, val int);
insert into t1 values (1,10),(2,10),(3,20);
insert into t2 values (101,1,5),(102,1,7),(103,2,9);
selectt1.id, x.max_valfrom t1
left join lateral (
selectmax(val) as max_val from t2 wheret2.t1_id=t1.id
) x on true
order byt1.id;
selectt1.idfrom t1
wheret1.grp< (
selectavg(dt.val)
from (
selectt2.valfrom t2 wheret2.t1_id=t1.id
) dt
)
order byt1.id;
MySQL 8.0.45 Result
The LATERAL query succeeds:
id max_val
1 7
2 9
3 NULL
The nested derived outer-reference query is also accepted. With the sample data above it returns an empty result set.
MatrixOne Result
LATERAL query:
ERROR 1064 (HY000): SQL parser error ... near "select max(val) as max_val ..."
Nested derived outer reference:
ERROR 20102 (HY000): correlated subquery in FROM clause is not yet implemented
Expected
MatrixOne should support these MySQL 8.0-compatible derived-table / correlated-subquery shapes, or explicitly document them as unsupported incompatibilities.
Consolidated acceptance scope from #23099: partitioned-table LATERAL and top-N test cases. Please retain the original reproduction and discussion in the linked issue. This consolidation does not claim the bug is fixed.
Activity
daviszhen commentedon Jul 3, 2026
支持完整的lateral 工作量大.
短期支持, 只能做到半拉子.
先做其他的内容
Ariznawlll commentedon Sep 7, 2026
在最新
main(74668fc075c965c462b30f10ae24a1c19c289cfd,本地单 CN,2026-09-07)复核,LATERAL仍未进入解析/规划路径。MySQL 8.0.45 可执行以下两类典型用法:JOIN LATERAL中按当前外层行计算MAX(),结果按四个 outer row 分别为5, 5, 10, NULL;LEFT JOIN LATERAL中使用相关ORDER BY ... LIMIT 1获取每组首行,同时保留无匹配 outer row。MO 对两条语句均在
LATERAL (后的子查询位置返回 1064 parser error。作为语义对照,将同样的相关聚合或 Top-1 写成 SELECT-list scalar subquery 时,MO 能返回与 MySQL 一致的结果,因此本次现象仍限定在 LATERAL/相关 FROM 能力本身。上述两种形状各重复 3 次,行为一致;无数据修改。
XuPeng-SH commentedon Oct 29, 2026
Consolidated acceptance scope from #23099: partitioned-table LATERAL and top-N test cases. Please retain the original reproduction and discussion in the linked issue. This consolidation does not claim the bug is fixed.