Skip to content

Commit 1fa05b8

Browse files
yaooqinndongjoon-hyun
authored andcommitted
[SPARK-51777][SQL][CORE] Register sql.columnar.* classes to KryoSerializer
### What changes were proposed in this pull request? Register sql.columnar.* classes to KryoSerializer ### Why are the changes needed? Satisfy cache query cases when `spark.kryo.registrationRequired=true` ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? new ut ### Was this patch authored or co-authored using generative AI tooling? no Closes #50566 from yaooqinn/SPARK-51777. Authored-by: Kent Yao <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent b9dbf8b commit 1fa05b8

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ private[serializer] object KryoSerializer {
573573
"org.apache.spark.sql.catalyst.expressions.BoundReference",
574574
"org.apache.spark.sql.catalyst.expressions.SortOrder",
575575
"[Lorg.apache.spark.sql.catalyst.expressions.SortOrder;",
576+
"org.apache.spark.sql.catalyst.expressions.GenericInternalRow",
576577
"org.apache.spark.sql.catalyst.InternalRow",
577578
"org.apache.spark.sql.catalyst.InternalRow$",
578579
"[Lorg.apache.spark.sql.catalyst.InternalRow;",
@@ -607,6 +608,12 @@ private[serializer] object KryoSerializer {
607608
"org.apache.spark.sql.execution.joins.LongHashedRelation",
608609
"org.apache.spark.sql.execution.joins.LongToUnsafeRowMap",
609610
"org.apache.spark.sql.execution.joins.UnsafeHashedRelation",
611+
"org.apache.spark.sql.columnar.CachedBatch",
612+
"org.apache.spark.sql.columnar.SimpleMetricsCachedBatch",
613+
"org.apache.spark.sql.execution.columnar.DefaultCachedBatch",
614+
"org.apache.spark.sql.columnar.CachedBatchSerializer",
615+
"org.apache.spark.sql.columnar.SimpleMetricsCachedBatchSerializer",
616+
"org.apache.spark.sql.execution.columnar.DefaultCachedBatchSerializer",
610617

611618
"org.apache.spark.ml.attribute.Attribute",
612619
"org.apache.spark.ml.attribute.AttributeGroup",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.sql
19+
20+
import org.apache.spark.SparkConf
21+
import org.apache.spark.sql.test.{SharedSparkSession, SQLTestUtils}
22+
import org.apache.spark.storage.StorageLevel
23+
24+
class CacheTableInKryoSuite extends QueryTest
25+
with SQLTestUtils
26+
with SharedSparkSession {
27+
28+
override def sparkConf: SparkConf = {
29+
super.sparkConf
30+
.set("spark.kryo.registrationRequired", "true")
31+
.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
32+
}
33+
34+
test("SPARK-51777: sql.columnar.* classes registered in KryoSerializer") {
35+
withTable("t1") {
36+
sql("CREATE TABLE t1 AS SELECT 1 AS a")
37+
checkAnswer(sql("SELECT * FROM t1").persist(StorageLevel.DISK_ONLY), Seq(Row(1)))
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)