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

Chun Chang commented on DRILL-2340:
-----------------------------------

Dataset can be downloaded from 
https://s3.amazonaws.com/apache-drill/files/complex.json.gz

plan for the failed query:

{code}
0: jdbc:drill:schema=dfs.drillTestDirComplexJ> explain plan for select count(*) 
from (select t.soa[0] soa0, t.soa[1] soa1, t.soa[2] soa2 from `complex.json` t) 
tt;
+------------+------------+
|    text    |    json    |
+------------+------------+
| 00-00    Screen
00-01      StreamAgg(group=[{}], EXPR$0=[$SUM0($0)])
00-02        StreamAgg(group=[{}], EXPR$0=[COUNT()])
00-03          Project($f0=[0])
00-04            Scan(groupscan=[EasyGroupScan 
[selectionRoot=/drill/testdata/complex_type/json/complex.json, numFiles=1, 
columns=[`*`], files=[maprfs:/drill/testdata/complex_type/json/complex.json]]])
{code}

plan for the working query:

{code}
0: jdbc:drill:schema=dfs.drillTestDirComplexJ> explain plan for select count(*) 
from (select t.soa[0] soa0, t.soa[1] soa1, t.soa[2] soa2 from `complex.json` t 
limit 200000) tt;
+------------+------------+
|    text    |    json    |
+------------+------------+
| 00-00    Screen
00-01      StreamAgg(group=[{}], EXPR$0=[$SUM0($0)])
00-02        StreamAgg(group=[{}], EXPR$0=[COUNT()])
00-03          Project($f0=[0])
00-04            SelectionVectorRemover
00-05              Limit(fetch=[200000])
00-06                Project(soa0=[ITEM($0, 0)], soa1=[ITEM($0, 1)], 
soa2=[ITEM($0, 2)])
00-07                  Scan(groupscan=[EasyGroupScan 
[selectionRoot=/drill/testdata/complex_type/json/complex.json, numFiles=1, 
columns=[`soa`[0], `soa`[1], `soa`[2]], 
files=[maprfs:/drill/testdata/complex_type/json/complex.json]]])
{code}

> count(*) fails with subquery containing limit
> ---------------------------------------------
>
>                 Key: DRILL-2340
>                 URL: https://issues.apache.org/jira/browse/DRILL-2340
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Execution - Data Types
>    Affects Versions: 0.8.0
>            Reporter: Chun Chang
>            Assignee: Daniel Barclay (Drill)
>
> #Wed Feb 25 17:07:31 EST 2015
> git.commit.id.abbrev=f7ef5ec
> count(*) with subquery containing limit works fine:
> {code}
> 0: jdbc:drill:schema=dfs.drillTestDirComplexJ> select count(*) from (select 
> t.soa[0] soa0, t.soa[1] soa1, t.soa[2] soa2 from `complex.json` t limit 
> 200000) tt;
> +------------+
> |   EXPR$0   |
> +------------+
> | 200000     |
> +------------+
> {code}
> But if I remove the limit, query fails with IllegalStateException:
> {code}
> 0: jdbc:drill:schema=dfs.drillTestDirComplexJ> select count(*) from (select 
> t.soa[0] soa0, t.soa[1] soa1, t.soa[2] soa2 from `complex.json` t) tt;
> +------------+
> |   EXPR$0   |
> +------------+
> Query failed: RemoteRpcException: Failure while running fragment., You tried 
> to do a batch data read operation when you were in a state of STOP.  You can 
> only do this type of operation when you are in a state of OK or 
> OK_NEW_SCHEMA. [ d3226020-a2b0-4497-948f-34ea2309ddb7 on 
> qa-node120.qa.lab:31010 ]
> [ d3226020-a2b0-4497-948f-34ea2309ddb7 on qa-node120.qa.lab:31010 ]
> java.lang.RuntimeException: java.sql.SQLException: Failure while executing 
> query.
>       at sqlline.SqlLine$IncrementalRows.hasNext(SqlLine.java:2514)
>       at sqlline.SqlLine$TableOutputFormat.print(SqlLine.java:2148)
>       at sqlline.SqlLine.print(SqlLine.java:1809)
>       at sqlline.SqlLine$Commands.execute(SqlLine.java:3766)
>       at sqlline.SqlLine$Commands.sql(SqlLine.java:3663)
>       at sqlline.SqlLine.dispatch(SqlLine.java:889)
>       at sqlline.SqlLine.begin(SqlLine.java:763)
>       at sqlline.SqlLine.start(SqlLine.java:498)
>       at sqlline.SqlLine.main(SqlLine.java:460)
> {code}
> Here is the exception in drill bit.log:
> {code}
> 2015-02-27 14:17:32,247 [2b0f1303-61ec-2350-4b62-b6b29d11c534:foreman] INFO  
> o.a.drill.exec.work.foreman.Foreman - State change requested.  PENDING --> 
> RUNNING
> 2015-02-27 14:17:32,267 [2b0f1303-61ec-2350-4b62-b6b29d11c534:frag:0:0] ERROR 
> o.a.drill.exec.ops.FragmentContext - Fragment Context received failure.
> java.lang.IllegalStateException: Needed to be in state INIT or IN_FLOAT8 but 
> in mode IN_BIGINT
>       at 
> org.apache.drill.exec.vector.complex.impl.SingleListWriter.float8(SingleListWriter.java:427)
>  ~[drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.vector.complex.fn.JsonReader.writeData(JsonReader.java:418)
>  ~[drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.vector.complex.fn.JsonReader.writeData(JsonReader.java:256)
>  ~[drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.vector.complex.fn.JsonReader.writeDataSwitch(JsonReader.java:208)
>  ~[drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.vector.complex.fn.JsonReader.writeToVector(JsonReader.java:182)
>  ~[drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.vector.complex.fn.JsonReader.write(JsonReader.java:156) 
> ~[drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.store.easy.json.JSONRecordReader.next(JSONRecordReader.java:125)
>  ~[drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.ScanBatch.next(ScanBatch.java:165) 
> ~[drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.validate.IteratorValidatorBatchIterator.next(IteratorValidatorBatchIterator.java:118)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:99)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:89)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractSingleRecordBatch.innerNext(AbstractSingleRecordBatch.java:51)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:134)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:142)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.validate.IteratorValidatorBatchIterator.next(IteratorValidatorBatchIterator.java:118)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:99)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:89)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.aggregate.StreamingAggBatch.buildSchema(StreamingAggBatch.java:83)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:130)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.validate.IteratorValidatorBatchIterator.next(IteratorValidatorBatchIterator.java:118)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:99)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:89)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.aggregate.StreamingAggBatch.buildSchema(StreamingAggBatch.java:83)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:130)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.validate.IteratorValidatorBatchIterator.next(IteratorValidatorBatchIterator.java:118)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:67) 
> [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.ScreenCreator$ScreenRoot.innerNext(ScreenCreator.java:97)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:57) 
> [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:115)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> org.apache.drill.exec.work.WorkManager$RunnableWrapper.run(WorkManager.java:303)
>  [drill-java-exec-0.8.0-SNAPSHOT-rebuffed.jar:0.8.0-SNAPSHOT]
>       at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>  [na:1.7.0_45]
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>  [na:1.7.0_45]
>       at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
> {code}



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

Reply via email to