Skip to content
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 @@ -45,12 +45,12 @@ case class TimeWindow(
slideDuration: Expression,
startTime: Expression) = {
this(timeColumn, TimeWindow.parseExpression(windowDuration),
TimeWindow.parseExpression(windowDuration), TimeWindow.parseExpression(startTime))
TimeWindow.parseExpression(slideDuration), TimeWindow.parseExpression(startTime))
}

def this(timeColumn: Expression, windowDuration: Expression, slideDuration: Expression) = {
this(timeColumn, TimeWindow.parseExpression(windowDuration),
TimeWindow.parseExpression(windowDuration), 0)
TimeWindow.parseExpression(slideDuration), 0)
}

def this(timeColumn: Expression, windowDuration: Expression) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,16 @@ class TimeWindowSuite extends SparkFunSuite with ExpressionEvalHelper with Priva
TimeWindow.invokePrivate(parseExpression(Rand(123)))
}
}

test("SPARK-16837: TimeWindow.apply equivalent to TimeWindow constructor") {
val slideLength = "1 second"
for (windowLength <- Seq("10 second", "1 minute", "2 hours")) {
val applyValue = TimeWindow(Literal(10L), windowLength, slideLength, "0 seconds")
val constructed = new TimeWindow(Literal(10L),
Literal(windowLength),
Literal(slideLength),
Literal("0 seconds"))
assert(applyValue == constructed)
}
}
}