You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2019/11/21 12:55:20 UTC

[GitHub] [incubator-doris] EmmyMiao87 opened a new issue #2270: Where stmt中支持结果为非 Salar 类型的子查询

EmmyMiao87 opened a new issue #2270: Where stmt中支持结果为非 Salar 类型的子查询
URL: https://github.com/apache/incubator-doris/issues/2270
 
 
   # 背景
   目前 Doris 仅支持在 Where 语句中结果为 Salar 类型的子查询,比如:
   
   ```
   select * from table1 where k1=(select sum(k1) from table2);
   select * from table1 where k1=(select k1 from table2 limit 1);
   
   ```
   但仍然存在一些结果类型不为 Salar 的子查询,也应该可以被执行,比如:
   `select * from table 1 where k1=(select k1 from table2)`
   这种查询只有在真正执行的时候,才能知道是否正确。比如当 table2 只有一行的时候,查询就可以被执行。
   TPC-DS 中的 query:6,54,58 都属于这类查询语句。
   
   # 设计
   1. 语义解析:将 Where stmt 中仅支持结果为 Salar 类型子查询,改为支持结果为一列的子查询。
   2. stmt rewrite:改写这种结果为非 Salar 类型的子查询时,为子查询增加一个窗口函数 row_number() , 并且增加一个 assert,用于判断子查询的结果是否为1条。比如:
   ```
   origin stmt: select * from table1 where k1=(select k1 from table2);
   new stmt: select * from table1 left semi join (assert row_number() = 1 (select k1, row_number() over() from table2) $a) on table1.k1=$a.k1;
   ```
   3. assert node: 实现一个非阻塞节点 assert node,主要包含一个列表 assert conditions。当所有行都满足 assert conditions 的时候查询才能继续。如果有一行不满足,则查询失败,返回错误信息。
   其中 assert conditions 之间的关系是 and。
   
   疑问:
   如果把assert node设计为非阻塞节点,可能会发生已经有结果返回给用户,但是查询中途失败了的情况。而返回给用户的数据是错的。
   但如果设计为阻塞节点,会影响处理效率。

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org