Skip to content

Commit 33bab3f

Browse files
committed
Address comments
Signed-off-by: Tomoyuki Morita <[email protected]>
1 parent c65993f commit 33bab3f

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
@@ -1897,10 +1897,9 @@ public RelNode visitRareTopN(RareTopN node, CalcitePlanContext context) {
18971897

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

2157-
private UnresolvedExpression addAliasToDynamicFieldAccess(UnresolvedExpression exp) {
2156+
/** Add alias to Field. Needed for when the field is resolved as dynamic field access. */
2157+
private UnresolvedExpression addAliasToFieldAccess(UnresolvedExpression exp) {
21582158
if (exp instanceof Field f) {
21592159
return AstDSL.alias(f.getField().toString(), f);
21602160
} 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)