Skip to content

Commit 413de26

Browse files
committed
fix formatting
Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>
1 parent bdd9683 commit 413de26

File tree

11 files changed

+102
-28
lines changed

11 files changed

+102
-28
lines changed

core/src/main/java/org/opensearch/sql/ast/tree/Sort.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
import com.google.common.collect.ImmutableList;
1414
import java.util.List;
15-
import lombok.AllArgsConstructor;
1615
import lombok.Data;
1716
import lombok.EqualsAndHashCode;
1817
import lombok.Getter;
19-
import lombok.RequiredArgsConstructor;
2018
import lombok.ToString;
2119
import org.opensearch.sql.ast.AbstractNodeVisitor;
2220
import org.opensearch.sql.ast.expression.Field;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public RelNode visitSort(Sort node, CalcitePlanContext context) {
337337
if (node.getCount() != null && node.getCount() > 0) {
338338
context.relBuilder.limit(0, node.getCount());
339339
}
340-
340+
341341
return context.relBuilder.peek();
342342
}
343343

core/src/main/java/org/opensearch/sql/planner/logical/LogicalPlanDSL.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public static LogicalPlan sort(LogicalPlan input, Pair<SortOption, Expression>..
101101
return new LogicalSort(input, null, Arrays.asList(sorts));
102102
}
103103

104-
public static LogicalPlan sort(LogicalPlan input, Integer count, Pair<SortOption, Expression>... sorts) {
104+
public static LogicalPlan sort(
105+
LogicalPlan input, Integer count, Pair<SortOption, Expression>... sorts) {
105106
return new LogicalSort(input, count, Arrays.asList(sorts));
106107
}
107108

core/src/main/java/org/opensearch/sql/planner/logical/LogicalSort.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public class LogicalSort extends LogicalPlan {
2424
private final List<Pair<SortOption, Expression>> sortList;
2525

2626
/** Constructor of LogicalSort. */
27-
public LogicalSort(LogicalPlan child, Integer count, List<Pair<SortOption, Expression>> sortList) {
27+
public LogicalSort(
28+
LogicalPlan child, Integer count, List<Pair<SortOption, Expression>> sortList) {
2829
super(Collections.singletonList(child));
2930
this.count = count;
3031
this.sortList = sortList;

core/src/main/java/org/opensearch/sql/planner/optimizer/rule/PushFilterUnderSort.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public PushFilterUnderSort() {
4141
@Override
4242
public LogicalPlan apply(LogicalFilter filter, Captures captures) {
4343
LogicalSort sort = captures.get(capture);
44-
return new LogicalSort(filter.replaceChildPlans(sort.getChild()), sort.getCount(), sort.getSortList());
44+
return new LogicalSort(
45+
filter.replaceChildPlans(sort.getChild()), sort.getCount(), sort.getSortList());
4546
}
4647
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public boolean pushDownSort(LogicalSort sort) {
8888
if (sort.getCount() != null) {
8989
requestBuilder.pushDownLimit(sort.getCount(), 0);
9090
}
91-
91+
9292
return true;
9393
}
9494

ppl/src/main/java/org/opensearch/sql/ppl/parser/AstBuilder.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@
4343
import org.opensearch.sql.ast.dsl.AstDSL;
4444
import org.opensearch.sql.ast.expression.Alias;
4545
import org.opensearch.sql.ast.expression.AllFieldsExcludeMeta;
46+
import org.opensearch.sql.ast.expression.Argument;
4647
import org.opensearch.sql.ast.expression.EqualTo;
4748
import org.opensearch.sql.ast.expression.Field;
4849
import org.opensearch.sql.ast.expression.Let;
4950
import org.opensearch.sql.ast.expression.Literal;
50-
import org.opensearch.sql.ast.expression.Argument;
51-
import org.opensearch.sql.ast.expression.DataType;
5251
import org.opensearch.sql.ast.expression.Map;
5352
import org.opensearch.sql.ast.expression.ParseMethod;
5453
import org.opensearch.sql.ast.expression.PatternMethod;
@@ -378,18 +377,19 @@ public UnresolvedPlan visitHeadCommand(HeadCommandContext ctx) {
378377
public UnresolvedPlan visitSortCommand(SortCommandContext ctx) {
379378
Integer count = ctx.count != null ? Integer.parseInt(ctx.count.getText()) : null;
380379
boolean shouldReverse = ctx.DESC() != null || ctx.D() != null;
381-
382-
List<Field> sortFields = ctx.sortbyClause().sortField().stream()
383-
.map(sort -> (Field) internalVisitExpression(sort))
384-
.map(field -> shouldReverse ? reverseSortDirection(field) : field)
385-
.collect(Collectors.toList());
386-
380+
381+
List<Field> sortFields =
382+
ctx.sortbyClause().sortField().stream()
383+
.map(sort -> (Field) internalVisitExpression(sort))
384+
.map(field -> shouldReverse ? reverseSortDirection(field) : field)
385+
.collect(Collectors.toList());
386+
387387
return new Sort(count, sortFields);
388388
}
389389

390390
private Field reverseSortDirection(Field field) {
391391
List<Argument> updatedArgs = new ArrayList<>();
392-
392+
393393
for (Argument arg : field.getFieldArgs()) {
394394
if ("asc".equals(arg.getArgName())) {
395395
boolean isAscending = (Boolean) arg.getValue().getValue();
@@ -398,7 +398,7 @@ private Field reverseSortDirection(Field field) {
398398
updatedArgs.add(arg);
399399
}
400400
}
401-
401+
402402
return new Field(field.getField(), updatedArgs);
403403
}
404404

ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ public UnresolvedExpression visitWcFieldExpression(WcFieldExpressionContext ctx)
196196
@Override
197197
public UnresolvedExpression visitSortField(SortFieldContext ctx) {
198198

199-
UnresolvedExpression fieldExpression =
199+
UnresolvedExpression fieldExpression =
200200
visit(ctx.sortFieldExpression().fieldExpression().qualifiedName());
201-
201+
202202
// Apply type casting for sort field keywords - create Cast expression if needed
203203
if (ctx.sortFieldExpression().IP() != null) {
204204
fieldExpression = new Cast(fieldExpression, AstDSL.stringLiteral("ip"));

ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,7 @@ public void testSortCommandWithOptions() {
450450
@Test
451451
public void testSortCommandWithCount() {
452452
assertEqual(
453-
"source=t | sort 100 f1",
454-
sort(
455-
relation("t"),
456-
100,
457-
field("f1", defaultSortFieldArgs())));
453+
"source=t | sort 100 f1", sort(relation("t"), 100, field("f1", defaultSortFieldArgs())));
458454
}
459455

460456
@Test
@@ -463,7 +459,10 @@ public void testSortCommandWithDesc() {
463459
"source=t | sort f1 desc",
464460
sort(
465461
relation("t"),
466-
field("f1", exprList(argument("asc", booleanLiteral(false)), argument("type", nullLiteral())))));
462+
field(
463+
"f1",
464+
exprList(
465+
argument("asc", booleanLiteral(false)), argument("type", nullLiteral())))));
467466
}
468467

469468
@Test
@@ -472,7 +471,10 @@ public void testSortCommandWithD() {
472471
"source=t | sort f1 d",
473472
sort(
474473
relation("t"),
475-
field("f1", exprList(argument("asc", booleanLiteral(false)), argument("type", nullLiteral())))));
474+
field(
475+
"f1",
476+
exprList(
477+
argument("asc", booleanLiteral(false)), argument("type", nullLiteral())))));
476478
}
477479

478480
@Test

0 commit comments

Comments
 (0)