-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Say you wanted to express the following SQL in MQL, it would be difficult to do today:
CASE
WHEN foo = "bar"
THEN (SELECT x, y FROM tbl1)
ELSE (SELECT x, y WHERE x > 10 FROM tbl2)
END
You could hack around it with $facet or $function, but it would be better to provide a first-class MQL operator to do this, e.g. an aggregation stage version of $switch (we already have a $switch at the expression level, but...)
{$switch: {
branches: [
{case: {$eq: ["$foo", "bar"]}, then: [], collection: "tbl1"},
]
default: {
pipeline: [{$match: {x > 0}}],
collection: "tbl2"
}
}}