Skip to content

Commit 9a2b08e

Browse files
committed
Address comments
Signed-off-by: Tomoyuki Morita <[email protected]>
1 parent a44c763 commit 9a2b08e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

common/src/main/java/org/opensearch/sql/common/utils/DebugUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.Map;
1010
import java.util.stream.Collectors;
1111

12-
/** Utility class for debugging operations. Should not be committed. */
12+
/** Utility class for debugging operations. */
1313
public class DebugUtils {
1414

1515
private static void print(String format, Object... args) {

core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,10 +1898,9 @@ public RelNode visitRareTopN(RareTopN node, CalcitePlanContext context) {
18981898

18991899
// 1. group the group-by list + field list and add a count() aggregation
19001900
List<UnresolvedExpression> groupExprList = new ArrayList<>();
1901-
node.getGroupExprList().forEach(exp -> groupExprList.add(addAliasToDynamicFieldAccess(exp)));
1901+
node.getGroupExprList().forEach(exp -> groupExprList.add(addAliasToFieldAccess(exp)));
19021902
// need alias for dynamic fields
1903-
node.getFields()
1904-
.forEach(field -> groupExprList.add(AstDSL.alias(field.getField().toString(), field)));
1903+
node.getFields().forEach(field -> groupExprList.add(addAliasToFieldAccess(field)));
19051904
List<UnresolvedExpression> aggExprList =
19061905
List.of(AstDSL.alias(countFieldName, AstDSL.aggregate("count", null)));
19071906
aggregateWithTrimming(groupExprList, aggExprList, context);
@@ -2155,7 +2154,8 @@ public RelNode visitTimechart(
21552154
}
21562155
}
21572156

2158-
private UnresolvedExpression addAliasToDynamicFieldAccess(UnresolvedExpression exp) {
2157+
/** Add alias to Field. Needed for when the field is resolved as dynamic field access. */
2158+
private UnresolvedExpression addAliasToFieldAccess(UnresolvedExpression exp) {
21592159
if (exp instanceof Field f) {
21602160
return AstDSL.alias(f.getField().toString(), f);
21612161
} else {

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalciteDynamicFieldsAggregationIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void testEventstatsByDynamicField() throws IOException {
128128
String query =
129129
source(
130130
TEST_INDEX_DYNAMIC,
131-
"eventstats count() as c by department" + "| fields id, city, department, c");
131+
"eventstats count() as c by department | fields id, city, department, c");
132132

133133
assertExplainYaml(
134134
query,

0 commit comments

Comments
 (0)