You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2018/01/03 01:58:00 UTC

[jira] [Updated] (CALCITE-270) Generate complex conditions against MongoDB

     [ https://issues.apache.org/jira/browse/CALCITE-270?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde updated CALCITE-270:
--------------------------------
    Component/s: mongodb

> Generate complex conditions against MongoDB
> -------------------------------------------
>
>                 Key: CALCITE-270
>                 URL: https://issues.apache.org/jira/browse/CALCITE-270
>             Project: Calcite
>          Issue Type: Bug
>          Components: mongodb
>            Reporter: GitHub Import
>              Labels: github-import
>
> We need to rework the MongoDB adapter to support complex conditions. Currently we use the `$match` operator whose syntax is limiting because it expects a column name on the LHS and a value on the RHS.
> We should instead generate a 'condition' column to be preceding `$project` operator. Then we can generate expressions the conventional way, e.g. `$gt: [e1, e2]` as opposed to `e1: {$gt: e2}`.
> In the following example, `cond` holds the evaluated condition, a subsequent `$match` filters on it, then a `$project` projects away the column.
> ```json
> db.zips.aggregate(
>                 {$project: {STATE: '$state', POP: '$pop'}},
>                 {$group: {_id: '$STATE', C: {$sum: 1}, _2: {$sum: '$POP'}}},
>                 {$project: {STATE: '$_id', C: '$C', _2: '$_2', cond: {$gt: [{$cond: [{$eq: ["$C", 0]}, null, "$_2"]}, 12000000]}}},
>                 {$match: {cond: true}},
>                 {$project: {STATE: 1, C: 1}})
> ```
> ---------------- Imported from GitHub ----------------
> Url: https://github.com/julianhyde/optiq/issues/270
> Created by: [julianhyde|https://github.com/julianhyde]
> Labels: 
> Created at: Thu May 01 23:37:10 CEST 2014
> State: open



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