[
https://issues.apache.org/jira/browse/METRON-1254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16221199#comment-16221199
]
ASF GitHub Bot commented on METRON-1254:
----------------------------------------
Github user ottobackwards commented on a diff in the pull request:
https://github.com/apache/metron/pull/801#discussion_r147259905
--- Diff:
metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/BasicStellarTest.java
---
@@ -218,6 +218,25 @@ public void testVariablesUsed() {
}
}
+ @Test
+ public void testConditionalsAsMapKeys() {
+ {
+ String query = "{ ( RET_TRUE() && y < 50 ) : 'info', y >= 50 :
'warn'}";
+ Map<Boolean, String> ret = (Map)run(query, ImmutableMap.of("y", 50));
+ Assert.assertEquals(ret.size(), 2);
+ Assert.assertEquals("warn", ret.get(true));
+ Assert.assertEquals("info", ret.get(false));
+ }
+ }
+
+
+ @Test
+ public void testConditionalsAsFunctionArgs() {
+ {
+ String query = "RET_TRUE(y < 10)";
+ Assert.assertTrue((boolean)run(query, ImmutableMap.of("y", 50)));
+ }
+ }
--- End diff --
I was thinking of something else, but on second thought I don't think it is
valid.
> Conditionals as map keys do not function in Stellar
> ---------------------------------------------------
>
> Key: METRON-1254
> URL: https://issues.apache.org/jira/browse/METRON-1254
> Project: Metron
> Issue Type: Bug
> Reporter: Casey Stella
>
> We currently cannot represent map literals in stellar where the keys are
> conditionals. For instance, the expression { x < 10 : 'info' } cannot be
> parsed currently and it should do. Having this enables a switch-style
> statement: MAP_GET(true, { x < 10 : 'info', x >= 10 : 'warn' })
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)