Skip to content

Commit

Permalink
[Backport 2.x] [Spotless] Applying Google Code Format for core/src/ma…
Browse files Browse the repository at this point in the history
…in files #1 #1930 (#1992)

* [Spotless] Applying Google Code Format for core/src/main files #1 (#1930)

* # This is a combination of 9 commits.

Fix create_index/create_index_with_IOException issue caused by OpenSearch PR change (#1899)

* Added setDefaultMediaType for create_index and create_index_with_IOException

Signed-off-by: Mitchell Gale <[email protected]>
(cherry picked from commit 7b932a7)
Signed-off-by: Mitchell Gale <[email protected]>

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <[email protected]>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <[email protected]>

Converts java doc table to proper java doc table.

Signed-off-by: Mitchell Gale <[email protected]>

Resolving merge conflicts for pre tag in java docs 2

Signed-off-by: Mitchell Gale <[email protected]>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <[email protected]>

cherry pick 60c0018

Signed-off-by: Mitchell Gale <[email protected]>

Addressed PR comment for table format in AbstractExprValue.

Signed-off-by: Mitchell Gale <[email protected]>

Removed pre tag from ExpressionReferenceOptimizer.

Signed-off-by: Mitchell Gale <[email protected]>

Removed pre tag from AstDSL.java

Signed-off-by: Mitchell Gale <[email protected]>

Removed pre tag from AstDSL.java

Signed-off-by: Mitchell Gale <[email protected]>

Removed pre tag from SelectExpressionAnalyzer.java

Signed-off-by: Mitchell Gale <[email protected]>

fixed java doc in QualifiedName.java

Signed-off-by: Mitchell Gale <[email protected]>

Removing checkstyle test for core and added spotless for relevant directories.

Signed-off-by: Mitchell Gale <[email protected]>

Fixing spacing around headers in ExpressionReferenceOptimizer.java SelectExpressionAnalyzer.java

Signed-off-by: Mitchell Gale <[email protected]>

Fix breaking changes. Disable some flaky tests in legacy.

Signed-off-by: Yury-Fridlyand <[email protected]>

(cherry picked from commit 809e656)
Signed-off-by: Mitchell Gale <[email protected]>

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <[email protected]>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <[email protected]>

Fixed java doc spelling and improving string concatination.

Signed-off-by: Mitchell Gale <[email protected]>

improving string concatination.

Signed-off-by: Mitchell Gale <[email protected]>

Improving failure format on some functions.

Signed-off-by: Mitchell Gale <[email protected]>

spotless apply and fix of build.gradle

Signed-off-by: Mitchell Gale <[email protected]>

* parent 496fe8e
author Mitchell Gale <[email protected]> 1691080710 -0700
committer Mitchell Gale <[email protected]> 1691080766 -0700

Fix create_index/create_index_with_IOException issue caused by OpenSearch PR change (#1899)

* Added setDefaultMediaType for create_index and create_index_with_IOException

Signed-off-by: Mitchell Gale <[email protected]>
(cherry picked from commit 7b932a7)
Signed-off-by: Mitchell Gale <[email protected]>

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <[email protected]>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <[email protected]>

Converts java doc table to proper java doc table.

Signed-off-by: Mitchell Gale <[email protected]>

Resolving merge conflicts for pre tag in java docs 2

Signed-off-by: Mitchell Gale <[email protected]>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <[email protected]>

cherry pick 60c0018

Signed-off-by: Mitchell Gale <[email protected]>

Addressed PR comment for table format in AbstractExprValue.

Signed-off-by: Mitchell Gale <[email protected]>

Removed pre tag from ExpressionReferenceOptimizer.

Signed-off-by: Mitchell Gale <[email protected]>

Removed pre tag from AstDSL.java

Signed-off-by: Mitchell Gale <[email protected]>

Removed pre tag from AstDSL.java

Signed-off-by: Mitchell Gale <[email protected]>

Removed pre tag from SelectExpressionAnalyzer.java

Signed-off-by: Mitchell Gale <[email protected]>

fixed java doc in QualifiedName.java

Signed-off-by: Mitchell Gale <[email protected]>

Removing checkstyle test for core and added spotless for relevant directories.

Signed-off-by: Mitchell Gale <[email protected]>

Fixing spacing around headers in ExpressionReferenceOptimizer.java SelectExpressionAnalyzer.java

Signed-off-by: Mitchell Gale <[email protected]>

Fix breaking changes. Disable some flaky tests in legacy.

Signed-off-by: Yury-Fridlyand <[email protected]>

(cherry picked from commit 809e656)
Signed-off-by: Mitchell Gale <[email protected]>

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <[email protected]>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <[email protected]>

Fixed java doc spelling and improving string concatination.

Signed-off-by: Mitchell Gale <[email protected]>

improving string concatination.

Signed-off-by: Mitchell Gale <[email protected]>

Improving failure format on some functions.

Signed-off-by: Mitchell Gale <[email protected]>

spotless apply and fix of build.gradle

Signed-off-by: Mitchell Gale <[email protected]>

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <[email protected]>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <[email protected]>

Converts java doc table to proper java doc table.

Signed-off-by: Mitchell Gale <[email protected]>

Removing unused import in OpenSearchRestClientTest.java

Signed-off-by: Mitchell Gale <[email protected]>

* running spotless apply.

Signed-off-by: Mitchell Gale <[email protected]>

* Addressed comments in PR 5.

Signed-off-by: Mitchell Gale <[email protected]>

---------

Signed-off-by: Mitchell Gale <[email protected]>

* spotless apply

Signed-off-by: Mitchell Gale <[email protected]>

* removed pitest

Signed-off-by: Mitchell Gale <[email protected]>

* remove pitest

Signed-off-by: Mitchell Gale <[email protected]>

* add spotless

Signed-off-by: Mitchell Gale <[email protected]>

* remove pitest

Signed-off-by: Mitchell Gale <[email protected]>

---------

Signed-off-by: Mitchell Gale <[email protected]>
Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale authored Aug 22, 2023
1 parent 6c07ac7 commit d205bd6
Show file tree
Hide file tree
Showing 101 changed files with 384 additions and 729 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ spotless {
'core/src/test/java/org/opensearch/sql/analysis/**/*.java',
'core/src/main/java/org/opensearch/sql/planner/**/*.java',
'core/src/main/java/org/opensearch/sql/storage/**/*.java',
'core/src/main/java/org/opensearch/sql/utils/**/*.java',
'core/src/main/java/org/opensearch/sql/monitor/**/*.java'
'core/src/main/java/org/opensearch/sql/utils/**/*.java'
exclude '**/build/**', '**/build-*/**'
}
importOrder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@
import org.opensearch.sql.planner.logical.LogicalWindow;

/**
* The optimizer used to replace the expression referred in the SelectClause e.g. The query SELECT
* abs(name), sum(age)-avg(age) FROM test GROUP BY abs(name). will be translated the AST
* Project[abs(age), sub(sum(age), avg(age)) Agg(agg=[sum(age), avg(age)], group=[abs(age)]]
* Relation The sum(age) and avg(age) in the Project could be replace by the analyzed reference, the
* LogicalPlan should be LogicalProject[Ref("abs(age)"), sub(Ref("sum(age)"), Ref("avg(age)"))
* LogicalAgg(agg=[sum(age), avg(age)], group=[abs(age)]] LogicalRelation
* The optimizer used to replace the expression referred in the SelectClause</br> e.g. The query
* SELECT abs(name), sum(age)-avg(age) FROM test GROUP BY abs(name).<br>
* will be translated the AST<br>
* Project[abs(age), sub(sum(age), avg(age))<br>
* &ensp Agg(agg=[sum(age), avg(age)], group=[abs(age)]]<br>
* &emsp Relation<br>
* The sum(age) and avg(age) in the Project could be replaced by the analyzed reference, the
* LogicalPlan should be<br>
* LogicalProject[Ref("abs(age)"), sub(Ref("sum(age)"), Ref("avg(age)"))<br>
* &ensp LogicalAgg(agg=[sum(age), avg(age)], group=[abs(age)]]<br>
* &emsp LogicalRelation
*/
public class ExpressionReferenceOptimizer
extends ExpressionNodeVisitor<Expression, AnalysisContext> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,17 @@ public List<NamedExpression> visitAlias(Alias node, AnalysisContext context) {
}

/**
* The Alias could be 1. SELECT name, AVG(age) FROM s BY name -> Project(Alias("name", expr),
* Alias("AVG(age)", aggExpr)) Agg(Alias("AVG(age)", aggExpr)) 2. SELECT length(name), AVG(age)
* FROM s BY length(name) Project(Alias("name", expr), Alias("AVG(age)", aggExpr))
* Agg(Alias("AVG(age)", aggExpr)) 3. SELECT length(name) as l, AVG(age) FROM s BY l
* Project(Alias("name", expr, l), Alias("AVG(age)", aggExpr)) Agg(Alias("AVG(age)", aggExpr),
* Alias("length(name)", groupExpr))
* The Alias could be
*
* <ol>
* <li>SELECT name, AVG(age) FROM s BY name -> Project(Alias("name", expr), Alias("AVG(age)",
* aggExpr)) Agg(Alias("AVG(age)", aggExpr))
* <li>SELECT length(name), AVG(age) FROM s BY length(name) Project(Alias("name", expr),
* Alias("AVG(age)", aggExpr)) Agg(Alias("AVG(age)", aggExpr))
* <li>SELECT length(name) as l, AVG(age) FROM s BY l Project(Alias("name", expr, l),
* Alias("AVG(age)", aggExpr)) Agg(Alias("AVG(age)", aggExpr), Alias("length(name)",
* groupExpr))
* </ol>
*/
private Expression referenceIfSymbolDefined(Alias expr, AnalysisContext context) {
UnresolvedExpression delegatedExpr = expr.getDelegated();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast;

import org.opensearch.sql.ast.expression.AggregateFunction;
Expand Down Expand Up @@ -62,9 +61,7 @@
import org.opensearch.sql.ast.tree.TableFunction;
import org.opensearch.sql.ast.tree.Values;

/**
* AST nodes visitor Defines the traverse path.
*/
/** AST nodes visitor Defines the traverse path. */
public abstract class AbstractNodeVisitor<T, C> {

public T visit(Node node, C context) {
Expand All @@ -73,6 +70,7 @@ public T visit(Node node, C context) {

/**
* Visit child node.
*
* @param node {@link Node}
* @param context Context
* @return Return Type.
Expand Down
5 changes: 1 addition & 4 deletions core/src/main/java/org/opensearch/sql/ast/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast;

import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
* AST node.
*/
/** AST node. */
@EqualsAndHashCode
@ToString
public abstract class Node {
Expand Down
10 changes: 7 additions & 3 deletions core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,27 @@ public static Function function(String funcName, UnresolvedExpression... funcArg
}

/**
* <pre>
* CASE
* WHEN search_condition THEN result_expr
* [WHEN search_condition THEN result_expr] ...
* [ELSE result_expr]
* WHEN search_condition THEN result_expr<br>
* [WHEN search_condition THEN result_expr] ...
* [ELSE result_expr]
* END
* </pre>
*/
public UnresolvedExpression caseWhen(UnresolvedExpression elseClause,
When... whenClauses) {
return caseWhen(null, elseClause, whenClauses);
}

/**
* <pre>
* CASE case_value_expr
* WHEN compare_expr THEN result_expr
* [WHEN compare_expr THEN result_expr] ...
* [ELSE result_expr]
* END
* </pre>
*/
public UnresolvedExpression caseWhen(UnresolvedExpression caseValueExpr,
UnresolvedExpression elseClause,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import java.util.Collections;
Expand All @@ -17,8 +16,8 @@
import org.opensearch.sql.common.utils.StringUtils;

/**
* Expression node of aggregate functions.
* Params include aggregate function name (AVG, SUM, MAX etc.) and the field to aggregate.
* Expression node of aggregate functions. Params include aggregate function name (AVG, SUM, MAX
* etc.) and the field to aggregate.
*/
@Getter
@EqualsAndHashCode(callSuper = false)
Expand All @@ -27,13 +26,16 @@ public class AggregateFunction extends UnresolvedExpression {
private final String funcName;
private final UnresolvedExpression field;
private final List<UnresolvedExpression> argList;

@Setter
@Accessors(fluent = true)
private UnresolvedExpression condition;

private Boolean distinct = false;

/**
* Constructor.
*
* @param funcName function name.
* @param field {@link UnresolvedExpression}.
*/
Expand All @@ -45,6 +47,7 @@ public AggregateFunction(String funcName, UnresolvedExpression field) {

/**
* Constructor.
*
* @param funcName function name.
* @param field {@link UnresolvedExpression}.
* @param distinct whether distinct field is specified or not.
Expand Down
21 changes: 7 additions & 14 deletions core/src/main/java/org/opensearch/sql/ast/expression/Alias.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import lombok.AllArgsConstructor;
Expand All @@ -14,10 +13,10 @@
import org.opensearch.sql.ast.AbstractNodeVisitor;

/**
* Alias abstraction that associate an unnamed expression with a name and an optional alias.
* The name and alias information preserved is useful for semantic analysis and response
* formatting eventually. This can avoid restoring the info in toString() method which is
* inaccurate because original info is already lost.
* Alias abstraction that associate an unnamed expression with a name and an optional alias. The
* name and alias information preserved is useful for semantic analysis and response formatting
* eventually. This can avoid restoring the info in toString() method which is inaccurate because
* original info is already lost.
*/
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
Expand All @@ -26,19 +25,13 @@
@ToString
public class Alias extends UnresolvedExpression {

/**
* Original field name.
*/
/** Original field name. */
private final String name;

/**
* Expression aliased.
*/
/** Expression aliased. */
private final UnresolvedExpression delegated;

/**
* Optional field alias.
*/
/** Optional field alias. */
private String alias;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import java.util.Collections;
Expand All @@ -13,16 +12,13 @@
import org.opensearch.sql.ast.AbstractNodeVisitor;
import org.opensearch.sql.ast.Node;

/**
* Represent the All fields which is been used in SELECT *.
*/
/** Represent the All fields which is been used in SELECT *. */
@ToString
@EqualsAndHashCode(callSuper = false)
public class AllFields extends UnresolvedExpression {
public static final AllFields INSTANCE = new AllFields();

private AllFields() {
}
private AllFields() {}

public static AllFields of() {
return INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import java.util.Arrays;
Expand All @@ -14,9 +13,7 @@
import lombok.ToString;
import org.opensearch.sql.ast.AbstractNodeVisitor;

/**
* Expression node of logic AND.
*/
/** Expression node of logic AND. */
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import java.util.Arrays;
Expand All @@ -14,9 +13,7 @@
import lombok.ToString;
import org.opensearch.sql.ast.AbstractNodeVisitor;

/**
* Argument.
*/
/** Argument. */
@Getter
@ToString
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import com.google.common.collect.ImmutableList;
Expand All @@ -14,15 +13,12 @@
import lombok.ToString;
import org.opensearch.sql.ast.AbstractNodeVisitor;

/**
* Expression node that includes a list of Expression nodes.
*/
/** Expression node that includes a list of Expression nodes. */
@ToString
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
public class AttributeList extends UnresolvedExpression {
@Getter
private List<UnresolvedExpression> attrList;
@Getter private List<UnresolvedExpression> attrList;

@Override
public List<UnresolvedExpression> getChild() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import org.opensearch.sql.ast.AbstractNodeVisitor;
import org.opensearch.sql.ast.Node;

/**
* Unresolved expression for BETWEEN.
*/
/** Unresolved expression for BETWEEN. */
@Data
@EqualsAndHashCode(callSuper = false)
public class Between extends UnresolvedExpression {
Expand Down
18 changes: 5 additions & 13 deletions core/src/main/java/org/opensearch/sql/ast/expression/Case.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import com.google.common.collect.ImmutableList;
Expand All @@ -15,29 +14,23 @@
import org.opensearch.sql.ast.AbstractNodeVisitor;
import org.opensearch.sql.ast.Node;

/**
* AST node that represents CASE clause similar as Switch statement in programming language.
*/
/** AST node that represents CASE clause similar as Switch statement in programming language. */
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Getter
@ToString
public class Case extends UnresolvedExpression {

/**
* Value to be compared by WHEN statements. Null in the case of CASE WHEN conditions.
*/
/** Value to be compared by WHEN statements. Null in the case of CASE WHEN conditions. */
private final UnresolvedExpression caseValue;

/**
* Expression list that represents WHEN statements. Each is a mapping from condition
* to its result.
* Expression list that represents WHEN statements. Each is a mapping from condition to its
* result.
*/
private final List<When> whenClauses;

/**
* Expression that represents ELSE statement result.
*/
/** Expression that represents ELSE statement result. */
private final UnresolvedExpression elseClause;

@Override
Expand All @@ -58,5 +51,4 @@ public List<? extends Node> getChild() {
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
return nodeVisitor.visitCase(this, context);
}

}
Loading

0 comments on commit d205bd6

Please sign in to comment.