You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by tdas <gi...@git.apache.org> on 2016/12/16 03:23:15 UTC

[GitHub] spark pull request #16304: [SPARK-18894][SS] Follow-up bug fix

GitHub user tdas opened a pull request:

    https://github.com/apache/spark/pull/16304

    [SPARK-18894][SS] Follow-up bug fix

    ## What changes were proposed in this pull request?
    
    Two changes 
    - Disallow went time watermark delay threshold be specified in months or years
    - Following up on #16258, not show watermark when there is no watermarking in the query
    
    ## How was this patch tested?
    Updated and new unit tests


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tdas/spark SPARK-18834-1

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/16304.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #16304
    
----
commit 7fc341195f6cd348d7745646b06e381dc79fe081
Author: Tathagata Das <ta...@gmail.com>
Date:   2016-12-16T02:45:51Z

    No event time stats when no watermark is set

commit 33a7d1b84266b0d50f7bd1cc4e5bb47226d043cd
Author: Tathagata Das <ta...@gmail.com>
Date:   2016-12-16T03:18:18Z

    Disallow dfelay threshold in months or years

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Disallow went time watermark de...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r92753590
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
    @@ -572,6 +572,10 @@ class Dataset[T] private[sql](
         val parsedDelay =
           Option(CalendarInterval.fromString("interval " + delayThreshold))
             .getOrElse(throw new AnalysisException(s"Unable to parse time delay '$delayThreshold'"))
    +    // Threshold specified in months/years is non-deterministic
    --- End diff --
    
    I think waiting 1 month for late data is a reasonable use case. Based on the definition of the watermark, its actually okay for us to over estimate this delay too.  Why not take take the max (31 days, leap year)?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70282 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70282/testReport)** for PR 16304 at commit [`736c903`](https://github.com/apache/spark/commit/736c9038f67941b438b14e052a8aa232c1ec7755).
     * This patch **fails from timeout after a configured wait of \`250m\`**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/70282/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/70420/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/70284/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Disallow went time watermark delay thr...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/70233/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70420 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70420/testReport)** for PR 16304 at commit [`debc748`](https://github.com/apache/spark/commit/debc748ceac73fcb1e235a1952b0832df658e95d).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Disallow went time watermark delay thr...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    fyi the title has a typo


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70420 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70420/testReport)** for PR 16304 at commit [`debc748`](https://github.com/apache/spark/commit/debc748ceac73fcb1e235a1952b0832df658e95d).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Disallow went time watermark de...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r92753969
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
    @@ -572,6 +572,10 @@ class Dataset[T] private[sql](
         val parsedDelay =
           Option(CalendarInterval.fromString("interval " + delayThreshold))
             .getOrElse(throw new AnalysisException(s"Unable to parse time delay '$delayThreshold'"))
    +    // Threshold specified in months/years is non-deterministic
    --- End diff --
    
    what does "safe" mean in this context?  users must not rely on watermarks for correctness as they can be arbitrarily delayed based on batch boundaries.  I think this error actually confuses the point as its is enforcing precision when this API cannot provide that.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r92902755
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala ---
    @@ -124,6 +137,29 @@ class WatermarkSuite extends StreamTest with BeforeAndAfter with Logging {
         )
       }
     
    +  test("delay in years handled correctly") {
    +    val input = MemoryStream[Long]
    +    val aggWithWatermark = input.toDF()
    +      .withColumn("eventTime", $"value".cast("timestamp"))
    +      .withWatermark("eventTime", "1 month")
    --- End diff --
    
    This seems to be testing months, but the title says years?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    LGTM


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r92903733
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala ---
    @@ -124,6 +137,29 @@ class WatermarkSuite extends StreamTest with BeforeAndAfter with Logging {
         )
       }
     
    +  test("delay in years handled correctly") {
    +    val input = MemoryStream[Long]
    +    val aggWithWatermark = input.toDF()
    +      .withColumn("eventTime", $"value".cast("timestamp"))
    +      .withWatermark("eventTime", "1 month")
    --- End diff --
    
    yeah. sorry .. i pushed too early. i updated the test now.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Disallow went time watermark de...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r92746039
  
    --- Diff: common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java ---
    @@ -252,6 +252,9 @@ public static long parseSecondNano(String secondNano) throws IllegalArgumentExce
       public final int months;
       public final long microseconds;
     
    +  /**
    +   * Return the interval in miliseconds, not including the months in interval.
    +   */
       public final long milliseconds() {
    --- End diff --
    
    @rxin Documented as per your requets 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Disallow went time watermark delay thr...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    event time?



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Disallow went time watermark delay thr...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70233 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70233/testReport)** for PR 16304 at commit [`8c603f4`](https://github.com/apache/spark/commit/8c603f46deb7021c9c2b6297be532342d2d8bfab).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Disallow went time watermark delay thr...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70233 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70233/testReport)** for PR 16304 at commit [`8c603f4`](https://github.com/apache/spark/commit/8c603f46deb7021c9c2b6297be532342d2d8bfab).
     * This patch **fails from timeout after a configured wait of \`250m\`**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70449 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70449/testReport)** for PR 16304 at commit [`29f0037`](https://github.com/apache/spark/commit/29f0037631399bf2226ff3c2e630e4927e177eb4).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70284 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70284/testReport)** for PR 16304 at commit [`40c200f`](https://github.com/apache/spark/commit/40c200fe12aab4d5f7b1f42f2164e0373988ff63).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r94288180
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala ---
    @@ -124,6 +137,33 @@ class WatermarkSuite extends StreamTest with BeforeAndAfter with Logging {
         )
       }
     
    +  test("delay in months and years handled correctly") {
    +    val currentTimeMs = System.currentTimeMillis
    +    val currentTime = new Date(currentTimeMs)
    +
    +    val input = MemoryStream[Long]
    +    val aggWithWatermark = input.toDF()
    +      .withColumn("eventTime", $"value".cast("timestamp"))
    +      .withWatermark("eventTime", "2 years 5 months")
    +      .groupBy(window($"eventTime", "5 seconds") as 'window)
    +      .agg(count("*") as 'count)
    +      .select($"window".getField("start").cast("long").as[Long], $"count".as[Long])
    +
    +    def monthsSinceEpoch(date: Date): Int = { date.getYear * 12 + date.getMonth }
    +
    +    testStream(aggWithWatermark)(
    +      AddData(input, currentTimeMs / 1000),
    +      CheckAnswer(),
    +      AddData(input, currentTimeMs / 1000),
    +      CheckAnswer(),
    +      assertEventStats { e =>
    +        assert(timestampFormat.parse(e.get("max")).getTime === (currentTimeMs / 1000) * 1000)
    +        val watermarkTime = timestampFormat.parse(e.get("watermark"))
    +        assert(monthsSinceEpoch(currentTime) - monthsSinceEpoch(watermarkTime) === 29)
    --- End diff --
    
    Thanks for reporting it. Working on a PR.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r94288555
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala ---
    @@ -124,6 +137,33 @@ class WatermarkSuite extends StreamTest with BeforeAndAfter with Logging {
         )
       }
     
    +  test("delay in months and years handled correctly") {
    +    val currentTimeMs = System.currentTimeMillis
    +    val currentTime = new Date(currentTimeMs)
    +
    +    val input = MemoryStream[Long]
    +    val aggWithWatermark = input.toDF()
    +      .withColumn("eventTime", $"value".cast("timestamp"))
    +      .withWatermark("eventTime", "2 years 5 months")
    +      .groupBy(window($"eventTime", "5 seconds") as 'window)
    +      .agg(count("*") as 'count)
    +      .select($"window".getField("start").cast("long").as[Long], $"count".as[Long])
    +
    +    def monthsSinceEpoch(date: Date): Int = { date.getYear * 12 + date.getMonth }
    +
    +    testStream(aggWithWatermark)(
    +      AddData(input, currentTimeMs / 1000),
    +      CheckAnswer(),
    +      AddData(input, currentTimeMs / 1000),
    +      CheckAnswer(),
    +      assertEventStats { e =>
    +        assert(timestampFormat.parse(e.get("max")).getTime === (currentTimeMs / 1000) * 1000)
    +        val watermarkTime = timestampFormat.parse(e.get("watermark"))
    +        assert(monthsSinceEpoch(currentTime) - monthsSinceEpoch(watermarkTime) === 29)
    --- End diff --
    
    Fixing in #16449


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/70449/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Disallow went time watermark delay thr...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Disallow went time watermark de...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r92754420
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
    @@ -572,6 +572,10 @@ class Dataset[T] private[sql](
         val parsedDelay =
           Option(CalendarInterval.fromString("interval " + delayThreshold))
             .getOrElse(throw new AnalysisException(s"Unable to parse time delay '$delayThreshold'"))
    +    // Threshold specified in months/years is non-deterministic
    --- End diff --
    
    when i have a record that's 29 days late in feb what should I expect? If we want to just change month to a fix number of days, I'd say just use 30, and then document it clearly in the API (e.g. "if month is specified, 1 month = 30 days").


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r92904102
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala ---
    @@ -124,6 +137,29 @@ class WatermarkSuite extends StreamTest with BeforeAndAfter with Logging {
         )
       }
     
    +  test("delay in years handled correctly") {
    +    val input = MemoryStream[Long]
    +    val aggWithWatermark = input.toDF()
    +      .withColumn("eventTime", $"value".cast("timestamp"))
    +      .withWatermark("eventTime", "1 month")
    --- End diff --
    
    Just wanted to make sure I wasn't missing something :)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r94287885
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala ---
    @@ -124,6 +137,33 @@ class WatermarkSuite extends StreamTest with BeforeAndAfter with Logging {
         )
       }
     
    +  test("delay in months and years handled correctly") {
    +    val currentTimeMs = System.currentTimeMillis
    +    val currentTime = new Date(currentTimeMs)
    +
    +    val input = MemoryStream[Long]
    +    val aggWithWatermark = input.toDF()
    +      .withColumn("eventTime", $"value".cast("timestamp"))
    +      .withWatermark("eventTime", "2 years 5 months")
    +      .groupBy(window($"eventTime", "5 seconds") as 'window)
    +      .agg(count("*") as 'count)
    +      .select($"window".getField("start").cast("long").as[Long], $"count".as[Long])
    +
    +    def monthsSinceEpoch(date: Date): Int = { date.getYear * 12 + date.getMonth }
    +
    +    testStream(aggWithWatermark)(
    +      AddData(input, currentTimeMs / 1000),
    +      CheckAnswer(),
    +      AddData(input, currentTimeMs / 1000),
    +      CheckAnswer(),
    +      assertEventStats { e =>
    +        assert(timestampFormat.parse(e.get("max")).getTime === (currentTimeMs / 1000) * 1000)
    +        val watermarkTime = timestampFormat.parse(e.get("watermark"))
    +        assert(monthsSinceEpoch(currentTime) - monthsSinceEpoch(watermarkTime) === 29)
    --- End diff --
    
    All the recent builds failed in this check.
    ```
    [info] - delay in months and years handled correctly *** FAILED *** (325 milliseconds)
    [info]   30 did not equal 29 (EventTimeWatermarkSuite.scala:193)
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70449 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70449/testReport)** for PR 16304 at commit [`29f0037`](https://github.com/apache/spark/commit/29f0037631399bf2226ff3c2e630e4927e177eb4).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r93364798
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamExecution.scala ---
    @@ -387,7 +387,7 @@ class StreamExecution(
             lastExecution.executedPlan.collect {
               case e: EventTimeWatermarkExec if e.eventTimeStats.value.count > 0 =>
                 logDebug(s"Observed event time stats: ${e.eventTimeStats.value}")
    -            e.eventTimeStats.value.max - e.delay.milliseconds
    +            math.max(0, e.eventTimeStats.value.max - e.delayMs)
    --- End diff --
    
    okay, I think I was doing something to goof up the conversion using SimpleDateFormat. I am fixing that. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r93349575
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamExecution.scala ---
    @@ -387,7 +387,7 @@ class StreamExecution(
             lastExecution.executedPlan.collect {
               case e: EventTimeWatermarkExec if e.eventTimeStats.value.count > 0 =>
                 logDebug(s"Observed event time stats: ${e.eventTimeStats.value}")
    -            e.eventTimeStats.value.max - e.delay.milliseconds
    +            math.max(0, e.eventTimeStats.value.max - e.delayMs)
    --- End diff --
    
    `newWatermarkMs` can be negative. Image the user is processing some very old data which is before 1970.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/16304


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70282 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70282/testReport)** for PR 16304 at commit [`736c903`](https://github.com/apache/spark/commit/736c9038f67941b438b14e052a8aa232c1ec7755).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    LGTM


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Thanks! Merging to master and 2.1.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    **[Test build #70284 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/70284/testReport)** for PR 16304 at commit [`40c200f`](https://github.com/apache/spark/commit/40c200fe12aab4d5f7b1f42f2164e0373988ff63).
     * This patch **fails from timeout after a configured wait of \`250m\`**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #16304: [SPARK-18894][SS] Fix event time watermark delay thresho...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/16304
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r93357063
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamExecution.scala ---
    @@ -387,7 +387,7 @@ class StreamExecution(
             lastExecution.executedPlan.collect {
               case e: EventTimeWatermarkExec if e.eventTimeStats.value.count > 0 =>
                 logDebug(s"Observed event time stats: ${e.eventTimeStats.value}")
    -            e.eventTimeStats.value.max - e.delay.milliseconds
    +            math.max(0, e.eventTimeStats.value.max - e.delayMs)
    --- End diff --
    
    It sounds like a SQL bug. IMO, a negative timestamp is valid, it's not a negative date, just a date before 1970.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r93353338
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamExecution.scala ---
    @@ -387,7 +387,7 @@ class StreamExecution(
             lastExecution.executedPlan.collect {
               case e: EventTimeWatermarkExec if e.eventTimeStats.value.count > 0 =>
                 logDebug(s"Observed event time stats: ${e.eventTimeStats.value}")
    -            e.eventTimeStats.value.max - e.delay.milliseconds
    +            math.max(0, e.eventTimeStats.value.max - e.delayMs)
    --- End diff --
    
    i think a lot of things are going to break for that usecase. I dont think our sql functions, Java time format, etc are even designed to handle negative millis. The way I found this issue is that when i tried for convert -ve watermark to formatted string, it gave a very weird date. So I dont think we should add complexity for that use case. 
    @marmbrus any thoughts?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Fix event time watermark delay ...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r93355210
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamExecution.scala ---
    @@ -387,7 +387,7 @@ class StreamExecution(
             lastExecution.executedPlan.collect {
               case e: EventTimeWatermarkExec if e.eventTimeStats.value.count > 0 =>
                 logDebug(s"Observed event time stats: ${e.eventTimeStats.value}")
    -            e.eventTimeStats.value.max - e.delay.milliseconds
    +            math.max(0, e.eventTimeStats.value.max - e.delayMs)
    --- End diff --
    
    Im not totally sure, but it does seem likely that we don't handle negative dates (and that is probably okay).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #16304: [SPARK-18894][SS] Disallow went time watermark de...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16304#discussion_r92756861
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
    @@ -572,6 +572,10 @@ class Dataset[T] private[sql](
         val parsedDelay =
           Option(CalendarInterval.fromString("interval " + delayThreshold))
             .getOrElse(throw new AnalysisException(s"Unable to parse time delay '$delayThreshold'"))
    +    // Threshold specified in months/years is non-deterministic
    --- End diff --
    
    sgtm


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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