Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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 @@ -207,4 +207,7 @@ case class InMemoryRelation(
}

override protected def otherCopyArgs: Seq[AnyRef] = Seq(statsOfPlanToCache)

override def simpleString: String = s"InMemoryRelation(${output}, ${cacheBuilder.storageLevel})"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about s"InMemoryRelation [${Utils.truncatedString(output, ", ")}], ${cacheBuilder.storageLevel}"?


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: remove the blank line

}
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,20 @@ class DatasetCacheSuite extends QueryTest with SharedSQLContext with TimeLimits
// first time use, load cache
checkDataset(df5, Row(10))
}

test("SPARK-24850 InMemoryRelation string representation does not include cached plan") {
val dummyQueryExecution = spark.range(0, 1).toDF().queryExecution
val inMemoryRelation = InMemoryRelation(
true,
1000,
StorageLevel.MEMORY_ONLY,
dummyQueryExecution.sparkPlan,
Some("test-relation"),
dummyQueryExecution.logical)

assert(!inMemoryRelation.simpleString.contains(dummyQueryExecution.sparkPlan.toString))
assert(inMemoryRelation.simpleString ==
s"InMemoryRelation(${inMemoryRelation.output},"
+ " StorageLevel(memory, deserialized, 1 replicas))")
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about just comparing explain results?

    val df = Seq((1, 2)).toDF("a", "b").cache
    val outputStream = new java.io.ByteArrayOutputStream()
    Console.withOut(outputStream) {
      df.explain(false)
    }
    assert(outputStream.toString.replaceAll("#\\d+", "#x").contains(
      "InMemoryRelation [a#x, b#x], StorageLevel(disk, memory, deserialized, 1 replicas)"))

}