In the case of the original query, I think Drill should fail the query, rather than return an unexpected result.
On Thu, Apr 30, 2015 at 12:21 AM, Abhishek Girish <[email protected] > wrote: > The JSON file contains one record `company` which is an array containing > two elements. > > > select t.company from hdfs.`autom.json` t; > +------------+ > | company | > +------------+ > | [{"modelName":{"name":"abc"}},{"modelName":{"name":"xyz"}}] | > +------------+ > 1 row selected (0.126 seconds) > > And that is the reason you see just one record with your query. To fetch > both records, can you try this: > > select p.q.`modelName` from (select flatten(t.company) q from > hdfs.`autom.json` t) p; > +------------+ > | EXPR$0 | > +------------+ > | {"name":"abc"} | > | {"name":"xyz"} | > +------------+ > > For more details you can refer > https://cwiki.apache.org/confluence/display/DRILL/FLATTEN+Function > > On Thu, Apr 30, 2015 at 12:14 PM, Mohit Kaushik <[email protected]> > wrote: > > > 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. > > > > > > > -- Steven Phillips Software Engineer mapr.com
