Skip to content

Commit

Permalink
[Spotless] Applying Google Code Format for ppl files #12 (opensearch-…
Browse files Browse the repository at this point in the history
…project#1972)

* Spotless apply on PPL (#339)

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

* Update ppl/src/test/java/org/opensearch/sql/ppl/parser/AstExpressionBuilderTest.java

Co-authored-by: Guian Gumpac <[email protected]>
Signed-off-by: Mitchell Gale <[email protected]>

---------

Signed-off-by: Mitchell Gale <[email protected]>
Signed-off-by: Mitchell Gale <[email protected]>
Co-authored-by: Guian Gumpac <[email protected]>
  • Loading branch information
MitchellGale and GumpacG committed Aug 22, 2023
1 parent d205bd6 commit 4254974
Show file tree
Hide file tree
Showing 26 changed files with 1,116 additions and 1,575 deletions.
15 changes: 4 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,10 @@ repositories {
spotless {
java {
target fileTree('.') {
include 'core/src/main/java/org/opensearch/sql/monitor/**/*.java',
'core/src/main/java/org/opensearch/sql/expression/**/*.java',
'core/src/main/java/org/opensearch/sql/executor/**/*.java',
'core/src/main/java/org/opensearch/sql/exception/**/*.java',
'core/src/main/java/org/opensearch/sql/DataSourceSchemaName.java',
'core/src/test/java/org/opensearch/sql/data/**/*.java',
'core/src/test/java/org/opensearch/sql/config/**/*.java',
'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'
include 'common/**/*.java',
'datasources/**/*.java',
'core/**/*.java',
'ppl/**/*.java'
exclude '**/build/**', '**/build-*/**'
}
importOrder()
Expand Down
5 changes: 5 additions & 0 deletions ppl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ plugins {
id 'antlr'
}

// Being ignored as a temporary measure before being removed in favour of
// spotless https://github.com/opensearch-project/sql/issues/1101
checkstyleTest.ignoreFailures = true
checkstyleMain.ignoreFailures = true

generateGrammarSource {
arguments += ['-visitor', '-package', 'org.opensearch.sql.ppl.antlr.parser']
source = sourceSets.main.antlr
Expand Down
16 changes: 6 additions & 10 deletions ppl/src/main/java/org/opensearch/sql/ppl/PPLService.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.ppl;

import static org.opensearch.sql.executor.ExecutionEngine.QueryResponse;
Expand All @@ -27,9 +26,7 @@
import org.opensearch.sql.ppl.parser.AstStatementBuilder;
import org.opensearch.sql.ppl.utils.PPLQueryDataAnonymizer;

/**
* PPLService.
*/
/** PPLService. */
@RequiredArgsConstructor
public class PPLService {
private final PPLSyntaxParser parser;
Expand All @@ -45,7 +42,7 @@ public class PPLService {
/**
* Execute the {@link PPLQueryRequest}, using {@link ResponseListener} to get response.
*
* @param request {@link PPLQueryRequest}
* @param request {@link PPLQueryRequest}
* @param listener {@link ResponseListener}
*/
public void execute(PPLQueryRequest request, ResponseListener<QueryResponse> listener) {
Expand All @@ -57,10 +54,10 @@ public void execute(PPLQueryRequest request, ResponseListener<QueryResponse> lis
}

/**
* Explain the query in {@link PPLQueryRequest} using {@link ResponseListener} to
* get and format explain response.
* Explain the query in {@link PPLQueryRequest} using {@link ResponseListener} to get and format
* explain response.
*
* @param request {@link PPLQueryRequest}
* @param request {@link PPLQueryRequest}
* @param listener {@link ResponseListener} for explain response
*/
public void explain(PPLQueryRequest request, ResponseListener<ExplainResponse> listener) {
Expand Down Expand Up @@ -90,7 +87,6 @@ private AbstractPlan plan(
QueryContext.getRequestId(),
anonymizer.anonymizeStatement(statement));

return queryExecutionFactory.create(
statement, queryListener, explainListener);
return queryExecutionFactory.create(statement, queryListener, explainListener);
}
}
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.ppl.antlr;

import org.antlr.v4.runtime.CommonTokenStream;
Expand All @@ -15,13 +14,9 @@
import org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLLexer;
import org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser;

/**
* PPL Syntax Parser.
*/
/** PPL Syntax Parser. */
public class PPLSyntaxParser implements Parser {
/**
* Analyze the query syntax.
*/
/** Analyze the query syntax. */
@Override
public ParseTree parse(String query) {
OpenSearchPPLParser parser = createParser(createLexer(query));
Expand All @@ -30,12 +25,10 @@ public ParseTree parse(String query) {
}

private OpenSearchPPLParser createParser(Lexer lexer) {
return new OpenSearchPPLParser(
new CommonTokenStream(lexer));
return new OpenSearchPPLParser(new CommonTokenStream(lexer));
}

private OpenSearchPPLLexer createLexer(String query) {
return new OpenSearchPPLLexer(
new CaseInsensitiveCharStream(query));
return new OpenSearchPPLLexer(new CaseInsensitiveCharStream(query));
}
}
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.ppl.domain;

import java.util.Locale;
Expand All @@ -22,12 +21,9 @@ public class PPLQueryRequest {
public static final PPLQueryRequest NULL = new PPLQueryRequest("", null, DEFAULT_PPL_PATH, "");

private final String pplQuery;
@Getter
private final JSONObject jsonContent;
@Getter
private final String path;
@Getter
private String format = "";
@Getter private final JSONObject jsonContent;
@Getter private final String path;
@Getter private String format = "";

@Setter
@Getter
Expand All @@ -43,9 +39,7 @@ public PPLQueryRequest(String pplQuery, JSONObject jsonContent, String path) {
this(pplQuery, jsonContent, path, "");
}

/**
* Constructor of PPLQueryRequest.
*/
/** Constructor of PPLQueryRequest. */
public PPLQueryRequest(String pplQuery, JSONObject jsonContent, String path, String format) {
this.pplQuery = pplQuery;
this.jsonContent = jsonContent;
Expand All @@ -59,23 +53,21 @@ public String getRequest() {

/**
* Check if request is to explain rather than execute the query.
* @return true if it is a explain request
*
* @return true if it is a explain request
*/
public boolean isExplainRequest() {
return path.endsWith("/_explain");
}

/**
* Decide on the formatter by the requested format.
*/
/** Decide on the formatter by the requested format. */
public Format format() {
Optional<Format> optionalFormat = Format.of(format);
if (optionalFormat.isPresent()) {
return optionalFormat.get();
} else {
throw new IllegalArgumentException(
String.format(Locale.ROOT,"response in %s format is not supported.", format));
String.format(Locale.ROOT, "response in %s format is not supported.", format));
}
}

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


package org.opensearch.sql.ppl.domain;

public class PPLQueryResponse {
}
public class PPLQueryResponse {}
Loading

0 comments on commit 4254974

Please sign in to comment.