Skip to content

Commit

Permalink
Spotless apply on PPL
Browse files Browse the repository at this point in the history
Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale committed Aug 16, 2023
1 parent 5381a6f commit e6a35a5
Show file tree
Hide file tree
Showing 26 changed files with 1,114 additions and 1,565 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ spotless {
target fileTree('.') {
include 'common/**/*.java',
'datasources/**/*.java',
'core/**/*.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 e6a35a5

Please sign in to comment.