Skip to content

Commit

Permalink
Fix check index when has index column or not
Browse files Browse the repository at this point in the history
  • Loading branch information
tobegit3hub committed Mar 23, 2022
1 parent 9494cfc commit a415b92
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,25 @@ object ExpressionUtil {
throw new IndexOutOfBoundsException(
s"${expr.GetExprString()} resolved index out of bound: $colIndex")
}
if (colIndex < leftDf.schema.size) {
// Get from left df
SparkColumnUtil.getColumnFromIndex(leftDf, colIndex)

if (hasIndexColumn) {
if (colIndex < leftDf.schema.size - 1) {
// Get from left df
SparkColumnUtil.getColumnFromIndex(leftDf, colIndex)
} else {
// Get from right df
val rightColIndex = colIndex - (leftDf.schema.size - 1)
SparkColumnUtil.getColumnFromIndex(rightDf, rightColIndex)
}
} else {
// Get from right df
val rightColIndex = if (hasIndexColumn) {
colIndex - (leftDf.schema.size - 1)
if (colIndex < leftDf.schema.size) {
// Get from left df
SparkColumnUtil.getColumnFromIndex(leftDf, colIndex)
} else {
colIndex - leftDf.schema.size
// Get from right df
val rightColIndex = colIndex - leftDf.schema.size
SparkColumnUtil.getColumnFromIndex(rightDf, rightColIndex)
}
SparkColumnUtil.getColumnFromIndex(rightDf, rightColIndex)
}

case ExprType.kExprPrimary =>
Expand Down

0 comments on commit a415b92

Please sign in to comment.