Skip to content

Commit

Permalink
Adding pre tag to javadocs that need to maintain old formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchellGale authored Jul 28, 2023
1 parent 90e44c4 commit 7d55f5a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@
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
* <pre>
* 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
* </pre>
*/
public class ExpressionReferenceOptimizer
extends ExpressionNodeVisitor<Expression, AnalysisContext> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,18 @@ 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))
* <pre>
* 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))
* </pre>
*/
private Expression referenceIfSymbolDefined(Alias expr, AnalysisContext context) {
UnresolvedExpression delegatedExpr = expr.getDelegated();
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,13 @@ public static Function function(String funcName, UnresolvedExpression... funcArg
}

/**
* CASE WHEN search_condition THEN result_expr [WHEN search_condition THEN result_expr] ... [ELSE
* result_expr] END
* <pre>
* CASE
* WHEN search_condition THEN result_expr
* [WHEN search_condition THEN result_expr] ...
* [ELSE result_expr]
* END
* </pre>
*/
public UnresolvedExpression caseWhen(UnresolvedExpression elseClause, When... whenClauses) {
return caseWhen(null, elseClause, whenClauses);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@
import org.opensearch.sql.exception.ExpressionEvaluationException;

/**
* The definition of widening type rule for expression value. ExprType Widens to data types INTEGER
* LONG, FLOAT, DOUBLE LONG FLOAT, DOUBLE FLOAT DOUBLE DOUBLE DOUBLE STRING STRING BOOLEAN BOOLEAN
* ARRAY ARRAY STRUCT STRUCT
* <pre>
* The definition of widening type rule for expression value.
* ExprType Widens to data types
* INTEGER LONG, FLOAT, DOUBLE
* LONG FLOAT, DOUBLE
* FLOAT DOUBLE
* DOUBLE DOUBLE
* STRING STRING
* BOOLEAN BOOLEAN
* ARRAY ARRAY
* STRUCT STRUCT
* </pre>
*/
@UtilityClass
public class WideningTypeRule {
Expand Down

0 comments on commit 7d55f5a

Please sign in to comment.