yagagagaga opened a new pull request, #19403:
URL: https://github.com/apache/doris/pull/19403

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Recursive `cte with` is not supported yet.
   
   What's Recursive `cte with` ? See the example below
   
   ```sql
   create table t1(
     id int,
     name varchar(64),
     parent_id int
   );
   
   insert into t1 values
   (1, '中国', 0),
   (2, '北京市', 1),
   (3, '广东省', 1),
   (4, '深圳市', 3),
   (5, '南山区', 4),
   (6, '福田区', 4);
   
   with RECURSIVE cte as (
       select id,name,parent_id
       from t1 where id=1
       union all
       select h.id, COALESCE(CONCAT(c.name, '/', h.name), h.name) as name, 
h.parent_id from t1 h inner join cte c on h.parent_id=c.id -- where c.id!=h.ID
   ) select * from cte;
   
   -- here is the output
   +------+--------------------------------------+-----------+
   | id   | name                                 | parent_id |
   +------+--------------------------------------+-----------+
   |    1 | 中国                                 |         0 |
   |    2 | 中国/北京市                          |         1 |
   |    3 | 中国/广东省                          |         1 |
   |    4 | 中国/广东省/深圳市                   |         3 |
   |    5 | 中国/广东省/深圳市/南山区            |         4 |
   |    6 | 中国/广东省/深圳市/福田区            |         4 |
   +------+--------------------------------------+-----------+
   
   ```
   
   ## Checklist(Required)
   
   * [ ] Does it affect the original behavior
   * [ ] Has unit tests been added
   * [x] Has document been added or modified
   * [ ] Does it need to update dependencies
   * [x] Is this PR support rollback (If NO, please explain WHY)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at 
[[email protected]](mailto:[email protected]) by explaining why you 
chose the solution you did and what alternatives you considered, etc...
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to