@@ -184,6 +184,7 @@ private void updateWithSequenceGroup(KeyValue kv) {
184
184
row .setField (
185
185
fieldIndex , getters [fieldIndex ].getFieldOrNull (kv .value ()));
186
186
}
187
+ continue ;
187
188
}
188
189
row .setField (
189
190
i , aggregator == null ? field : aggregator .agg (accumulator , field ));
@@ -304,6 +305,7 @@ private Factory(Options options, RowType rowType, List<String> primaryKeys) {
304
305
List <String > fieldNames = rowType .getFieldNames ();
305
306
this .fieldSeqComparators = new HashMap <>();
306
307
Map <String , Integer > sequenceGroupMap = new HashMap <>();
308
+ List <String > allSequenceFields = new ArrayList <>();
307
309
for (Map .Entry <String , String > entry : options .toMap ().entrySet ()) {
308
310
String k = entry .getKey ();
309
311
String v = entry .getValue ();
@@ -318,6 +320,7 @@ private Factory(Options options, RowType rowType, List<String> primaryKeys) {
318
320
.split (FIELDS_SEPARATOR ))
319
321
.map (fieldName -> validateFieldName (fieldName , fieldNames ))
320
322
.collect (Collectors .toList ());
323
+ allSequenceFields .addAll (sequenceFields );
321
324
322
325
Supplier <FieldsComparator > userDefinedSeqComparator =
323
326
() -> UserDefinedSeqComparator .create (rowType , sequenceFields , true );
@@ -347,7 +350,8 @@ private Factory(Options options, RowType rowType, List<String> primaryKeys) {
347
350
}
348
351
}
349
352
this .fieldAggregators =
350
- createFieldAggregators (rowType , primaryKeys , new CoreOptions (options ));
353
+ createFieldAggregators (
354
+ rowType , primaryKeys , allSequenceFields , new CoreOptions (options ));
351
355
if (!fieldAggregators .isEmpty () && fieldSeqComparators .isEmpty ()) {
352
356
throw new IllegalArgumentException (
353
357
"Must use sequence group for aggregation functions." );
@@ -514,7 +518,10 @@ private String validateFieldName(String fieldName, List<String> fieldNames) {
514
518
* @return The aggregators for each column.
515
519
*/
516
520
private Map <Integer , Supplier <FieldAggregator >> createFieldAggregators (
517
- RowType rowType , List <String > primaryKeys , CoreOptions options ) {
521
+ RowType rowType ,
522
+ List <String > primaryKeys ,
523
+ List <String > allSequenceFields ,
524
+ CoreOptions options ) {
518
525
519
526
List <String > fieldNames = rowType .getFieldNames ();
520
527
List <DataType > fieldTypes = rowType .getFieldTypes ();
@@ -539,7 +546,8 @@ private Map<Integer, Supplier<FieldAggregator>> createFieldAggregators(
539
546
isPrimaryKey ,
540
547
options ,
541
548
fieldName ));
542
- } else if (defaultAggFunc != null ) {
549
+ } else if (defaultAggFunc != null && !allSequenceFields .contains (fieldName )) {
550
+ // no agg for sequence fields
543
551
fieldAggregators .put (
544
552
i ,
545
553
() ->
0 commit comments