Skip to content

[Bug]: mo report 'invalid input: missing FROM-clause entry for table 'c'' while mysql can execute successfully. #20000

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

e7771f6

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

image

Expected Behavior

as mysql's behavior

Steps to Reproduce

create table orders (
order_id int primary key ,
customer_id int,
order_date date,
status enum('Pending', 'Shipped', 'Delivered', 'Cancelled')
);

insert into orders (order_id, customer_id, order_date, status) values
(1, 1, '2024-01-01', 'Delivered'),
(2, 2, '2024-01-02', 'Shipped'),
(3, 3, '2024-01-03', 'Delivered'),
(4, 1, '2024-01-04', 'Delivered');
select * from orders;

create table order_items (
item_id int primary key,
order_id int,
product_id int,
quantity int,
price decimal(10, 2)
);

insert into order_items (item_id, order_id, product_id, quantity, price) values
(1, 1, 101, 2, 19.99),
(2, 1, 102, 1, 29.99),
(3, 2, 103, 3, 9.99),
(4, 3, 104, 1, 49.99),
(5, 4, 101, 1, 19.99);
select * from order_items;

create table customers (
customer_id int primary key,
first_name varchar(50),
last_name varchar(50),
city char(50)
);

insert into customers (customer_id, first_name, last_name, city) values
(1, 'John', 'Doe', 'New York'),
(2, 'Jane', 'Smith', 'Los Angeles'),
(3, 'Alice', 'Johnson', 'Chicago');
select * from customers;

create table products (
product_id int primary key,
product_name varchar(100),
category_id int
);

insert into products (product_id, product_name, category_id) values
(101, 'Product A', 1),
(102, 'Product B', 1),
(103, 'Product C', 2),
(104, 'Product D', 2);
select * from products;

create table categories (
category_id int primary key,
category_name varchar(100)
);

insert into categories (category_id, category_name) values
(1, 'Electronics'),
(2, 'Books');
select * from categories;

select
    year(o.order_date) as order_year,
    month(o.order_date) as order_month,
    c.city,
    cat.category_name,
    sum(oi.quantity * oi.price) as total_sales
from
    orders o
    join
    order_items oi on o.order_id = oi.order_id
    join
    customers c on o.customer_id = c.customer_id
    join
    products p on oi.product_id = p.product_id
    join
    categories cat on p.category_id = cat.category_id
where
    o.status = 'Delivered'
group by
    year(o.order_date),
    month(o.order_date),
    cat.category_name,
    c.city,
    c.customer_id,
    cat.category_id with rollup
order by
    order_year,
    order_month,
    c.city,
    cat.category_name;

Additional information

No response

Activity

  1. added
    kind/bug
    severity/s0
    on Nov 12, 2024
  2. added this to the 2.1.0 milestone on Nov 12, 2024
  3. added
    severity/s1
    and removed
    severity/s0
    on Nov 12, 2024
  4. assigned and unassigned on Apr 27, 2025
  5. added theissue type on Apr 27, 2025
  6. modified the milestones: 2.1.0, 2506 on Apr 27, 2025
  7. modified the milestones: MO-2506, MO-2508 on Jul 17, 2025
  8. modified the milestones: MO-2508, MO-202602 on Feb 3, 2026
  9. iamlinjunhong commented on Aug 4, 2026

    @iamlinjunhong
    Contributor

    #26357 已经修复

  10. Ariznawlll commented on Aug 6, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:09e02eea38bfa87e4c4333ffb57b370091136bc8
    • 部署方式:本地单机 LogService + TN + CN,独立数据目录。
    • 测试日期:2026-08-06
    • MySQL oracle:本地 MySQL 8,同一组 customers/orders/order_items/products/categories 数据。

    原问题验证

    使用原问题所覆盖的五表 JOIN、c.city/cat.category_name 限定别名、ENUM('Delivered',...) 状态列,以及 GROUP BY ... WITH ROLLUP。

    普通聚合返回两行:2026/1/Shanghai/Books/20.00、2026/2/Beijing/Games/100.00。ROLLUP 返回 12 行(含 grand total 120.00);MO 与 MySQL 输出逐行一致,没有再出现 missing FROM-clause entry for table c。

    Happy Path 覆盖

    1. ENUM 状态谓词过滤。
    2. 五表内连接与限定列别名。
    3. 普通 GROUP BY。
    4. 带隐藏分组列的 WITH ROLLUP 与确定性 ORDER BY。

    Unhappy Path 覆盖

    本 issue 的修复面是别名绑定/聚合执行,不存在合法的业务拒绝路径;已通过 Pending 订单验证谓词排除不会污染 Delivered 聚合结果。

    白盒验证

    不适用:该问题由公开 SQL 的 bind/plan/execute 全路径覆盖。

    回归测试

    • motr PR:matrixorigin/motr#81
    • 文件:suites/14_issue_regression/t/issue_20000_rollup_join_alias.test
    • 结果:record 后连续 3 轮成功;每轮 16 条语句/断言成功。

    测试结论

    测试通过。

  11. removed
    severity/s1
    on Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions