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

Jinfeng Ni commented on DRILL-5165:
-----------------------------------

[~khfaraaz], can you please upload the sample file you used so that we can see 
if this is an incorrect problem or not.

According to Postgres doc [1], "LIMIT ALL is the same as omitting the LIMIT 
clause. "OFFSET says to skip that many rows before beginning to return rows.".  
Therefore, if I have "LIMIT ALL OFFSET N", I would expect to get the rows from 
N+1 to the end of table. 

Here are queries I tried on Drill 1.9.0-SNAPSHOT.

{code}
select * from cp.`tpch/nation.parquet` limit all offset 5;
+--------------+-----------------+--------------+---------------------------------------------------------------------------------------------------------------------+
| n_nationkey  |     n_name      | n_regionkey  |                               
                       n_comment                                                
      |
+--------------+-----------------+--------------+---------------------------------------------------------------------------------------------------------------------+
| 5            | ETHIOPIA        | 0            | ven packages wake quickly. 
regu                                                                            
         |
| 6            | FRANCE          | 3            | refully final requests. 
regular, ironi                                                                  
            |
| 7            | GERMANY         | 3            | l platelets. regular accounts 
x-ray: unusual, regular acco                                                    
      |
| 8            | INDIA           | 2            | ss excuses cajole slyly 
across the packages. deposits print aroun                                       
            |
| 9            | INDONESIA       | 2            |  slyly express asymptotes. 
regular deposits haggle slyly. carefully ironic hockey players sleep blithely. 
carefull  |
| 10           | IRAN            | 4            | efully alongside of the slyly 
final dependencies.                                                             
      |
| 11           | IRAQ            | 4            | nic deposits boost atop the 
quickly final requests? quickly regula                                          
        |
| 12           | JAPAN           | 2            | ously. final, express gifts 
cajole a                                                                        
        |
| 13           | JORDAN          | 4            | ic deposits are blithely 
about the carefully regular pa                                                  
           |
| 14           | KENYA           | 0            |  pending excuses haggle 
furiously deposits. pending, express pinto beans wake fluffily past t           
            |
| 15           | MOROCCO         | 0            | rns. blithely bold courts 
among the closely regular packages use furiously bold platelets?                
          |
| 16           | MOZAMBIQUE      | 0            | s. ironic, unusual asymptotes 
wake blithely r                                                                 
      |
| 17           | PERU            | 1            | platelets. blithely pending 
dependencies use fluffily across the even pinto beans. carefully silent accoun  
        |
| 18           | CHINA           | 2            | c dependencies. furiously 
express notornis sleep slyly regular accounts. ideas sleep. depos               
          |
| 19           | ROMANIA         | 3            | ular asymptotes are about the 
furious multipliers. express dependencies nag above the ironically ironic 
account     |
| 20           | SAUDI ARABIA    | 4            | ts. silent requests haggle. 
closely express packages sleep across the blithely                              
        |
| 21           | VIETNAM         | 2            | hely enticingly express 
accounts. even, final                                                           
            |
| 22           | RUSSIA          | 3            |  requests against the 
platelets use never according to the quickly regular pint                       
              |
| 23           | UNITED KINGDOM  | 3            | eans boost carefully special 
requests. accounts are. carefull                                                
       |
| 24           | UNITED STATES   | 1            | y final packages. slow foxes 
cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto 
be      |
+--------------+-----------------+--------------+---------------------------------------------------------------------------------------------------------------------+
20 rows selected (0.277 seconds)
{code}

{code}
select * from cp.`tpch/nation.parquet` offset 5;
+--------------+-----------------+--------------+---------------------------------------------------------------------------------------------------------------------+
| n_nationkey  |     n_name      | n_regionkey  |                               
                       n_comment                                                
      |
+--------------+-----------------+--------------+---------------------------------------------------------------------------------------------------------------------+
| 5            | ETHIOPIA        | 0            | ven packages wake quickly. 
regu                                                                            
         |
| 6            | FRANCE          | 3            | refully final requests. 
regular, ironi                                                                  
            |
| 7            | GERMANY         | 3            | l platelets. regular accounts 
x-ray: unusual, regular acco                                                    
      |
| 8            | INDIA           | 2            | ss excuses cajole slyly 
across the packages. deposits print aroun                                       
            |
| 9            | INDONESIA       | 2            |  slyly express asymptotes. 
regular deposits haggle slyly. carefully ironic hockey players sleep blithely. 
carefull  |
| 10           | IRAN            | 4            | efully alongside of the slyly 
final dependencies.                                                             
      |
| 11           | IRAQ            | 4            | nic deposits boost atop the 
quickly final requests? quickly regula                                          
        |
| 12           | JAPAN           | 2            | ously. final, express gifts 
cajole a                                                                        
        |
| 13           | JORDAN          | 4            | ic deposits are blithely 
about the carefully regular pa                                                  
           |
| 14           | KENYA           | 0            |  pending excuses haggle 
furiously deposits. pending, express pinto beans wake fluffily past t           
            |
| 15           | MOROCCO         | 0            | rns. blithely bold courts 
among the closely regular packages use furiously bold platelets?                
          |
| 16           | MOZAMBIQUE      | 0            | s. ironic, unusual asymptotes 
wake blithely r                                                                 
      |
| 17           | PERU            | 1            | platelets. blithely pending 
dependencies use fluffily across the even pinto beans. carefully silent accoun  
        |
| 18           | CHINA           | 2            | c dependencies. furiously 
express notornis sleep slyly regular accounts. ideas sleep. depos               
          |
| 19           | ROMANIA         | 3            | ular asymptotes are about the 
furious multipliers. express dependencies nag above the ironically ironic 
account     |
| 20           | SAUDI ARABIA    | 4            | ts. silent requests haggle. 
closely express packages sleep across the blithely                              
        |
| 21           | VIETNAM         | 2            | hely enticingly express 
accounts. even, final                                                           
            |
| 22           | RUSSIA          | 3            |  requests against the 
platelets use never according to the quickly regular pint                       
              |
| 23           | UNITED KINGDOM  | 3            | eans boost carefully special 
requests. accounts are. carefull                                                
       |
| 24           | UNITED STATES   | 1            | y final packages. slow foxes 
cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto 
be      |
+--------------+-----------------+--------------+---------------------------------------------------------------------------------------------------------------------+
20 rows selected (0.258 seconds)
{code}

My understanding is that Drill seems to return correct result. I'm not sure 
what happen to your query. Since I don not have your sample file, I would not 
be able to comment on that. 

1. https://www.postgresql.org/docs/8.2/static/queries-limit.html

> wrong results - LIMIT ALL and OFFSET clause in same query
> ---------------------------------------------------------
>
>                 Key: DRILL-5165
>                 URL: https://issues.apache.org/jira/browse/DRILL-5165
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning & Optimization
>    Affects Versions: 1.10.0
>            Reporter: Khurram Faraaz
>            Assignee: Chunhui Shi
>            Priority: Critical
>
> This issue was reported by a user on Drill's user list.
> Drill 1.10.0 commit ID : bbcf4b76
> I tried a similar query on apache Drill 1.10.0 and Drill returns wrong 
> results when compared to Postgres, for a query that uses LIMIT ALL and OFFSET 
> clause in the same query. We need to file a JIRA to track this issue.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select col_int from typeall_l order by 1 limit 
> all offset 10;
> +----------+
> | col_int  |
> +----------+
> +----------+
> No rows selected (0.211 seconds)
> 0: jdbc:drill:schema=dfs.tmp> select col_int from typeall_l order by col_int 
> limit all offset 10;
> +----------+
> | col_int  |
> +----------+
> +----------+
> No rows selected (0.24 seconds)
> {noformat}
> Query => select col_int from typeall_l limit all offset 10;
> Drill 1.10.0 returns 85 rows
> whereas for same query,
> postgres=# select col_int from typeall_l limit all offset 10;
> Postgres 9.3 returns 95 rows, which is the correct expected result.
> Query plan for above query that returns wrong results
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> explain plan for select col_int from typeall_l 
> limit all offset 10;
> +------+------+
> | text | json |
> +------+------+
> | 00-00    Screen
> 00-01      Project(col_int=[$0])
> 00-02        SelectionVectorRemover
> 00-03          Limit(offset=[10])
> 00-04            Scan(groupscan=[ParquetGroupScan [entries=[ReadEntryWithPath 
> [path=maprfs:///tmp/typeall_l]], selectionRoot=maprfs:/tmp/typeall_l, 
> numFiles=1, usedMetadataFile=false, columns=[`col_int`]]])
> {noformat} 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to