Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Address comments
  • Loading branch information
lw-lin committed Nov 6, 2016
commit a7a6f6bbe3d7b4245a1a568cd16332ce6af61e73
Original file line number Diff line number Diff line change
Expand Up @@ -187,29 +187,20 @@ class MemorySinkSuite extends StreamTest with BeforeAndAfter {
query.stop()
}

test("MemoryPlan statistics for joining") {
val input = MemoryStream[Int]
val query = input.toDF()
.writeStream
.format("memory")
.queryName("memStream")
.start()

val memStream = spark.table("memStream").as[Int]
test("MemoryPlan statistics") {
implicit val schema = new StructType().add(new StructField("value", IntegerType))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! This will be much faster than a test where we actually join DataFrames.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to do this

val sink = new MemorySink(schema, InternalOutputModes.Append)
val plan = new MemoryPlan(sink)

input.addData(1)
query.processAllAvailable()
checkDatasetUnorderly(
memStream.crossJoin(memStream.withColumnRenamed("value", "value2")).as[(Int, Int)],
(1, 1))
// Before adding data, check output
checkAnswer(sink.allData, Seq.empty)
assert(plan.statistics.sizeInBytes === 0)

input.addData(2)
query.processAllAvailable()
checkDatasetUnorderly(
memStream.crossJoin(memStream.withColumnRenamed("value", "value2")).as[(Int, Int)],
(1, 1), (1, 2), (2, 1), (2, 2))
sink.addBatch(0, 1 to 3)
assert(plan.statistics.sizeInBytes === 12)

query.stop()
sink.addBatch(1, 4 to 6)
assert(plan.statistics.sizeInBytes === 24)
}

ignore("stress test") {
Expand Down