You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Neeraja (JIRA)" <ji...@apache.org> on 2014/10/28 00:37:36 UTC

[jira] [Created] (DRILL-1589) count(*) on json fails with exception

Neeraja created DRILL-1589:
------------------------------

             Summary: count(*) on json fails with exception
                 Key: DRILL-1589
                 URL: https://issues.apache.org/jira/browse/DRILL-1589
             Project: Apache Drill
          Issue Type: Bug
            Reporter: Neeraja
            Priority: Critical


A simple count(*) query on JSON fails while count(column) works fine.

Below are the queries.

 0: jdbc:drill:zk=local> select count(*) from  dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json` b
. . . . . . . . . . . > ;
Query failed: Screen received stop request sent. You tried to start when you are using a ValueWriter of type NullableVarCharWriterImpl. [23966ff6-7ea9-4c6d-a3c6-0a024cedc972]

Error: exception while executing query: Failure while trying to get next result batch. (state=,code=0)


------------
0: jdbc:drill:zk=local> select count(business_id) from dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json` b;
+------------+
|   EXPR$0   |
+------------+
| 42153      |
+------------+

Explain plans are below.

0: jdbc:drill:zk=local> explain plan for select count(*) from  dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json` b;
+------------+------------+
|    text    |    json    |
+------------+------------+
| 00-00    Screen
00-01      StreamAgg(group=[{}], EXPR$0=[COUNT()])
00-02        Project($f0=[0])
00-03          Scan(groupscan=[EasyGroupScan [selectionRoot=/users/nrentachintal |
+------------+------------+
1 row selected (0.139 seconds)
0: jdbc:drill:zk=local> explain plan for select count(business_Id) from  dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json` b;
+------------+------------+
|    text    |    json    |
+------------+------------+
| 00-00    Screen
00-01      StreamAgg(group=[{}], EXPR$0=[COUNT($0)])
00-02        Scan(groupscan=[EasyGroupScan [selectionRoot=/users/nrentachintala/Downloads/yelp_dataset_chall |
+------------+------------+




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

Re: [jira] [Created] (DRILL-1589) count(*) on json fails with exception

Posted by Hanifi Gunes <hg...@maprtech.com>.
Earlier, we had a chat with Aman about this in the context of
https://issues.apache.org/jira/browse/DRILL-1417.

It is true that the current behavior of count(*) for text queries is to
scan the entire file. The problem with pushing a specific column is that
given that count(column_name) accounts non-null columns, there is no
guarantee that the file will always have a non-null column, which in turn
changes the result. My understanding is that this is more like a memory
optimization: even if we push down a specific column, we may end up
scanning the entire file yet allocate less number of vectors. Still we
should consider optimizing this further.

Thanks.
-Hanifi

On Mon, Oct 27, 2014 at 5:51 PM, Jinfeng Ni <ji...@gmail.com> wrote:

> The issues seems to not caused by count(*), but by the JSON scanning of all
> the columns.
>
> I hit the same error, if I remove count(), and use * directly.
>
> select * from
> dfs.`/Users/jni/work/data/yelp/yelp_academic_dataset_business.json`;
>
> "
> RpcException: Query stopeed., You tried to start when you are using a
> ValueWriter of type NullableBitWriterImpl.
> "
>
> This query actually returns many rows back, then it hit the above error.
> Either the input file has some format that Drill's code could not handle,
> or did not handle properly due to some bug.  In any case, Drill should
> report the position in the input file where the issue is encountered, so
> that user would have better idea where it goes wrong.
>
> I think the reason that you did not run into this problem with
> count(business_id)
> is probably because the that filed is well formatted.
>
> As a side note, the plan for count(*) seems not optimal :
>
>
> text json
> 00-00    Screen
> 00-01      StreamAgg(group=[{}], EXPR$0=[COUNT()])
> 00-02        Project($f0=[0])
> 00-03          Scan(groupscan=[EasyGroupScan
>
> [selectionRoot=/Users/jni/work/data/yelp/yelp_academic_dataset_business.json,
> numFiles=1, columns =* [SchemaPath [`*`]]*]])
> {
>     "pop" : "fs-scan",
>     "@id" : 3,
>     "files" : [
> "file:/Users/jni/work/data/yelp/yelp_academic_dataset_business.json" ],
> ,
>     "format" : {
>       "type" : "json"
>     },
> *    "columns" : [ "`*`" ],*
>     "selectionRoot" :
> "/Users/jni/work/data/yelp/yelp_academic_dataset_business.json",
>     "cost" : 36382.0
>   },
>
>
> For count(*) query, if no specific column/field is required by the query,
> we should not scan all the column by setting "SchemaPath = *".  In stead,
> Drill should scan ONLY one column (least expensive, ideally). The project
> will map the input column into a constant, and then the aggregate count(*)
> would apply to the constant expression, to get the total # of rows.  To
> scan all the columns will mean sub-optimal performance.
>
> Please consider opening a separate  JIRA for the plan issue.
>
>
>
> On Mon, Oct 27, 2014 at 4:37 PM, Neeraja (JIRA) <ji...@apache.org> wrote:
>
> > Neeraja created DRILL-1589:
> > ------------------------------
> >
> >              Summary: count(*) on json fails with exception
> >                  Key: DRILL-1589
> >                  URL: https://issues.apache.org/jira/browse/DRILL-1589
> >              Project: Apache Drill
> >           Issue Type: Bug
> >             Reporter: Neeraja
> >             Priority: Critical
> >
> >
> > A simple count(*) query on JSON fails while count(column) works fine.
> >
> > Below are the queries.
> >
> >  0: jdbc:drill:zk=local> select count(*) from
> >
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> > b
> > . . . . . . . . . . . > ;
> > Query failed: Screen received stop request sent. You tried to start when
> > you are using a ValueWriter of type NullableVarCharWriterImpl.
> > [23966ff6-7ea9-4c6d-a3c6-0a024cedc972]
> >
> > Error: exception while executing query: Failure while trying to get next
> > result batch. (state=,code=0)
> >
> >
> > ------------
> > 0: jdbc:drill:zk=local> select count(business_id) from
> >
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> > b;
> > +------------+
> > |   EXPR$0   |
> > +------------+
> > | 42153      |
> > +------------+
> >
> > Explain plans are below.
> >
> > 0: jdbc:drill:zk=local> explain plan for select count(*) from
> >
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> > b;
> > +------------+------------+
> > |    text    |    json    |
> > +------------+------------+
> > | 00-00    Screen
> > 00-01      StreamAgg(group=[{}], EXPR$0=[COUNT()])
> > 00-02        Project($f0=[0])
> > 00-03          Scan(groupscan=[EasyGroupScan
> > [selectionRoot=/users/nrentachintal |
> > +------------+------------+
> > 1 row selected (0.139 seconds)
> > 0: jdbc:drill:zk=local> explain plan for select count(business_Id) from
> >
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> > b;
> > +------------+------------+
> > |    text    |    json    |
> > +------------+------------+
> > | 00-00    Screen
> > 00-01      StreamAgg(group=[{}], EXPR$0=[COUNT($0)])
> > 00-02        Scan(groupscan=[EasyGroupScan
> > [selectionRoot=/users/nrentachintala/Downloads/yelp_dataset_chall |
> > +------------+------------+
> >
> >
> >
> >
> > --
> > This message was sent by Atlassian JIRA
> > (v6.3.4#6332)
> >
>

Re: [jira] [Created] (DRILL-1589) count(*) on json fails with exception

Posted by Neeraja Rentachintala <nr...@maprtech.com>.
Thanks Jinfeng.
I can open separate bug for the plan issue.

I also tried another query as below which seem to be hitting the same
exception.
I tried setting the "alter system set `store.json.all_text_mode`=true;" and
still hitting this.
Let me know if this is the same issue or need to open separate bug.

0: jdbc:drill:zk=local> select * from
dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
b where review_count > 1000;

+-------------+--------------+------------+------------+------------+------------+--------------+------------+------------+------------+------------+------------+------------+-----+

| business_id | full_address |   hours    |    open    | categories |
city    | review_count |    name    | longitude  |   state    |   stars
|  latitude  | attributes |     |

+-------------+--------------+------------+------------+------------+------------+--------------+------------+------------+------------+------------+------------+------------+-----+

| hW0Ne_HTHEAgGF1rAdmR-g | 3400 E Sky Harbor Blvd

Phoenix, AZ 85034 |
{"Tuesday":{"close":"00:00","open":"00:00"},"Friday":{"close":"00:00","open":"00:00"},"Monday":{"close":"00:0
|

| FV16IeXJp2W6pnghTz2FAw | 4029 Spring Mountain Rd

Chinatown

Las Vegas, NV 89102 |
{"Tuesday":{"close":"06:00","open":"06:00"},"Friday":{"close":"06:00","open":"06:00"},"Monday":{
|

| 4UVhuOLaMm2-34SrW8y-ag | 4355 Spring Mountain Rd

Chinatown

Las Vegas, NV 89102 |
{"Tuesday":{"close":"02:30","open":"17:00"},"Friday":{"close":"02:30","open":"17:00"},"Monday":{
|

| JokKtdXU7zXHcr20Lrk29A | 1340 E 8th St

Ste 104

Tempe, AZ 85281 |
{"Tuesday":{"close":"01:00","open":"11:00"},"Friday":{"close":"01:00","open":"11:00"},"Monday":{"close":"01:00",
|

Query failed: Screen received stop request sent. You tried to start when
you are using a ValueWriter of type NullableVarCharWriterImpl.
[e4ac9829-9013-4b6d-bfb7-397e159448eb]


java.lang.RuntimeException: java.sql.SQLException: Failure while trying to
get next result batch.

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)

On Mon, Oct 27, 2014 at 5:51 PM, Jinfeng Ni <ji...@gmail.com> wrote:

> The issues seems to not caused by count(*), but by the JSON scanning of all
> the columns.
>
> I hit the same error, if I remove count(), and use * directly.
>
> select * from
> dfs.`/Users/jni/work/data/yelp/yelp_academic_dataset_business.json`;
>
> "
> RpcException: Query stopeed., You tried to start when you are using a
> ValueWriter of type NullableBitWriterImpl.
> "
>
> This query actually returns many rows back, then it hit the above error.
> Either the input file has some format that Drill's code could not handle,
> or did not handle properly due to some bug.  In any case, Drill should
> report the position in the input file where the issue is encountered, so
> that user would have better idea where it goes wrong.
>
> I think the reason that you did not run into this problem with
> count(business_id)
> is probably because the that filed is well formatted.
>
> As a side note, the plan for count(*) seems not optimal :
>
>
> text json
> 00-00    Screen
> 00-01      StreamAgg(group=[{}], EXPR$0=[COUNT()])
> 00-02        Project($f0=[0])
> 00-03          Scan(groupscan=[EasyGroupScan
>
> [selectionRoot=/Users/jni/work/data/yelp/yelp_academic_dataset_business.json,
> numFiles=1, columns =* [SchemaPath [`*`]]*]])
> {
>     "pop" : "fs-scan",
>     "@id" : 3,
>     "files" : [
> "file:/Users/jni/work/data/yelp/yelp_academic_dataset_business.json" ],
> ,
>     "format" : {
>       "type" : "json"
>     },
> *    "columns" : [ "`*`" ],*
>     "selectionRoot" :
> "/Users/jni/work/data/yelp/yelp_academic_dataset_business.json",
>     "cost" : 36382.0
>   },
>
>
> For count(*) query, if no specific column/field is required by the query,
> we should not scan all the column by setting "SchemaPath = *".  In stead,
> Drill should scan ONLY one column (least expensive, ideally). The project
> will map the input column into a constant, and then the aggregate count(*)
> would apply to the constant expression, to get the total # of rows.  To
> scan all the columns will mean sub-optimal performance.
>
> Please consider opening a separate  JIRA for the plan issue.
>
>
>
> On Mon, Oct 27, 2014 at 4:37 PM, Neeraja (JIRA) <ji...@apache.org> wrote:
>
> > Neeraja created DRILL-1589:
> > ------------------------------
> >
> >              Summary: count(*) on json fails with exception
> >                  Key: DRILL-1589
> >                  URL: https://issues.apache.org/jira/browse/DRILL-1589
> >              Project: Apache Drill
> >           Issue Type: Bug
> >             Reporter: Neeraja
> >             Priority: Critical
> >
> >
> > A simple count(*) query on JSON fails while count(column) works fine.
> >
> > Below are the queries.
> >
> >  0: jdbc:drill:zk=local> select count(*) from
> >
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> > b
> > . . . . . . . . . . . > ;
> > Query failed: Screen received stop request sent. You tried to start when
> > you are using a ValueWriter of type NullableVarCharWriterImpl.
> > [23966ff6-7ea9-4c6d-a3c6-0a024cedc972]
> >
> > Error: exception while executing query: Failure while trying to get next
> > result batch. (state=,code=0)
> >
> >
> > ------------
> > 0: jdbc:drill:zk=local> select count(business_id) from
> >
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> > b;
> > +------------+
> > |   EXPR$0   |
> > +------------+
> > | 42153      |
> > +------------+
> >
> > Explain plans are below.
> >
> > 0: jdbc:drill:zk=local> explain plan for select count(*) from
> >
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> > b;
> > +------------+------------+
> > |    text    |    json    |
> > +------------+------------+
> > | 00-00    Screen
> > 00-01      StreamAgg(group=[{}], EXPR$0=[COUNT()])
> > 00-02        Project($f0=[0])
> > 00-03          Scan(groupscan=[EasyGroupScan
> > [selectionRoot=/users/nrentachintal |
> > +------------+------------+
> > 1 row selected (0.139 seconds)
> > 0: jdbc:drill:zk=local> explain plan for select count(business_Id) from
> >
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> > b;
> > +------------+------------+
> > |    text    |    json    |
> > +------------+------------+
> > | 00-00    Screen
> > 00-01      StreamAgg(group=[{}], EXPR$0=[COUNT($0)])
> > 00-02        Scan(groupscan=[EasyGroupScan
> > [selectionRoot=/users/nrentachintala/Downloads/yelp_dataset_chall |
> > +------------+------------+
> >
> >
> >
> >
> > --
> > This message was sent by Atlassian JIRA
> > (v6.3.4#6332)
> >
>

Re: [jira] [Created] (DRILL-1589) count(*) on json fails with exception

Posted by Jinfeng Ni <ji...@gmail.com>.
The issues seems to not caused by count(*), but by the JSON scanning of all
the columns.

I hit the same error, if I remove count(), and use * directly.

select * from
dfs.`/Users/jni/work/data/yelp/yelp_academic_dataset_business.json`;

"
RpcException: Query stopeed., You tried to start when you are using a
ValueWriter of type NullableBitWriterImpl.
"

This query actually returns many rows back, then it hit the above error.
Either the input file has some format that Drill's code could not handle,
or did not handle properly due to some bug.  In any case, Drill should
report the position in the input file where the issue is encountered, so
that user would have better idea where it goes wrong.

I think the reason that you did not run into this problem with
count(business_id)
is probably because the that filed is well formatted.

As a side note, the plan for count(*) seems not optimal :


text json
00-00    Screen
00-01      StreamAgg(group=[{}], EXPR$0=[COUNT()])
00-02        Project($f0=[0])
00-03          Scan(groupscan=[EasyGroupScan
[selectionRoot=/Users/jni/work/data/yelp/yelp_academic_dataset_business.json,
numFiles=1, columns =* [SchemaPath [`*`]]*]])
{
    "pop" : "fs-scan",
    "@id" : 3,
    "files" : [
"file:/Users/jni/work/data/yelp/yelp_academic_dataset_business.json" ],
,
    "format" : {
      "type" : "json"
    },
*    "columns" : [ "`*`" ],*
    "selectionRoot" :
"/Users/jni/work/data/yelp/yelp_academic_dataset_business.json",
    "cost" : 36382.0
  },


For count(*) query, if no specific column/field is required by the query,
we should not scan all the column by setting "SchemaPath = *".  In stead,
Drill should scan ONLY one column (least expensive, ideally). The project
will map the input column into a constant, and then the aggregate count(*)
would apply to the constant expression, to get the total # of rows.  To
scan all the columns will mean sub-optimal performance.

Please consider opening a separate  JIRA for the plan issue.



On Mon, Oct 27, 2014 at 4:37 PM, Neeraja (JIRA) <ji...@apache.org> wrote:

> Neeraja created DRILL-1589:
> ------------------------------
>
>              Summary: count(*) on json fails with exception
>                  Key: DRILL-1589
>                  URL: https://issues.apache.org/jira/browse/DRILL-1589
>              Project: Apache Drill
>           Issue Type: Bug
>             Reporter: Neeraja
>             Priority: Critical
>
>
> A simple count(*) query on JSON fails while count(column) works fine.
>
> Below are the queries.
>
>  0: jdbc:drill:zk=local> select count(*) from
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> b
> . . . . . . . . . . . > ;
> Query failed: Screen received stop request sent. You tried to start when
> you are using a ValueWriter of type NullableVarCharWriterImpl.
> [23966ff6-7ea9-4c6d-a3c6-0a024cedc972]
>
> Error: exception while executing query: Failure while trying to get next
> result batch. (state=,code=0)
>
>
> ------------
> 0: jdbc:drill:zk=local> select count(business_id) from
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> b;
> +------------+
> |   EXPR$0   |
> +------------+
> | 42153      |
> +------------+
>
> Explain plans are below.
>
> 0: jdbc:drill:zk=local> explain plan for select count(*) from
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> b;
> +------------+------------+
> |    text    |    json    |
> +------------+------------+
> | 00-00    Screen
> 00-01      StreamAgg(group=[{}], EXPR$0=[COUNT()])
> 00-02        Project($f0=[0])
> 00-03          Scan(groupscan=[EasyGroupScan
> [selectionRoot=/users/nrentachintal |
> +------------+------------+
> 1 row selected (0.139 seconds)
> 0: jdbc:drill:zk=local> explain plan for select count(business_Id) from
> dfs.`/users/nrentachintala/Downloads/yelp_dataset_challenge_academic_dataset/yelp_academic_dataset_business.json`
> b;
> +------------+------------+
> |    text    |    json    |
> +------------+------------+
> | 00-00    Screen
> 00-01      StreamAgg(group=[{}], EXPR$0=[COUNT($0)])
> 00-02        Scan(groupscan=[EasyGroupScan
> [selectionRoot=/users/nrentachintala/Downloads/yelp_dataset_chall |
> +------------+------------+
>
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)
>