You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metron.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/08/23 18:49:20 UTC

[jira] [Commented] (METRON-388) Stellar - Unable to Operate on Result of If-Then-Else

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

ASF GitHub Bot commented on METRON-388:
---------------------------------------

GitHub user cestella opened a pull request:

    https://github.com/apache/incubator-metron/pull/227

    METRON-388: Stellar - Unable to Operate on Result of If-Then-Else

    As per [METROn-388](https://issues.apache.org/jira/browse/METRON-388), we added a regression to Stellar around conditional expressions.  This is corrected in this PR and the test cases suggested are adopted.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cestella/incubator-metron METRON-388

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-metron/pull/227.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #227
    
----
commit df44df71bd8fa14338acd5dd3cb7643a67871923
Author: cstella <ce...@gmail.com>
Date:   2016-08-23T18:47:33Z

    METRON-388: Stellar - Unable to Operate on Result of If-Then-Else

----


> Stellar - Unable to Operate on Result of If-Then-Else
> -----------------------------------------------------
>
>                 Key: METRON-388
>                 URL: https://issues.apache.org/jira/browse/METRON-388
>             Project: Metron
>          Issue Type: Bug
>            Reporter: Nick Allen
>              Labels: stellar
>
> The result of an if-then-else cannot be further operated on in an expression.  See examples below that explain this much better.
> {code}
>   @Test
>   public void testIfThenElseBug1() {
>     String query = "50 + (true == true ? 10 : 20)";
>     Assert.assertEquals(60.0, run(query, new HashMap<>()));
>   }
>   @Test
>   public void testIfThenElseBug2() {
>     String query = "50 + (true == false ? 10 : 20)";
>     Assert.assertEquals(70.0, run(query, new HashMap<>()));
>   }
>   @Test
>   public void testIfThenElseBug3() {
>     String query = "50 * (true == false ? 2 : 10)";
>     Assert.assertEquals(500.0, run(query, new HashMap<>()));
>   }
>   @Test
>   public void testIfThenElseBug4() {
>     String query = "TO_INTEGER(true == true ? 10 : 20 )";
>     Assert.assertEquals(10, run(query, new HashMap<>()));
>   }
> {code}
> The output when running these tests looks something like the following.
> {code}
> org.apache.metron.common.dsl.ParseException: Unable to parse 50 + (true == true ? 10 : 20): Syntax error @ 1:6 no viable alternative at input '50+(true'
> 	at org.apache.metron.common.stellar.BaseStellarProcessor.validate(BaseStellarProcessor.java:72)
> 	at org.apache.metron.common.stellar.BaseStellarProcessor.validate(BaseStellarProcessor.java:62)
> 	at org.apache.metron.common.stellar.StellarTest.run(StellarTest.java:344)
> 	at org.apache.metron.common.stellar.StellarTest.run(StellarTest.java:340)
> 	at org.apache.metron.common.stellar.StellarTest.testIfThenElseBug1(StellarTest.java:147)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:497)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> 	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> 	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
> 	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
> 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
> 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:497)
> 	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
> Caused by: org.apache.metron.common.dsl.ParseException: Syntax error @ 1:6 no viable alternative at input '50+(true'
> 	at org.apache.metron.common.dsl.ErrorListener.syntaxError(ErrorListener.java:34)
> 	at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:65)
> 	at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:558)
> 	at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:310)
> 	at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:147)
> 	at org.apache.metron.common.stellar.generated.StellarParser.transformation_expr(StellarParser.java:301)
> 	at org.apache.metron.common.stellar.generated.StellarParser.transformation(StellarParser.java:147)
> 	at org.apache.metron.common.stellar.BaseStellarProcessor.parse(BaseStellarProcessor.java:57)
> 	at org.apache.metron.common.stellar.BaseStellarProcessor.validate(BaseStellarProcessor.java:67)
> 	... 31 more
> Caused by: org.antlr.v4.runtime.NoViableAltException
> 	at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:1894)
> 	at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:498)
> 	at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:424)
> 	at org.apache.metron.common.stellar.generated.StellarParser.transformation_expr(StellarParser.java:252)
> 	... 34 more
> {code}
> This is causing the ProfilerIntegrationTest to fail.  One of the core Profiler examples leverages this functionality.  This was previously working, but broke likely with METRON-366 or METRON-362.



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