Skip to content

Commit

Permalink
Merge branch '2.x' into Spotless_Backport_6_pt2
Browse files Browse the repository at this point in the history
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>
  • Loading branch information
MitchellGale authored Aug 22, 2023
2 parents b18eb64 + 6c07ac7 commit 5afb99f
Show file tree
Hide file tree
Showing 24 changed files with 696 additions and 240 deletions.
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ repositories {
mavenCentral()
}

checkstyleTest.ignoreFailures = true
checkstyleMain.ignoreFailures = true
checkstyleTest.ignoreFailures = true

dependencies {
api group: 'com.google.guava', name: 'guava', version: '32.0.1-jre'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
public interface ExecutionEngine {

/**
* 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. deprecated this interface after finalize {@link ExecutionContext}.
*
* @param plan executable physical plan
* @param listener response listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.opensearch.sql.executor.execution.AbstractPlan;

/**
* QueryManager is the high-level interface of core engine. Frontend submit {@link AbstractPlan} to
* QueryManager.
* QueryManager is the high-level interface of core engine. Frontend submit an {@link AbstractPlan}
* to QueryManager.
*/
public interface QueryManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class QueryService {
private final Planner planner;

/**
* 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. deprecated this interface after finalize {@link PlanContext}.
*
* @param plan {@link UnresolvedPlan}
* @param listener {@link ResponseListener}
Expand All @@ -46,7 +46,8 @@ public void execute(

/**
* Execute the {@link UnresolvedPlan}, with {@link PlanContext} and using {@link ResponseListener}
* to get response. Todo. Pass split from PlanContext to ExecutionEngine in following PR.
* to get response.<br>
* Todo. Pass split from PlanContext to ExecutionEngine in following PR.
*
* @param plan {@link LogicalPlan}
* @param planContext {@link PlanContext}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ interface ExecutionStrategy {
}

/**
* execute task with fixed interval. if task run time < interval, trigger next task on next
* interval. if task run time >= interval, trigger next task immediately.
* execute task with fixed interval.<br>
* if task run time < interval, trigger next task on next interval.<br>
* if task run time >= interval, trigger next task immediately.
*/
@RequiredArgsConstructor
public static class IntervalTriggerExecution implements ExecutionStrategy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,27 @@
import org.opensearch.sql.expression.function.BuiltinFunctionName;

/**
* Use this unresolved plan visitor to check if a plan can be serialized by PaginatedPlanCache. If
* Use this unresolved plan visitor to check if a plan can be serialized by PaginatedPlanCache.<br>
* 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.
* returns <em>true</em>, <em>PaginatedPlanCache.convertToCursor</em> will succeed.<br>
* Otherwise, it will fail.<br>
* The purpose of this visitor is to activate legacy engine fallback mechanism.<br>
* Currently, V2 engine does not support queries with:<br>
*
* <ul>
* <li>aggregation (GROUP BY clause or aggregation functions like min/max)
* <li>in memory aggregation (window function)
* <li>LIMIT/OFFSET clause(s)
* <li>without FROM clause
* <li>JOIN
* <li>a subquery
* </ul>
*
* V2 also requires that the table being queried should be an OpenSearch index.<br>
* See PaginatedPlanCache.canConvertToCursor for usage.
*/
public class CanPaginateVisitor extends AbstractNodeVisitor<Boolean, Object> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ public T visitNamedAggregator(NamedAggregator node, C context) {

/**
* 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
* handled:
*
* <ol>
* <li>by visitFunction() if not overwritten: ex. FilterQueryBuilder
* <li>by visitCase/When() otherwise if any special logic: ex. ExprReferenceOptimizer
* </ol>
*/
public T visitCase(CaseClause node, C context) {
return visitFunction(node, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
import org.opensearch.sql.expression.env.Environment;

/**
* Named expression that represents expression with name. Please see more details in associated
* unresolved expression operator {@link org.opensearch.sql.ast.expression.Alias}.
* Named expression that represents expression with name.<br>
* Please see more details in associated unresolved expression operator<br>
* {@link org.opensearch.sql.ast.expression.Alias}.
*/
@AllArgsConstructor
@EqualsAndHashCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,39 @@ public String toString() {
}

/**
* 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.
* <pre>
* 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.
*
* <p>Resolve Rule 1. Resolve the full name by combine the paths("x"."y"."z") as whole ("x.y.z").
* 2. Resolve the path recursively through ExprValue.
*
* @param value {@link ExprTupleValue}.
* @return {@link ExprTupleValue}.
* </pre>
*/
public ExprValue resolve(ExprTupleValue value) {
return resolve(value, paths);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
import org.opensearch.sql.expression.function.FunctionSignature;

/**
* The definition of aggregator function avg, Accepts two numbers and produces a number. sum,
* Accepts two numbers and produces a number. max, Accepts two numbers and produces a number. min,
* Accepts two numbers and produces a number. count, Accepts two numbers and produces a number.
* The definition of aggregator functions <em>avg</em>, <em>sum</em>, <em>min</em>, <em>max</em> and
* <em>count</em>.<br>
* All of them accept a list of numbers and produce a number. <em>avg</em>, <em>min</em> and
* <em>max</em> also accept datetime types.<br>
* <em>count</em> accepts values of all types.
*/
@UtilityClass
public class AggregatorFunction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

/**
* NamedAggregator expression that represents expression with name. Please see more details in
* associated unresolved expression operator {@link org.opensearch.sql.ast.expression.Alias}.
* associated unresolved expression operator<br>
* {@link org.opensearch.sql.ast.expression.Alias}.
*/
@EqualsAndHashCode(callSuper = false)
public class NamedAggregator extends Aggregator<AggregationState> {
Expand Down
Loading

0 comments on commit 5afb99f

Please sign in to comment.