You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Abhishek Girish (JIRA)" <ji...@apache.org> on 2015/04/30 09:20:06 UTC

[jira] [Commented] (DRILL-2919) Drill not resolving repeated values in json

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

Abhishek Girish commented on DRILL-2919:
----------------------------------------

The JSON file contains one record `company` which is an array containing two elements. 
{code:sql}
> select t.company from hdfs.`autom.json` t;
+------------+
|  company   |
+------------+
| [{"modelName":{"name":"abc"}},{"modelName":{"name":"xyz"}}] |
+------------+
1 row selected (0.126 seconds)
{code}

And that is the reason you see just one record with your query. To fetch both records, can you try this:
{code:sql}
select p.q.`modelName` from (select flatten(t.company) q from hdfs.`autom.json` t) p;
+------------+
|   EXPR$0   |
+------------+
| {"name":"abc"} |
| {"name":"xyz"} |
+------------+
{code}

For more details you can refer https://cwiki.apache.org/confluence/display/DRILL/FLATTEN+Function 

> Drill not resolving repeated values in json
> -------------------------------------------
>
>                 Key: DRILL-2919
>                 URL: https://issues.apache.org/jira/browse/DRILL-2919
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Execution - Flow
>    Affects Versions: 0.8.0
>            Reporter: mohit kaushik
>            Assignee: Chris Westin
>              Labels: features
>
> I have a json file in HDFS named autom.json contains. 
> {
>   "company": [
>     {
>       "modelName": {
>         "name": "abc"
>       }
>     },
>     {
>       "modelName": {
>         "name": "xyz"
>       }
>     }
>   ]
> }
> When i query 
> select t.company.`modelName`  from hdfs.`autom.json` t ;
> it gives result 
> {"name":"abc"} 
> However, The expected result was both entries. 
> {"name":"abc"} 
> {"name":"xyz"} 
> Even when I query 
> select t.company.`modelName`  from hdfs.`autom.json` t where t.company.`modelName`.`name`='xyz' ;
> it does not find anything.



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