Skip to content

Commit

Permalink
Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
beliefer committed Feb 10, 2020
1 parent c87069f commit 5b3caa9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,16 @@ case class NthValue(input: Expression, offset: Expression)
val check = super.checkInputDataTypes()
if (check.isFailure) {
check
} else {
} else if (offset.foldable) {
offset.eval() match {
case i: Int if i <= 0 => TypeCheckFailure(
s"The 'offset' argument of nth_value must be greater than zero but it is $i.")
case i: Int => TypeCheckSuccess
case other => TypeCheckFailure(
s"The 'offset' parameter must be a int literal but it is $other.")
}
} else {
TypeCheckFailure("The 'offset' parameter must be a int literal.")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ class OffsetWindowFunctionFrame(
override def currentUpperBound(): Int = throw new UnsupportedOperationException()
}

/**
* The fixed offset window frame calculates frames containing
* NTH_VALUE/FIRST_VALUE/LAST_VALUE statements.
* The fixed offset windwo frame return the same value for all rows in the window partition.
*/
class FixedOffsetWindowFunctionFrame(
target: InternalRow,
ordinal: Int,
Expand Down

0 comments on commit 5b3caa9

Please sign in to comment.