[
https://issues.apache.org/jira/browse/GROOVY-12847?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153324#comment-18153324
]
ASF GitHub Bot commented on GROOVY-12847:
-----------------------------------------
codecov-commenter commented on PR #3383:
URL: https://github.com/apache/groovy/pull/3383#issuecomment-7308467640
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3383?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
:x: Patch coverage is `0%` with `1 line` in your changes missing coverage.
Please review.
:white_check_mark: Project coverage is 72.7129%. Comparing base
([`0f008db`](https://app.codecov.io/gh/apache/groovy/commit/0f008db020fe72dd1ffc25d787cd6780d091395b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`ed15fca`](https://app.codecov.io/gh/apache/groovy/commit/ed15fcab8685b97f6499f4485a2c464607b9bd1f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on GROOVY_6_0_X.
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3383?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Patch % | Lines |
|---|---|---|
|
[...oovy/ginq/provider/collection/GinqAstWalker.groovy](https://app.codecov.io/gh/apache/groovy/pull/3383?src=pr&el=tree&filepath=subprojects%2Fgroovy-ginq%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fapache%2Fgroovy%2Fginq%2Fprovider%2Fcollection%2FGinqAstWalker.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWdpbnEvc3JjL21haW4vZ3Jvb3Z5L29yZy9hcGFjaGUvZ3Jvb3Z5L2dpbnEvcHJvdmlkZXIvY29sbGVjdGlvbi9HaW5xQXN0V2Fsa2VyLmdyb292eQ==)
| 0.0000% | [0 Missing and 1 partial :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3383?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/3383?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## GROOVY_6_0_X #3383 +/- ##
======================================================
+ Coverage 72.7117% 72.7129% +0.0012%
- Complexity 40335 40336 +1
======================================================
Files 1595 1595
Lines 141907 141902 -5
Branches 26905 26902 -3
======================================================
- Hits 103183 103181 -2
+ Misses 29449 29444 -5
- Partials 9275 9277 +2
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3383?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...oovy/ginq/provider/collection/GinqAstWalker.groovy](https://app.codecov.io/gh/apache/groovy/pull/3383?src=pr&el=tree&filepath=subprojects%2Fgroovy-ginq%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fapache%2Fgroovy%2Fginq%2Fprovider%2Fcollection%2FGinqAstWalker.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWdpbnEvc3JjL21haW4vZ3Jvb3Z5L29yZy9hcGFjaGUvZ3Jvb3Z5L2dpbnEvcHJvdmlkZXIvY29sbGVjdGlvbi9HaW5xQXN0V2Fsa2VyLmdyb292eQ==)
| `90.3145% <0.0000%> (-0.0605%)` | :arrow_down: |
... and [7 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3383/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests,
report on failures, and find test suite problems.
- :package: [JS Bundle
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save
yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
> GINQ: implicit aggregates give wrong results when the property name starts
> with a capital letter
> ------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12847
> URL: https://issues.apache.org/jira/browse/GROOVY-12847
> Project: Groovy
> Issue Type: Bug
> Components: GINQ
> Affects Versions: 6.0.1
> Reporter: Paul King
> Priority: Major
>
> Implicit GINQ aggregates ({{sum}}, {{avg}}, {{min}}, {{max}}, {{count}}) over
> a property whose name starts with a capital letter silently give wrong
> results. Capitalised names are common with data such as CSV files with header
> rows.
> h3. Reproducer
> {code:groovy}
> def rows = [[k: 'a', v: 3.0, V: 3.0], [k: 'a', v: 1.0, V: 1.0]]
> assert GQ { from r in rows select sum(r.v) }.toList() == [4.0] // ok
> assert GQ { from r in rows select sum(r.V) }.toList() == [4.0] // fails:
> [6.0]
> {code}
> {{groupby}} isn't required, but the same happens with it. Results on 6.0.1,
> using the rows above (with {{groupby r.k}}) unless noted:
> ||Query||lowercase {{v}}||capital {{V}}||
> |{{sum}}|4.0|6.0 (wrong)|
> |{{min}}|1.0|3.0 (wrong)|
> |{{count}}, rows null then 5.0|1|0 (wrong)|
> |{{sum}} after an inner join of the rows with themselves on {{k}}|8.0|12.0
> (wrong)|
> |{{select r.k, r.x}} where {{x}} is not in the {{groupby}}|compile error, as
> expected|accepted, returns 3.0|
> {{where}}, {{groupby r.V}}, {{over()}} windows and {{agg}} gave the expected
> results.
> h3. Cause
> From reading the source, {{GinqAstWalker.correctVars}} has:
> {code:groovy}
> if (expression instanceof PropertyExpression) {
> if (Character.isUpperCase(expression.propertyAsString.charAt(0))) {
> return transformedExpression // null
> }
> if (isExternalVariable(findRootObjectExpression(expression))) {
> return transformedExpression
> }
> }
> {code}
> Returning {{null}} tells the caller to leave the expression and its children
> alone. So in {{sum(r.V)}} the {{r}} isn't rewritten to the aggregate lambda's
> parameter. It still compiles because the enclosing lambda declares {{r}} from
> {{__sourceRecord}}, so every iteration reads the group's representative row.
> The check was added in 5d6680a05a, apparently so that the {{java.lang.Math}}
> part of {{max(java.lang.Math.abs\(n))}} is left alone. The
> {{isExternalVariable}} check added shortly after in d1951f6873 seems to cover
> that case, as {{java}} isn't a query alias.
> The last row of the table appears to come from a similar check in
> {{validateGroupCols}}.
> The same code is on master, GROOVY_6_0_X, GROOVY_5_0_X and GROOVY_4_0_X,
> though only 6.0.x has been run.
> h3. Possible fix
> Remove the capital letter check in {{correctVars}}, relying on
> {{isExternalVariable}}, and review whether the one in {{validateGroupCols}}
> can also rely on its existing alias check. Not yet tested.
> h3. Workarounds
> {code:groovy}
> assert GQ { from r in rows groupby r.k into g select g.sum(r -> r.V)
> }.toList() == [4.0]
> assert GQ { from r in rows select sum(r['V']) }.toList() == [4.0]
> {code}
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)