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

    https://github.com/apache/spark/pull/13957#discussion_r69363771
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/TextSocketStreamSuite.scala
 ---
    @@ -85,6 +86,47 @@ class TextSocketStreamSuite extends StreamTest with 
SharedSQLContext with Before
         }
       }
     
    +  test("timestamped usage") {
    +    serverThread = new ServerThread()
    +    serverThread.start()
    +
    +    val provider = new TextSocketSourceProvider
    +    val parameters = Map("host" -> "localhost", "port" -> 
serverThread.port.toString,
    +      "includeTimestamp" -> "true")
    +    val schema = provider.sourceSchema(sqlContext, None, "", parameters)._2
    +    assert(schema === StructType(StructField("value", StringType) ::
    +      StructField("timestamp", TimestampType) :: Nil))
    +
    +    source = provider.createSource(sqlContext, "", None, "", parameters)
    +
    +    failAfter(streamingTimeout) {
    +      serverThread.enqueue("hello")
    +      while (source.getOffset.isEmpty) {
    +        Thread.sleep(10)
    +      }
    +      val offset1 = source.getOffset.get
    +      val batch1 = source.getBatch(None, offset1)
    +      val batch1Seq = batch1.as[(String, Timestamp)].collect().toSeq
    +      assert(batch1Seq.map(_._1) === Seq("hello"))
    +      val batch1Stamp = batch1Seq(0)._2
    +
    +      serverThread.enqueue("world")
    +      while (source.getOffset.get === offset1) {
    +        Thread.sleep(10)
    +      }
    +      val offset2 = source.getOffset.get
    +      val batch2 = source.getBatch(Some(offset1), offset2)
    +      val batch2Seq = batch2.as[(String, Timestamp)].collect().toSeq
    +      assert(batch2Seq.map(_._1) === Seq("world"))
    +      val batch2Stamp = batch2Seq(0)._2
    +      assert(!batch2Stamp.before(batch1Stamp))
    +
    +      // Try stopping the source to make sure this does not block forever.
    +      source.stop()
    +      source = null
    +    }
    +  }
    +
    --- End diff --
    
    add tests below to make sure includeTimestamp errors are checked. 


---
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