Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hotfix] [table] Fix IndexOutOfBoundsException in DataStreamSortRule. #5370

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class DataStreamSortRule
def checkTimeOrder(sort: FlinkLogicalSort): Boolean = {

val sortCollation = sort.collation
if (sortCollation.getFieldCollations.size() == 0) {
// no sort fields defined
return false
}
// get type of first sort field
val firstSortType = SortUtil.getFirstSortField(sortCollation, sort.getRowType).getType
// get direction of first sort field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.apache.flink.table.api.TableException
import org.apache.flink.table.calcite.FlinkTypeFactory
import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.table.plan.schema.RowSchema
import org.apache.flink.util.Preconditions

import java.util.Comparator

Expand All @@ -60,6 +61,7 @@ object SortUtil {
inputTypeInfo: TypeInformation[Row],
execCfg: ExecutionConfig): ProcessFunction[CRow, CRow] = {

Preconditions.checkArgument(collationSort.getFieldCollations.size() > 0)
val rowtimeIdx = collationSort.getFieldCollations.get(0).getFieldIndex

val collectionRowComparator = if (collationSort.getFieldCollations.size() > 1) {
Expand Down Expand Up @@ -158,6 +160,7 @@ object SortUtil {
* @return The direction of the first sort field.
*/
def getFirstSortDirection(collationSort: RelCollation): Direction = {
Preconditions.checkArgument(collationSort.getFieldCollations.size() > 0)
collationSort.getFieldCollations.get(0).direction
}

Expand All @@ -169,6 +172,7 @@ object SortUtil {
* @return The first sort field.
*/
def getFirstSortField(collationSort: RelCollation, rowType: RelDataType): RelDataTypeField = {
Preconditions.checkArgument(collationSort.getFieldCollations.size() > 0)
val idx = collationSort.getFieldCollations.get(0).getFieldIndex
rowType.getFieldList.get(idx)
}
Expand Down