Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spotless] Applying Google Code Format for core/src/main files #2 #313

Closed

Conversation

MitchellGale
Copy link

Description

This PR applies Spotless on Java code for:
core/src/main/java/org/opensearch/sql/exception
core/src/main/java/org/opensearch/sql/executor
core/src/main/java/org/opensearch/sql/expression
core/src/main/java/org/opensearch/sql/monitor

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Merging #313 (4076a2d) into integ/sl_GoogleJavaFormat2 (4102b58) will decrease coverage by 0.06%.
Report is 11 commits behind head on integ/sl_GoogleJavaFormat2.
The diff coverage is 100.00%.

@@                       Coverage Diff                        @@
##             integ/sl_GoogleJavaFormat2     #313      +/-   ##
================================================================
- Coverage                         97.39%   97.34%   -0.06%     
+ Complexity                         4603     4405     -198     
================================================================
  Files                               401      371      -30     
  Lines                             11397    11129     -268     
  Branches                            835      774      -61     
================================================================
- Hits                              11100    10833     -267     
+ Misses                              290      289       -1     
  Partials                              7        7              
Flag Coverage Δ
sql-engine 97.34% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...h/sql/exception/ExpressionEvaluationException.java 100.00% <ø> (ø)
...opensearch/sql/exception/QueryEngineException.java 100.00% <ø> (ø)
...ensearch/sql/exception/SemanticCheckException.java 100.00% <ø> (ø)
.../org/opensearch/sql/executor/ExecutionContext.java 100.00% <ø> (ø)
...main/java/org/opensearch/sql/executor/QueryId.java 100.00% <ø> (ø)
...java/org/opensearch/sql/executor/QueryManager.java 100.00% <ø> (ø)
...opensearch/sql/executor/execution/CommandPlan.java 100.00% <ø> (ø)
...opensearch/sql/executor/execution/ExplainPlan.java 100.00% <ø> (ø)
...rch/sql/executor/execution/StreamingQueryPlan.java 100.00% <ø> (ø)
...org/opensearch/sql/executor/pagination/Cursor.java 100.00% <ø> (ø)
... and 72 more

... and 29 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@GumpacG
Copy link

GumpacG commented Jul 25, 2023

Checkstyle fails for some of the changes.

@MitchellGale MitchellGale force-pushed the dev/sl_GoogleJavaFormat2 branch 3 times, most recently from b698850 to b8aea35 Compare July 27, 2023 22:22
Comment on lines 44 to 53
* Use this unresolved plan visitor to check if a plan can be serialized by PaginatedPlanCache. If
*
* <pre>plan.accept(new CanPaginateVisitor(...))</pre>
*
* returns <em>true</em>, then PaginatedPlanCache.convertToCursor will succeed. Otherwise, it will
* fail. The purpose of this visitor is to activate legacy engine fallback mechanism. Currently, V2
* engine does not support queries with: - aggregation (GROUP BY clause or aggregation functions
* like min/max) - in memory aggregation (window function) - LIMIT/OFFSET clause(s) - without FROM
* clause - JOIN - a subquery V2 also requires that the table being queried should be an OpenSearch
* index. See PaginatedPlanCache.canConvertToCursor for usage.
Copy link

@matthewryanwells matthewryanwells Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you need to add more pre tags to this take make all of the lines not lose formatting

Comment on lines +30 to +34
* @param visitor visitor
* @param context context
* @param <T> result type
* @param <C> context type
* @return result accumulated by visitor when visiting

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would adding pre tags here help fix the even spacing from being lost?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would, but I don't think it's worth it as @oaram are important parts of Javadocs so I think we shouldn't mess with it.

Comment on lines +30 to +32
* @param node function node
* @param context context
* @return result

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another spacing issue

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's an improvement removing the extra spaces

Comment on lines 85 to 87
* Call visitFunction() by default rather than visitChildren(). This makes CASE/WHEN able to be
* handled: 1) by visitFunction() if not overwritten: ex. FilterQueryBuilder 2) by
* visitCase/When() otherwise if any special logic: ex. ExprReferenceOptimizer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs pre tags

Comment on lines +18 to +19
* @param <T> type of return value to accumulate when visiting.
* @param <C> type of context.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically the spacing on this one is still fine because both lines have the same length but still should have pre

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes a difference?

Comment on lines 18 to 19
* Named expression that represents expression with name. Please see more details in associated
* unresolved expression operator {@link org.opensearch.sql.ast.expression.Alias}.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs pre

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved.

Comment on lines 64 to 72
* Resolve the ExprValue from {@link ExprTupleValue} using paths. Considering the following sample
* data. { "name": "bob smith" "project.year": 1990, "project": { "year": "2020" } "address": {
* "state": "WA", "city": "seattle", "project.year": 1990 } "address.local": { "state": "WA", } }
* The paths could be 1. top level, e.g. "name", which will be resolved as "bob smith" 2. multiple
* paths, e.g. "name.address.state", which will be resolved as "WA" 3. special case, the "." is
* the path separator, but it is possible that the path include ".", for handling this use case,
* we define the resolve rule as bellow, e.g. "project.year" is resolved as 1990 instead of 2020.
* Note. This logic only applied top level none object field. e.g. "address.local.state" been
* resolved to Missing. but "address.project.year" could been resolved as 1990.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs pre

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved.

* 3) Sliding window frame that maintains a sliding window of fixed size
* Note that which type of window frame is used is determined by both window function itself
* and frame definition in a window definition.
* Window frame that represents a subset of a window which is all data accessible to the window
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved.

@@ -82,11 +75,10 @@ public ExprValue current() {
/**
* Preload all peer rows if last peer rows done. Note that when no more data in peeking iterator,
* there must be rows in frame (hasNext()=true), so no need to check it.hasNext() in this method.
* Load until:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

* 1. Ranking window functions: ignore frame definition and always operates on
* previous and current row.
* 2. Aggregate window functions: frame partition into peers and sliding window is not supported.
* Create specific window frame based on window definition and what's current window function. For
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* The definition of text functions.
* 1) have the clear interface for function define.
* 2) the implementation should rely on ExprValue.
* The definition of text functions. 1) have the clear interface for function define. 2) the
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* float/double integer float/double (field type)
* float/double double float/double (field type)
* other any field type
* Return type follows the following table. FIELD VALUE RETURN_TYPE int/long integer int/long
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* NULL NULL
* MISSING MISSING
*/
/** The not logic. A NOT A TRUE FALSE FALSE TRUE NULL NULL MISSING MISSING */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL a not a true false false true null null missing missing.
Needs tags as well

* FALSE MISSING MISSING
* NULL NULL NULL
* NULL MISSING NULL
* The xor logic. A B A AND B TRUE TRUE FALSE TRUE FALSE TRUE TRUE NULL TRUE TRUE MISSING TRUE
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* NULL NULL NULL
* NULL MISSING NULL
* MISSING MISSING MISSING
* The or logic. A B A AND B TRUE TRUE TRUE TRUE FALSE TRUE TRUE NULL TRUE TRUE MISSING TRUE FALSE
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* FALSE MISSING FALSE
* NULL NULL NULL
* NULL MISSING MISSING
* The and logic. A B A AND B TRUE TRUE TRUE TRUE FALSE FALSE TRUE NULL NULL TRUE MISSING MISSING
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* or, Accepts two Boolean values and produces a Boolean.
* xor, Accepts two Boolean values and produces a Boolean.
* equalTo, Compare the left expression and right expression and produces a Boolean.
* The definition of binary predicate function and, Accepts two Boolean values and produces a
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* The supported signature of floor function is
* (STRING, INTEGER, INTEGER) -> STRING
* (INTEGER, INTEGER, INTEGER) -> STRING
* Definition of conv(x, a, b) function. Convert number x from base a to base b The supported
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* The definition of date and time functions.
* 1) have the clear interface for function define.
* 2) the implementation should rely on ExprValue.
* The definition of date and time functions. 1) have the clear interface for function define. 2)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* (TIME, INTERVAL) -> TIME // when interval has no date part
* (STRING, INTERVAL) -> STRING // when argument has date or datetime string,
* // result has date or datetime depending on interval type
* A common signature for `date_add` and `date_sub`. Specify a start date and add/subtract a
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* Adds/subtracts an integer number of days to/from the first argument.
* (DATE, LONG) -> DATE
* (TIME/DATETIME/TIMESTAMP, LONG) -> DATETIME
* A common signature for `adddate` and `subdate`. Adds/subtracts an integer number of days
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* (STRING, STRING/TIME) -> STRING // second arg - string with time only
* (x, STRING) -> NULL // second arg - string with timestamp
* (x, STRING/DATE) -> x // second arg - string with date only
* Adds expr2 to expr1 and returns the result. (TIME, TIME/DATE/DATETIME/TIMESTAMP) -> TIME
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* (x, x) -> NULL // when args have different types
* (STRING, STRING) -> TIME // argument strings contain same types only
* (STRING, STRING) -> NULL // argument strings are different types
* Returns different between two times as a time. (TIME, TIME) -> TIME MySQL has these signatures
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* (DATETIME, STRING) -> STRING
* (TIME, STRING) -> STRING
* (TIMESTAMP, STRING) -> STRING
* Formats date according to format specifier. First argument is time, second is format. Detailed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

* - negative year is not accepted
* - @dayOfYear should be greater than 1
* - if @dayOfYear is greater than 365/366, calculation goes to the next year(s)
* Furthermore: - zero year interpreted as 2000 - negative year is not accepted - @dayOfYear
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tags as well

@MitchellGale MitchellGale force-pushed the dev/sl_GoogleJavaFormat2 branch 2 times, most recently from 45fe539 to 66c98ae Compare July 28, 2023 22:35
/**
* Call visitFunction() by default rather than visitChildren().
* This makes CASE/WHEN able to be handled:
* * <ol>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have added a new * here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

* (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE)
* -> wider type between types of x and y
* Definition of divide(x, y) function. Returns the number x divided by number y The supported
* signature of divide function is (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add

 tags here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

* (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE)
* -> wider type between types of x and y
* Definition of modulus(x, y) function. Returns the number x modulo by number y The supported
* signature of modulo function is (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add

 tags here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

* (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE)
* -> wider type between types of x and y
* Definition of multiply(x, y) function. Returns the number x multiplied by number y The
* supported signature of multiply function is (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add

 tags here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

* The supported signature of subtract function is
* (x: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE, y: BYTE/SHORT/INTEGER/LONG/FLOAT/DOUBLE)
* -> wider type between types of x and y
* Definition of subtract(x, y) function. Returns the number x minus number y The supported

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add

 tags here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

* The supported signature of mod function is
* (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE)
* -> wider type between types of x and y
* Definition of mod(x, y) function. Calculate the remainder of x divided by y The supported

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add

 tags here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

* Definition of atan(x) and atan(y, x) function. atan(x) calculates the arc tangent of x, that
* is, the value whose tangent is x. atan(y, x) calculates the arc tangent of y / x, except that
* the signs of both arguments are used to determine the quadrant of the result. The supported
* signature of atan function is (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) ->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add

 tags here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already included this file in part 1 in #312

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also present in #312 with other changes

*/
public class NoCursorException extends RuntimeException {
}
public class NoCursorException extends RuntimeException {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{} will conflict with checkstyle

Comment on lines +23 to +24
* Execute physical plan and call back response listener. Todo. deprecated this interface after
* finalize {@link ExecutionContext}.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Execute physical plan and call back response listener. Todo. deprecated this interface after
* finalize {@link ExecutionContext}.
* Execute physical plan and call back response listener.<br />
* TODO: deprecate this interface after finalize {@link ExecutionContext}.

Comment on lines +32 to +33
* Execute the {@link UnresolvedPlan}, using {@link ResponseListener} to get response. Todo.
* deprecated this interface after finalize {@link PlanContext}.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Execute the {@link UnresolvedPlan}, using {@link ResponseListener} to get response. Todo.
* deprecated this interface after finalize {@link PlanContext}.
* Execute the {@link UnresolvedPlan}, using {@link ResponseListener} to get response.<br />
* TODO: deprecate this interface after finalize {@link PlanContext}.

@@ -87,6 +132,7 @@ public static void register(BuiltinFunctionRepository repository) {
.build();

/**
* <pre>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a table too?

@@ -115,6 +162,7 @@ public static void register(BuiltinFunctionRepository repository) {
.build();

/**
* <pre>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a table too?

}

/**
* <pre>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a table too?

return rounding.round(field.valueOf(valueEnv));
}

/**
* <pre>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a table?

* REPLACE(str, from_str, to_str) returns the string str with all occurrences of
* the string from_str replaced by the string to_str.
* REPLACE() performs a case-sensitive match when searching for from_str.
* Supports following signature:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: add <br /> to put signature on the next line (for all functions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants