Package org.h2.expression.analysis
Class Window
- java.lang.Object
-
- org.h2.expression.analysis.Window
-
public final class Window extends java.lang.Object
Window clause.
-
-
Field Summary
Fields Modifier and Type Field Description private WindowFrame
frame
private java.util.ArrayList<QueryOrderBy>
orderBy
private java.lang.String
parent
private java.util.ArrayList<Expression>
partitionBy
-
Constructor Summary
Constructors Constructor Description Window(java.lang.String parent, java.util.ArrayList<Expression> partitionBy, java.util.ArrayList<QueryOrderBy> orderBy, WindowFrame frame)
Creates a new instance of window clause.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
appendOrderBy(java.lang.StringBuilder builder, java.util.ArrayList<QueryOrderBy> orderBy, int sqlFlags, boolean forceOrderBy)
Appends ORDER BY clause to the specified builder.private static void
appendOrderByStart(java.lang.StringBuilder builder)
Value
getCurrentKey(SessionLocal session)
Returns the key for the current group.java.util.ArrayList<QueryOrderBy>
getOrderBy()
Returns ORDER BY clause.java.lang.StringBuilder
getSQL(java.lang.StringBuilder builder, int sqlFlags, boolean forceOrderBy)
Appends SQL representation to the specified builder.WindowFrame
getWindowFrame()
Returns window frame, or null.boolean
isOrdered()
Returnstrue
if window ordering clause is specified or ROWS unit is used.void
mapColumns(ColumnResolver resolver, int level)
Map the columns of the resolver to expression columns.void
optimize(SessionLocal session)
Try to optimize the window conditions.private void
resolveWindows(ColumnResolver resolver)
void
setEvaluatable(TableFilter tableFilter, boolean value)
Tell the expression columns whether the table filter can return values now.java.lang.String
toString()
void
updateAggregate(SessionLocal session, int stage)
Update an aggregate value.
-
-
-
Field Detail
-
partitionBy
private java.util.ArrayList<Expression> partitionBy
-
orderBy
private java.util.ArrayList<QueryOrderBy> orderBy
-
frame
private WindowFrame frame
-
parent
private java.lang.String parent
-
-
Constructor Detail
-
Window
public Window(java.lang.String parent, java.util.ArrayList<Expression> partitionBy, java.util.ArrayList<QueryOrderBy> orderBy, WindowFrame frame)
Creates a new instance of window clause.- Parameters:
parent
- name of the parent windowpartitionBy
- PARTITION BY clause, or nullorderBy
- ORDER BY clause, or nullframe
- window frame clause, or null
-
-
Method Detail
-
appendOrderBy
public static void appendOrderBy(java.lang.StringBuilder builder, java.util.ArrayList<QueryOrderBy> orderBy, int sqlFlags, boolean forceOrderBy)
Appends ORDER BY clause to the specified builder.- Parameters:
builder
- string builderorderBy
- ORDER BY clause, or nullsqlFlags
- formatting flagsforceOrderBy
- whether synthetic ORDER BY clause should be generated when it is missing
-
appendOrderByStart
private static void appendOrderByStart(java.lang.StringBuilder builder)
-
mapColumns
public void mapColumns(ColumnResolver resolver, int level)
Map the columns of the resolver to expression columns.- Parameters:
resolver
- the column resolverlevel
- the subquery nesting level- See Also:
Expression.mapColumns(ColumnResolver, int, int)
-
resolveWindows
private void resolveWindows(ColumnResolver resolver)
-
optimize
public void optimize(SessionLocal session)
Try to optimize the window conditions.- Parameters:
session
- the session
-
setEvaluatable
public void setEvaluatable(TableFilter tableFilter, boolean value)
Tell the expression columns whether the table filter can return values now. This is used when optimizing the query.- Parameters:
tableFilter
- the table filtervalue
- true if the table filter can return value- See Also:
Expression.setEvaluatable(TableFilter, boolean)
-
getOrderBy
public java.util.ArrayList<QueryOrderBy> getOrderBy()
Returns ORDER BY clause.- Returns:
- ORDER BY clause, or null
-
getWindowFrame
public WindowFrame getWindowFrame()
Returns window frame, or null.- Returns:
- window frame, or null
-
isOrdered
public boolean isOrdered()
Returnstrue
if window ordering clause is specified or ROWS unit is used.- Returns:
true
if window ordering clause is specified or ROWS unit is used
-
getCurrentKey
public Value getCurrentKey(SessionLocal session)
Returns the key for the current group.- Parameters:
session
- session- Returns:
- key for the current group, or null
-
getSQL
public java.lang.StringBuilder getSQL(java.lang.StringBuilder builder, int sqlFlags, boolean forceOrderBy)
Appends SQL representation to the specified builder.- Parameters:
builder
- string buildersqlFlags
- formatting flagsforceOrderBy
- whether synthetic ORDER BY clause should be generated when it is missing- Returns:
- the specified string builder
- See Also:
Expression.getSQL(StringBuilder, int, int)
-
updateAggregate
public void updateAggregate(SessionLocal session, int stage)
Update an aggregate value.- Parameters:
session
- the sessionstage
- select stage- See Also:
Expression.updateAggregate(SessionLocal, int)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-