Github user raghavgautam commented on a diff in the pull request:
https://github.com/apache/spark/pull/22414#discussion_r220380561
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/TimeWindow.scala
---
@@ -137,16 +139,42 @@ object TimeWindow {
"an integer, long or string literal.")
}
+ private def parseWindowDuration(windowDuration: Expression): Long = {
+ val windowDurationMicroSec = parseExpression(windowDuration)
+ require(windowDurationMicroSec > 0, "The window duration must be " +
+ s"a positive integer, long or string literal, found:
$windowDuration")
+ windowDurationMicroSec
+ }
+
+ private def parseSlideDuration(slideDuration: Expression): Long = {
+ val slideDurationMicroSec = parseExpression(slideDuration)
+ require(slideDurationMicroSec > 0, "The slide duration must be " +
+ s"a positive integer, long or string literal, found: $slideDuration")
+ slideDurationMicroSec
+ }
+
def apply(
timeColumn: Expression,
windowDuration: String,
slideDuration: String,
startTime: String): TimeWindow = {
+ val windowDurationMicroSec = getIntervalInMicroSeconds(windowDuration)
+ val slideDurationMicroSec = getIntervalInMicroSeconds(slideDuration)
+ checkWindowAndSlideDuration(windowDurationMicroSec,
slideDurationMicroSec,
+ windowDuration, slideDuration)
TimeWindow(timeColumn,
- getIntervalInMicroSeconds(windowDuration),
- getIntervalInMicroSeconds(slideDuration),
+ windowDurationMicroSec,
+ slideDurationMicroSec,
getIntervalInMicroSeconds(startTime))
}
+
+ private def checkWindowAndSlideDuration(windowDurationMicroSec: Long,
slideDurationMicroSec: Long,
+ windowDuration: Any,
slideDuration: Any): Unit = {
--- End diff --
Done.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]