metamodel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (METAMODEL-195) Scalar function to get key from a MAP type field
Date Fri, 20 Nov 2015 08:19:10 GMT

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

ASF GitHub Bot commented on METAMODEL-195:
------------------------------------------

Github user albertostratio commented on a diff in the pull request:

    https://github.com/apache/metamodel/pull/70#discussion_r45444580
  
    --- Diff: core/src/main/java/org/apache/metamodel/query/FromClause.java ---
    @@ -75,7 +75,13 @@ public FromItem getItemByReference(String reference) {
             return null;
         }
     
    -    private FromItem getItemByReference(FromItem item, String reference) {
    +    private FromItem getItemByReference(final FromItem item, final String reference)
{
    +        if (reference.equals(item.toStringNoAlias(false))) {
    +            return item;
    +        }
    +        if (reference.equals(item.toStringNoAlias(true))) {
    +            return item;
    +        }
             final String alias = item.getAlias();
    --- End diff --
    
    Wouldn't it be better to write just one if instead of two? I'd rewrite it to:
    
    if (reference.equals(item.toStringNoAlias(false)) || reference.equals(item.toStringNoAlias(true)))
{
                return item;
    }


> Scalar function to get key from a MAP type field
> ------------------------------------------------
>
>                 Key: METAMODEL-195
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-195
>             Project: Apache MetaModel
>          Issue Type: Improvement
>            Reporter: Kasper Sørensen
>
> Now that we have support for scalar functions, and we also support a host of key/value
or document oriented datastores, I think it would be really natural to support a function
for getting a value inside a map.
> Example:
> {code}
> SELECT MAP_VALUE(address, 'street') FROM contacts
> {code}
> Ideally the function would allow for a full "path" of keys so that you could have maps-within-maps
and so on.
> {code}
> SELECT MAP_VALUE(address, 'homeaddress.street') FROM contacts
> {code}
> Even more ideally we would also add a bit of query parser logic to allow expressing the
path as part of the operand itself:
> {code}
> SELECT address.homeaddress.street FROM contacts
> {code}



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

Mime
View raw message