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

Jinfeng Ni commented on DRILL-5464:
-----------------------------------

One idea might be to enable an experimental feature called Union type 
(DRILL-3233, which was disabled by default), to address the schema change 
listed above.  Tried the query with the Union type enabled, and it failed with 
same error.

{code}
alter session set `exec.enable_union_type` = true;
select count(*), stars  from dfs.`/tmp/yelp` group by stars;
Error: SYSTEM ERROR: IllegalStateException: Failure while reading vector.  
Expected vector class of org.apache.drill.exec.vector.NullableIntVector but was 
holding vector class org.apache.drill.exec.vector.NullableBigIntVector, field= 
stars(BIGINT:OPTIONAL)[$bits$(UINT1:REQUIRED), stars(BIGINT:OPTIONAL)]
{code} 

> Fix JSON reader when it deals with empty file
> ---------------------------------------------
>
>                 Key: DRILL-5464
>                 URL: https://issues.apache.org/jira/browse/DRILL-5464
>             Project: Apache Drill
>          Issue Type: Bug
>            Reporter: Jinfeng Ni
>
> An empty json file is the one without any json object.  If we query an empty 
> json file asking it to return column 'A',  Drill's JSON record reader would 
> return a batch with 0 row, and put column 'A' as a nullable int column. A 
> better name for such column might be phantom columns, as the record reader 
> does not have any knowledge of the column schema, and the nullable int column 
> is just a guessed schema. 
> However, that processing could introduce many issues. Consider if we have a 
> directory consisting of multiple json files and at least one of them is 
> empty.  If column 'A' is returned as nullable-int column from the reader over 
> the empty file, while the other json files contains a real typed column 'A', 
> that would cause query hit many issues, including 1) SchemaChangeException, 
> 2) failed in certain operator which does not detect SchemaChange, 3) or 
> incorrect query result, since the run-time code is generated over a phantom 
> column type, not a real type.
> For instance, the following query against yelp json file run successfully.
> {code}
> select count(*), stars  from 
> dfs.`/tmp/yelp/yelp_academic_dataset_review.json` group by stars;
> {code}
> If an empty json file is added to the directory,  the query would fail with 
> the following error (which falls into the 2nd category : PartitionSender did 
> not detect schema change properly).  
> {code}
> select count(*), stars  from dfs.`/tmp/yelp` group by stars;
> Error: SYSTEM ERROR: IllegalStateException: Failure while reading vector.  
> Expected vector class of org.apache.drill.exec.vector.NullableIntVector but 
> was holding vector class org.apache.drill.exec.vector.NullableBigIntVector, 
> field= stars(BIGINT:OPTIONAL)[$bits$(UINT1:REQUIRED), stars(BIGINT:OPTIONAL)]
> {code}



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

Reply via email to