Package org.h2.expression.analysis

# Class Window

java.lang.Object
org.h2.expression.analysis.Window

public final class Window extends Object
Window clause.

## Constructor Summary

Constructors
Constructor
Description
`Window(String parent, ArrayList<Expression> partitionBy, ArrayList<QueryOrderBy> orderBy, WindowFrame frame)`
Creates a new instance of window clause.

## Method Summary

Modifier and Type
Method
Description
`static void`
`appendOrderBy(StringBuilder builder, ArrayList<QueryOrderBy> orderBy, int sqlFlags, boolean forceOrderBy)`
Appends ORDER BY clause to the specified builder.
`Value`
`getCurrentKey(SessionLocal session)`
Returns the key for the current group.
`ArrayList<QueryOrderBy>`
`getOrderBy()`
Returns ORDER BY clause.
`StringBuilder`
`getSQL(StringBuilder builder, int sqlFlags, boolean forceOrderBy)`
Appends SQL representation to the specified builder.
`WindowFrame`
`getWindowFrame()`
Returns window frame, or null.
`boolean`
`isOrdered()`
Returns `true` 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.
`void`
`setEvaluatable(TableFilter tableFilter, boolean value)`
Tell the expression columns whether the table filter can return values now.
`String`
`toString()`
`void`
`updateAggregate(SessionLocal session, int stage)`
Update an aggregate value.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### Window

public Window(String parent, ArrayList<Expression> partitionBy, ArrayList<QueryOrderBy> orderBy, WindowFrame frame)
Creates a new instance of window clause.

Parameters:
  `parent` - name of the parent window
  `partitionBy` - PARTITION BY clause, or null
  `orderBy` - ORDER BY clause, or null
  `frame` - window frame clause, or null

## Method Details

### appendOrderBy

public static void appendOrderBy(StringBuilder builder, ArrayList<QueryOrderBy> orderBy, int sqlFlags, boolean forceOrderBy)
Appends ORDER BY clause to the specified builder.

Parameters:
  `builder` - string builder
  `orderBy` - ORDER BY clause, or null
  `sqlFlags` - formatting flags
  `forceOrderBy` - whether synthetic ORDER BY clause should be generated when it is missing

### mapColumns

public void mapColumns(ColumnResolver resolver, int level)
Map the columns of the resolver to expression columns.

Parameters:
  `resolver` - the column resolver
  `level` - the subquery nesting level
See Also:
  - `Expression.mapColumns(ColumnResolver, int, int)`

### 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 filter
  `value` - true if the table filter can return value
See Also:
  - `Expression.setEvaluatable(TableFilter, boolean)`

### getOrderBy

public 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()
Returns `true` 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 StringBuilder getSQL(StringBuilder builder, int sqlFlags, boolean forceOrderBy)
Appends SQL representation to the specified builder.

Parameters:
  `builder` - string builder
  `sqlFlags` - formatting flags
  `forceOrderBy` - 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 session
  `stage` - select stage
See Also:
  - `Expression.updateAggregate(SessionLocal, int)`

### toString

public String toString()

Overrides:
  `toString` in class `Object`