You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "yesamer (via GitHub)" <gi...@apache.org> on 2024/03/05 10:29:30 UTC
[PR] [ki-issues#969]: Negated value in accumulate function ends with Invalid expression error [incubator-kie-drools]
yesamer opened a new pull request, #5762:
URL: https://github.com/apache/incubator-kie-drools/pull/5762
Closes: https://github.com/apache/incubator-kie-issues/issues/969
Description in progress
<details>
<summary>
How to replicate CI configuration locally?
</summary>
Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use [build-chain tool](https://github.com/kiegroup/github-action-build-chain) to handle cross repository builds and be sure that we always use latest version of the code for each repository.
[build-chain tool](https://github.com/kiegroup/github-action-build-chain) is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See [local execution](https://github.com/kiegroup/github-action-build-chain#local-execution) details to get more information about it.
</details>
<details>
<summary>
How to retest this PR or trigger a specific build:
</summary>
- for <b>pull request and downstream checks</b>
- Push a new commit to the PR. An empty commit would be enough.
- for a <b>full downstream build</b>
- for <b>github actions</b> job: add the label `run_fdb`
- for <b>Jenkins PR check only</b>
- If you are an ASF committer for KIE podling, login to Jenkins (https://ci-builds.apache.org/job/KIE/job/drools/), go to the specific PR job, and click on `Build Now` button.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [ki-issues#969]: Negated value in accumulate function ends with Invalid expression error [incubator-kie-drools]
Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #5762:
URL: https://github.com/apache/incubator-kie-drools/pull/5762#discussion_r1512657996
##########
drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/visitor/accumulate/AccumulateVisitor.java:
##########
@@ -406,10 +414,10 @@ private boolean parameterNeedsConvertionToMethodCallExpr(Expression accumulateFu
return accumulateFunctionParameter.isMethodCallExpr() || accumulateFunctionParameter.isArrayAccessExpr() || accumulateFunctionParameter.isFieldAccessExpr();
}
- private Optional<NewBinding> binaryExprParameter(PatternDescr basePattern, AccumulateDescr.AccumulateFunctionCallDescr function, MethodCallExpr functionDSL, String bindingId, String accumulateFunctionParameterStr) {
+ private Optional<NewBinding> binaryOrUnaryExprParameter(PatternDescr basePattern, AccumulateDescr.AccumulateFunctionCallDescr function, MethodCallExpr functionDSL, String bindingId, String accumulateFunctionParameterStr) {
Review Comment:
HI @yesamer
Would it make sense to rename it as `bindingParameter` or similar ?
1. if, by chance, we discover that another kind of expression has to be managed here, the method name would becaome awfull
2. usually, the method name express the returned object
3. IINW, nothing prevent this method to be invoked by somehting different then a `BinaryExpr` or a `UnaryExpr` (if it is implicitily so, I think there should be a check/guard somehow)
WDYT ?
##########
drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/AccumulateTest.java:
##########
@@ -4204,4 +4206,80 @@ public void testJoinInAccumulate() {
assertThat(results.size()).isEqualTo(2);
assertThat(results).containsExactlyInAnyOrder(new Result(0), new Result(75));
}
+
+ @Test
+ public void testAccumulateSumMultipleParametersExpression() {
+ String str =
+ "import " + Person.class.getCanonicalName() + ";" +
+ "import " + Result.class.getCanonicalName() + ";" +
+ "rule X when\n" +
+ " accumulate ( $i : Integer() and $p: Person ( name.length >= $i ); \n" +
+ " $sum : sum($p.getAge(), $p.getName()) \n" +
+ " ) \n" +
+ "then\n" +
+ " insert(new Result($sum));\n" +
+ "end";
+
+ Results results = createKieBuilder(str).getResults();
+ if (testRunType.isExecutableModel()) {
+ System.out.println(results.getMessages(Message.Level.ERROR).get(0).getText());
Review Comment:
Thanks @yesamer
Could you please remove this System.out.println ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [kie-issues#969]: Negated value in accumulate function ends with Invalid expression error [incubator-kie-drools]
Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #5762:
URL: https://github.com/apache/incubator-kie-drools/pull/5762#discussion_r1512664929
##########
drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/visitor/accumulate/AccumulateVisitor.java:
##########
@@ -406,10 +414,10 @@ private boolean parameterNeedsConvertionToMethodCallExpr(Expression accumulateFu
return accumulateFunctionParameter.isMethodCallExpr() || accumulateFunctionParameter.isArrayAccessExpr() || accumulateFunctionParameter.isFieldAccessExpr();
}
- private Optional<NewBinding> binaryExprParameter(PatternDescr basePattern, AccumulateDescr.AccumulateFunctionCallDescr function, MethodCallExpr functionDSL, String bindingId, String accumulateFunctionParameterStr) {
+ private Optional<NewBinding> binaryOrUnaryExprParameter(PatternDescr basePattern, AccumulateDescr.AccumulateFunctionCallDescr function, MethodCallExpr functionDSL, String bindingId, String accumulateFunctionParameterStr) {
Review Comment:
Thank you, done!
##########
drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/AccumulateTest.java:
##########
@@ -4204,4 +4206,80 @@ public void testJoinInAccumulate() {
assertThat(results.size()).isEqualTo(2);
assertThat(results).containsExactlyInAnyOrder(new Result(0), new Result(75));
}
+
+ @Test
+ public void testAccumulateSumMultipleParametersExpression() {
+ String str =
+ "import " + Person.class.getCanonicalName() + ";" +
+ "import " + Result.class.getCanonicalName() + ";" +
+ "rule X when\n" +
+ " accumulate ( $i : Integer() and $p: Person ( name.length >= $i ); \n" +
+ " $sum : sum($p.getAge(), $p.getName()) \n" +
+ " ) \n" +
+ "then\n" +
+ " insert(new Result($sum));\n" +
+ "end";
+
+ Results results = createKieBuilder(str).getResults();
+ if (testRunType.isExecutableModel()) {
+ System.out.println(results.getMessages(Message.Level.ERROR).get(0).getText());
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [ki-issues#969]: Negated value in accumulate function ends with Invalid expression error [incubator-kie-drools]
Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #5762:
URL: https://github.com/apache/incubator-kie-drools/pull/5762#discussion_r1512657996
##########
drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/visitor/accumulate/AccumulateVisitor.java:
##########
@@ -406,10 +414,10 @@ private boolean parameterNeedsConvertionToMethodCallExpr(Expression accumulateFu
return accumulateFunctionParameter.isMethodCallExpr() || accumulateFunctionParameter.isArrayAccessExpr() || accumulateFunctionParameter.isFieldAccessExpr();
}
- private Optional<NewBinding> binaryExprParameter(PatternDescr basePattern, AccumulateDescr.AccumulateFunctionCallDescr function, MethodCallExpr functionDSL, String bindingId, String accumulateFunctionParameterStr) {
+ private Optional<NewBinding> binaryOrUnaryExprParameter(PatternDescr basePattern, AccumulateDescr.AccumulateFunctionCallDescr function, MethodCallExpr functionDSL, String bindingId, String accumulateFunctionParameterStr) {
Review Comment:
HI @yesamer
Would it make sense to rename it as `bindingParameter` or similar ?
1. if, by chance, we discover that another kind of expression has to be managed here, the method name would become awfull
2. usually, the method name express the returned object
3. IINW, nothing prevent this method to be invoked by somehting different then a `BinaryExpr` or a `UnaryExpr` (if it is implicitily so, I think there should be a check/guard somehow)
WDYT ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [kie-issues#969]: Negated value in accumulate function ends with Invalid expression error [incubator-kie-drools]
Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer merged PR #5762:
URL: https://github.com/apache/incubator-kie-drools/pull/5762
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org