Skip to content

Commit

Permalink
override clone for String.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhuai committed Sep 2, 2015
1 parent fc48307 commit 1469cb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Expand Up @@ -339,6 +339,8 @@ private[sql] object STRING extends NativeColumnType(StringType, 7, 8) {
override def copyField(from: InternalRow, fromOrdinal: Int, to: MutableRow, toOrdinal: Int) {
setField(to, toOrdinal, getField(from, fromOrdinal))
}

override def clone(v: UTF8String): UTF8String = v.clone()
}

private[sql] object DATE extends NativeColumnType(DateType, 8, 4) {
Expand Down
Expand Up @@ -191,4 +191,13 @@ class InMemoryColumnarQuerySuite extends QueryTest with SharedSQLContext {
ctx.table("InMemoryCache_different_data_types").collect())
ctx.dropTempTable("InMemoryCache_different_data_types")
}

test("SPARK-10422: String column in InMemoryColumnarCache needs to override clone method") {
val df =
ctx.range(1, 30000).selectExpr("id % 500 as id").rdd.map(id => Tuple1(s"str_$id")).toDF("i")
val cached = df.cache()
// count triggers the caching action. It should not throw.
cached.count()
cached.unpersist()
}
}

0 comments on commit 1469cb0

Please sign in to comment.