Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17179#discussion_r106568279
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/KeyedStateImpl.scala
 ---
    @@ -60,6 +82,45 @@ private[sql] class KeyedStateImpl[S](optionalValue: 
Option[S]) extends KeyedStat
         defined = false
         updated = false
         removed = true
    +    timeoutTimestamp = TIMEOUT_TIMESTAMP_NOT_SET
    +  }
    +
    +  override def setTimeoutDuration(durationMs: Long): Unit = {
    +    if (!isTimeoutEnabled) {
    +      throw new UnsupportedOperationException(
    +        "Cannot set timeout duration without enabling timeout in 
map/flatMapGroupsWithState")
    +    }
    +    if (durationMs <= 0) {
    +      throw new IllegalArgumentException("Timeout duration must be 
positive")
    +    }
    +    if (!removed && batchProcessingTimeMs != 
NO_BATCH_PROCESSING_TIMESTAMP) {
    +      timeoutTimestamp = durationMs + batchProcessingTimeMs
    +    } else {
    +      // This is being called in a batch query, hence no processing 
timestamp.
    +      // Just ignore any attempts to set timeout.
    +    }
    +  }
    +
    +  override def setTimeoutDuration(duration: String): Unit = {
    +    if (StringUtils.isBlank(duration)) {
    +      throw new IllegalArgumentException(
    +        "The window duration, slide duration and start time cannot be null 
or blank.")
    +    }
    +    val intervalString = if (duration.startsWith("interval")) {
    +      duration
    +    } else {
    +      "interval " + duration
    +    }
    +    val cal = CalendarInterval.fromString(intervalString)
    +    if (cal == null) {
    +      throw new IllegalArgumentException(
    +        s"The provided duration ($duration) is not valid.")
    +    }
    +    val delayMs = {
    --- End diff --
    
    Added checks and tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to