use of org.apache.flink.table.api.SessionWithGapOnTimeWithAlias in project flink by apache.
the class AggregateOperationFactory method createResolvedWindow.
/**
* Converts an API class to a resolved window for planning with expressions already resolved. It
* performs following validations:
*
* <ul>
* <li>The alias is represented with an unresolved reference
* <li>The time attribute is a single field reference of a {@link
* TimeIndicatorTypeInfo}(stream), {@link SqlTimeTypeInfo}(batch), or {@link
* BasicTypeInfo#LONG_TYPE_INFO}(batch) type
* <li>The size & slide are value literals of either {@link BasicTypeInfo#LONG_TYPE_INFO}, or
* {@link TimeIntervalTypeInfo} type
* <li>The size & slide are of the same type
* <li>The gap is a value literal of a {@link TimeIntervalTypeInfo} type
* </ul>
*
* @param window window to resolve
* @param resolver resolver to resolve potential unresolved field references
* @return window with expressions resolved
*/
ResolvedGroupWindow createResolvedWindow(GroupWindow window, ExpressionResolver resolver) {
Expression alias = window.getAlias();
if (!(alias instanceof UnresolvedReferenceExpression)) {
throw new ValidationException("Only unresolved reference supported for alias of a group window.");
}
final String windowName = ((UnresolvedReferenceExpression) alias).getName();
FieldReferenceExpression timeField = getValidatedTimeAttribute(window, resolver);
if (window instanceof TumbleWithSizeOnTimeWithAlias) {
return validateAndCreateTumbleWindow((TumbleWithSizeOnTimeWithAlias) window, windowName, timeField);
} else if (window instanceof SlideWithSizeAndSlideOnTimeWithAlias) {
return validateAndCreateSlideWindow((SlideWithSizeAndSlideOnTimeWithAlias) window, windowName, timeField);
} else if (window instanceof SessionWithGapOnTimeWithAlias) {
return validateAndCreateSessionWindow((SessionWithGapOnTimeWithAlias) window, windowName, timeField);
} else {
throw new TableException("Unknown window type: " + window);
}
}
Aggregations