apache / apache/doris

[Bug] [Nereids] "fragment has no children" error when INSERT INTO / CTAS with RECURSIVE CTE

Open
#64,368 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
15.9k
Forks
3.9k
Avg merge
2d 23h
Merged PRs (30d)
520

Description

### Search before asking

- [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.

### Version

create table tmps.tmp_trace_link_long_magnetic_sort PROPERTIES ( "replication_num" = "2" ) as with recursive t(id, a) as ( select cast(1 as bigint), array(cast(1 as bigint))

union all

select
id + 1,
array_pushback(a, id)
from t
where id < 5
) select * from t;

### What's Wrong?

SQL 错误 [1105] [HY000]: fragment has no children

### What You Expected?

-- 1. 显式建表(明确指定字段类型)
drop table tmps.tmp_trace_link_long_magnetic_sort;
CREATE TABLE tmps.tmp_trace_link_long_magnetic_sort (
id BIGINT,
a ARRAY
)
PROPERTIES (
"replication_num" = "2"
);

-- 方法 1:直接关闭 Nereids 优化器(推荐)
SET enable_nereids_planner = false;

-- 方法 2:如果方法 1 报错,尝试开启自动回退机制
SET enable_fallback_to_original_planner = true;

-- 2. 插入数据
INSERT INTO tmps.tmp_trace_link_long_magnetic_sort
WITH RECURSIVE t(id, a) AS (
SELECT
CAST(1 AS BIGINT),
array(CAST(1 AS BIGINT))
UNION ALL
SELECT
id + 1,
array_pushback(a, id)
FROM t
WHERE id < 5
)
SELECT * FROM t;

SQL 错误 [1105] [HY000]: fragment has no children

### How to Reproduce?

_No response_

### Anything Else?

_No response_

### Are you willing to submit PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the recursive CTE examples in the issue with the Nereids planner enabled, covering both CTAS and INSERT INTO. Trace how Nereids handles these statements and recursive CTE fragments; done means both operations complete without the “fragment has no children” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.