Skip to content
Permalink
Browse files
Add one more test case for GINQ
  • Loading branch information
daniellansun committed Apr 11, 2022
1 parent f15e5f1 commit 5e939022d01dfbe55c78b8610f545be8bdc3985d
Showing 2 changed files with 17 additions and 0 deletions.
@@ -431,6 +431,10 @@ include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_grouping_03,in
`_g` is an implicit variable for `agg` aggregate function,
it represents the grouped `Queryable` object and its record(e.g. `r`) could reference the data source by alias(e.g. `n`)
[source, sql]
----
include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_grouping_13,indent=0]
----
Also, we could apply the aggregate functions for the whole GINQ result, i.e. no `groupby` clause is needed:
[source, groovy]
@@ -3005,6 +3005,19 @@ class GinqTest {
'''
}

@Test
void "testGinq - from groupby select - 31"() {
assertGinqScript '''
assert [['A', ['Apple', 'Apricot']], ['B', ['Banana']], ['C', ['Cantaloupe']]] == GQ {
// tag::ginq_grouping_13[]
from fruit in ['Apple', 'Apricot', 'Banana', 'Cantaloupe']
groupby fruit.substring(0, 1) as firstChar
select firstChar, agg(_g.stream().map(r -> r.fruit).toList()) as fruit_list
// end::ginq_grouping_13[]
}.toList()
'''
}

@Test
void "testGinq - from where groupby select - 1"() {
assertGinqScript '''

0 comments on commit 5e93902

Please sign in to comment.