Skip to content

Commit f91b2cf

Browse files
committed
Chores: reorder util functions
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 764e450 commit f91b2cf

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteLogicalIndexScan.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ public CalciteLogicalIndexScan pushDownSort(List<RelFieldCollation> collations)
309309
return null;
310310
}
311311

312+
private List<String> getCollationNames(List<RelFieldCollation> collations) {
313+
return collations.stream()
314+
.map(collation -> getRowType().getFieldNames().get(collation.getFieldIndex()))
315+
.toList();
316+
}
317+
312318
/**
313319
* Check if the sort by collations contains any aggregators that are pushed down. E.g. In `stats
314320
* avg(age) as avg_age by state | sort avg_age`, the sort clause has `avg_age` which is an
@@ -327,10 +333,17 @@ private boolean hasAggregatorInSortBy(List<String> collations) {
327333
.reduce(false, Boolean::logicalOr);
328334
}
329335

330-
private List<String> getCollationNames(List<RelFieldCollation> collations) {
336+
private static boolean isAnyCollationNameInAggregateOutput(
337+
LogicalAggregate aggregate, List<String> collations) {
338+
List<String> fieldNames = aggregate.getRowType().getFieldNames();
339+
// The output fields of the aggregate are in the format of
340+
// [...grouping fields, ...aggregator fields], so we set an offset to skip
341+
// the grouping fields.
342+
int groupOffset = aggregate.getGroupSet().cardinality();
343+
List<String> fieldsWithoutGrouping = fieldNames.subList(groupOffset, fieldNames.size());
331344
return collations.stream()
332-
.map(collation -> getRowType().getFieldNames().get(collation.getFieldIndex()))
333-
.toList();
345+
.map(fieldsWithoutGrouping::contains)
346+
.reduce(false, Boolean::logicalOr);
334347
}
335348

336349
/**
@@ -357,19 +370,6 @@ private static List<RelFieldCollation> mergeCollations(
357370
return new ArrayList<>(mergedCollations.values());
358371
}
359372

360-
private static boolean isAnyCollationNameInAggregateOutput(
361-
LogicalAggregate aggregate, List<String> collations) {
362-
List<String> fieldNames = aggregate.getRowType().getFieldNames();
363-
// The output fields of the aggregate are in the format of
364-
// [...grouping fields, ...aggregator fields], so we set an offset to skip
365-
// the grouping fields.
366-
int groupOffset = aggregate.getGroupSet().cardinality();
367-
List<String> fieldsWithoutGrouping = fieldNames.subList(groupOffset, fieldNames.size());
368-
return collations.stream()
369-
.map(fieldsWithoutGrouping::contains)
370-
.reduce(false, Boolean::logicalOr);
371-
}
372-
373373
/**
374374
* Create a new {@link PushDownContext} without the collation action.
375375
*

0 commit comments

Comments
 (0)