Skip to content

GROOVY-11915: GINQ: Add groupby...into with first-class GroupResult type#2453

Merged
daniellansun merged 1 commit intoapache:masterfrom
paulk-asert:groovy11915
Apr 11, 2026
Merged

GROOVY-11915: GINQ: Add groupby...into with first-class GroupResult type#2453
daniellansun merged 1 commit intoapache:masterfrom
paulk-asert:groovy11915

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

@paulk-asert paulk-asert commented Apr 10, 2026

Summary of changes

New files (2):

  • GroupResult.java — interface extending Queryable with getKey() and key(String)
  • GroupResultImpl.java — implementation extending QueryableCollection, materializes group elements as a list for reuse

Modified files (6):

  • GroupExpression.java — added intoAlias field with getter/setter, updated getText()
  • GinqAstBuilder.java — added KW_INTO keyword, dispatch block for into that sets alias on GroupExpression, hedge error for where after groupby...into, reordered conditions so hedge is checked before generic
    DataSourceHolder check
  • GinqAstWalker.groovy — added __GROUPBY_INTO_ALIAS metadata key, getGroupByIntoAlias() helper, modified visitGroupExpression to generate groupByInto() call with simple having lambda, modified
    getLambdaParamName/correctVariablesOfLambdaExpression/validateGroupCols to bypass rewriting in into-mode
  • Queryable.java — added groupByInto() method signatures
  • QueryableCollection.java — added groupByInto() implementation
  • ginq-userguide.adoc — added "Group Into" subsection with examples

Tests added:

  • 3 backend API tests in QueryableCollectionTest.groovy
  • 5 DSL-level tests in GinqTest.groovy (single-key, multi-key, sum, having, multi-key with as)
  • 2 error tests in GinqErrorTest.groovy (where-after-into hedge, into-without-groupby)

Key design decisions in implementation:

  • GroupResultImpl materializes elements via toList() to avoid stream-already-consumed errors when aggregates are called multiple times (having + select)
  • Single-key getKey() unwraps the NamedRecord to return the raw value
  • into is parsed as a chained method call (groupby(n).into(g)), not as part of groupby's arguments — cleanly separates key aliasing (as) from group aliasing (into)

This comment was marked as outdated.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 84.12698% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.4901%. Comparing base (5e07369) to head (c820e64).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ovy/org/apache/groovy/ginq/dsl/GinqAstBuilder.java 70.5882% 4 Missing and 1 partial ⚠️
...q/provider/collection/runtime/GroupResultImpl.java 66.6667% 1 Missing and 2 partials ⚠️
...he/groovy/ginq/dsl/expression/GroupExpression.java 75.0000% 1 Missing ⚠️
...ovider/collection/runtime/QueryableCollection.java 88.8889% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2453        +/-   ##
==================================================
+ Coverage     66.4799%   66.4901%   +0.0103%     
- Complexity      30238      30269        +31     
==================================================
  Files            1409       1411         +2     
  Lines          117953     118016        +63     
  Branches        20976      20987        +11     
==================================================
+ Hits            78415      78469        +54     
- Misses          33066      33073         +7     
- Partials         6472       6474         +2     
Files with missing lines Coverage Δ
...oovy/ginq/provider/collection/GinqAstWalker.groovy 90.4161% <100.0000%> (+0.2607%) ⬆️
.../ginq/provider/collection/runtime/GroupResult.java 100.0000% <100.0000%> (ø)
...vy/ginq/provider/collection/runtime/Queryable.java 76.6667% <100.0000%> (+0.8046%) ⬆️
...he/groovy/ginq/dsl/expression/GroupExpression.java 73.3333% <75.0000%> (+0.6061%) ⬆️
...ovider/collection/runtime/QueryableCollection.java 90.0568% <88.8889%> (-0.0306%) ⬇️
...q/provider/collection/runtime/GroupResultImpl.java 66.6667% <66.6667%> (ø)
...ovy/org/apache/groovy/ginq/dsl/GinqAstBuilder.java 88.9344% <70.5882%> (-1.3739%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This comment was marked as outdated.

@paulk-asert paulk-asert force-pushed the groovy11915 branch 3 times, most recently from 62d2e3e to ce31a90 Compare April 10, 2026 04:04
@daniellansun daniellansun merged commit b1e7ac8 into apache:master Apr 11, 2026
23 checks passed
@daniellansun
Copy link
Copy Markdown
Contributor

Merged. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants