[ 
https://issues.apache.org/jira/browse/DRILL-5051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15676527#comment-15676527
 ] 

Khurram Faraaz commented on DRILL-5051:
---------------------------------------

The problem is only when the OFFSET is specified in the subquery. When there is 
no OFFSET specified in the sub-query, query returns correct results.

{noformat}
0: jdbc:drill:schema=dfs.tmp> select count(col_int) from (select col_int from 
(select col_int from typeall_l limit 2) limit 1 offset 1);
+---------+
| EXPR$0  |
+---------+
| 0       |
+---------+
1 row selected (0.231 seconds)

0: jdbc:drill:schema=dfs.tmp> explain plan for select count(col_int) from 
(select col_int from (select col_int from typeall_l limit 2) limit 1 offset 1);
+------+------+
| text | json |
+------+------+
| 00-00    Screen
00-01      Project(EXPR$0=[$0])
00-02        StreamAgg(group=[{}], EXPR$0=[COUNT($0)])
00-03          Limit(offset=[1], fetch=[1])
00-04            Limit(fetch=[2])
00-05              Scan(groupscan=[ParquetGroupScan [entries=[ReadEntryWithPath 
[path=maprfs:///tmp/typeall_l]], selectionRoot=maprfs:/tmp/typeall_l, 
numFiles=1, usedMetadataFile=false, columns=[`col_int`]]])
{noformat}

Without OFFSET in sub-query

{noformat}
0: jdbc:drill:schema=dfs.tmp> select count(1) from (select col_int from (select 
col_int from typeall_l limit 2) limit 1);
+---------+
| EXPR$0  |
+---------+
| 1       |
+---------+
1 row selected (0.242 seconds)
{noformat}

> Returning incorrect number of rows while querying using both nested select 
> and offset
> -------------------------------------------------------------------------------------
>
>                 Key: DRILL-5051
>                 URL: https://issues.apache.org/jira/browse/DRILL-5051
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning & Optimization
>    Affects Versions: 1.8.0
>         Environment: Fedora 24 / OpenJDK 8
>            Reporter: Hongze Zhang
>             Fix For: Future
>
>
> My SQl:
> select count(1) from (select id from (select id from 
> cp.`tpch/lineitem.parquet` LIMIT 2) limit 1 offset 1) 
> This SQL returns nothing.
> Something goes wrong in LimitRecordBatch.java, and the reason is different 
> with [DRILL-4884|https://issues.apache.org/jira/browse/DRILL-4884?filter=-2]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to