From d5d0012b4f65df1dca3ac8136f95d19e1a9a0437 Mon Sep 17 00:00:00 2001 From: James Duong Date: Mon, 21 Oct 2024 11:07:10 -0700 Subject: [PATCH] Use List#get(0) instead of getFirst() to support older compilers Signed-off-by: James Duong --- core/src/main/java/org/opensearch/sql/executor/Explain.java | 2 +- .../opensearch/sql/planner/physical/TrendlineOperator.java | 5 ++--- .../org/opensearch/sql/ppl/utils/PPLQueryDataAnonymizer.java | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/opensearch/sql/executor/Explain.java b/core/src/main/java/org/opensearch/sql/executor/Explain.java index 99d66f1bfc..baedea0fa4 100644 --- a/core/src/main/java/org/opensearch/sql/executor/Explain.java +++ b/core/src/main/java/org/opensearch/sql/executor/Explain.java @@ -265,7 +265,7 @@ private List> describeTrendlineComputations( ImmutableMap.of( "computationType", computation.getComputationType().name().toLowerCase(Locale.ROOT), "numberOfDataPoints", computation.getNumberOfDataPoints().toString(), - "dataField", computation.getDataField().getChild().getFirst().toString(), + "dataField", computation.getDataField().getChild().get(0).toString(), "alias", computation.getAlias() != null ? computation.getAlias() : "")) .collect(Collectors.toList()); } diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/TrendlineOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/TrendlineOperator.java index c62fbc3300..8a0bfa87c9 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/TrendlineOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/TrendlineOperator.java @@ -32,7 +32,6 @@ public class TrendlineOperator extends PhysicalPlan { @Getter private final List computations; private final List accumulators; private final Map fieldToIndexMap; - private boolean hasAnotherRow = false; public TrendlineOperator(PhysicalPlan input, List computations) { this.input = input; @@ -41,7 +40,7 @@ public TrendlineOperator(PhysicalPlan input, List(computations.size()); for (int i = 0; i < computations.size(); ++i) { - fieldToIndexMap.put(computations.get(i).getDataField().getChild().getFirst().toString(), i); + fieldToIndexMap.put(computations.get(i).getDataField().getChild().get(0).toString(), i); } } @@ -76,7 +75,7 @@ public ExprValue next() { if (null != computations.get(i).getAlias()) { mapBuilder.put(computations.get(i).getAlias(), calculateResult); } else { - mapBuilder.put(computations.get(i).getDataField().getChild().getFirst().toString(), calculateResult); + mapBuilder.put(computations.get(i).getDataField().getChild().get(0).toString(), calculateResult); } } result = ExprTupleValue.fromExprValueMap(mapBuilder.buildKeepingLast()); diff --git a/ppl/src/main/java/org/opensearch/sql/ppl/utils/PPLQueryDataAnonymizer.java b/ppl/src/main/java/org/opensearch/sql/ppl/utils/PPLQueryDataAnonymizer.java index 5b961b0f13..7e622489ba 100644 --- a/ppl/src/main/java/org/opensearch/sql/ppl/utils/PPLQueryDataAnonymizer.java +++ b/ppl/src/main/java/org/opensearch/sql/ppl/utils/PPLQueryDataAnonymizer.java @@ -224,7 +224,7 @@ public String visitHead(Head node, String context) { @Override public String visitTrendline(Trendline node, String context) { - String child = node.getChild().getFirst().accept(this, context); + String child = node.getChild().get(0).accept(this, context); String computations = visitExpressionList(node.getComputations()); return StringUtils.format("%s | trendline %s", child, computations); }