You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metamodel.apache.org by "Kasper Sørensen (JIRA)" <ji...@apache.org> on 2017/12/10 06:39:08 UTC

[jira] [Commented] (METAMODEL-1172) Allow searching list of type map in where clause

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

Kasper Sørensen commented on METAMODEL-1172:
--------------------------------------------

I took a brief look at this tonight, but found that it wasn't as easy as I thought/hoped. OTOH it's not super intricate either - just a bit of work to it ... The MapValueFunction currently uses CollectionUtils.find(..) to apply an expression to the value. This find(..) method supports Maps as well as Maps of lists and so on. It would be feasible to make it also support lists. There's an interesting comment in the code though (line 151-152):

{code}
                        // not traversing any further. Should we want to add
                        // support for double-sided arrays, we could do it here.
{code}

We should probably make this utility method work on any depth of structure, map or list or whatever, and then just apply it in MapValue.

Very isolated problem. I'm marking it with the "starter" label because it does not require deep knowledge of MetaModel - just some Java skills and comprehension of these specific 2 classes.

> Allow searching list of type map in where clause
> ------------------------------------------------
>
>                 Key: METAMODEL-1172
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-1172
>             Project: Apache MetaModel
>          Issue Type: New Feature
>    Affects Versions: 5.0.0
>         Environment: Linux
>            Reporter: AnandRai
>             Fix For: 5.0.1
>
>
>  I have schema like “_id”,"address","borough","cuisine","grades"
>                 Where grades is list of maps with elements like
>                                 [Document{{date=Fri May 14 05:30:00 IST 2021, grade=A, score=12.0}}, Document{{date=Wed Aug 13 05:30:00 IST 2025, grade=A, score=12.0}}, Document{{date=Sun Apr 04 05:30:00 IST 2027, grade=A, score=12.0}}] 
> Now if I execute query like DataSet ds = mongo.executeQuery("select * from restaurants where grades[0].grade='A'"); 
>        
> Its failing at line 427 of MongoDbContext class final Column column = item.getSelectItem().getColumn();



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)