Commit e3569ba
[SPARK-52819][SQL] Making KryoSerializationCodec serializable to fix java.io.NotSerializableException errors in various use cases
### What changes were proposed in this pull request?
This PR makes `KryoSerializationCodec` implements `java.io.Serializable` to avoid `java.io.NotSerializableException` exceptions when using Kryo encoder in `Dataset.flatMapGroupsWithState` or `Aggregator.bufferEncoder`.
### Why are the changes needed?
See the description in [SPARK-52819](https://issues.apache.org/jira/browse/SPARK-52819) as well as the [minimal repro](https://github.com/Kontinuation/spark-4-kryo-encoder-bug). The problems only happens when using Spark 4.0.0 but not when using Spark 3.5.5.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
New tests were added to ensure that
1. Both kryo encoder and java serialization encoder are serializable
2. The kryo encoded aggregator buffer use case works
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes apache#51615 from Kontinuation/fix-kryo-codec-serializable.
Authored-by: Kristin Cowalcijk <bo@wherobots.com>
Signed-off-by: Herman van Hövell <herman@databricks.com>1 parent 1413dbb commit e3569ba
File tree
3 files changed
+20
-1
lines changed- sql
- api/src/main/scala/org/apache/spark/sql/catalyst/encoders
- catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders
- core/src/test/scala/org/apache/spark/sql
3 files changed
+20
-1
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
| 615 | + | |
615 | 616 | | |
616 | 617 | | |
617 | 618 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
56 | 67 | | |
57 | 68 | | |
58 | 69 | | |
| |||
1249 | 1260 | | |
1250 | 1261 | | |
1251 | 1262 | | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
1252 | 1270 | | |
0 commit comments