tkaymak opened a new pull request, #41596: URL: https://github.com/apache/beam/pull/41596
Fixes #41466, part of #36841. On Spark 4 `Combine.perKey` fails in batch with `INTERNAL_ERROR Couldn't find method fromByteArray` when the key coder has no native Spark encoder, for example a `KV` or a `Void` key. The Spark 4 `EncoderFactory` marked every Beam encoder as `AgnosticEncoders.StructEncoder`, also the ones that serialize to a single `BinaryType` column. Spark 3 decided this from the serializer, `TypedAggUtils.aggKeyColumn` checked `isSerializedAsStructForTopLevel`. Spark 4 asks the encoder. It checks `isStruct`, wraps the binary grouping key in `CreateStruct`, and the key deserializer then calls `CoderHelpers.fromByteArray` with an `InternalRow`. Now only encoders whose serializer is a `StructType` implement `StructEncoder`, the same condition Spark 3 used. Struct encoders behave as before, so `Dataset.select(TypedColumn)` still flattens their fields. Spark 3 builds its `ExpressionEncoder` from the serializer and needs no change. The new `EncoderHelpersTest` case groups by a `KvCoder` key and counts. It fails on master with the error above and passes now. `CombineTest$BasicTests.testHotKeyCombining` failed with the same error on Spark 4 batch and passes now, its exclusion is removed. It stays excluded in the streaming suite under #41199, a different cause. Locally the batch Structured Streaming suite on Spark 4 runs 311 tests with 0 failures, before it ran 310. The streaming suite runs 212 tests with 0 failures, as on master, and the full `:runners:spark:4:test` passes. The Spark4 trigger file runs the suites here. Merge order: it bumps the same Spark4 trigger line as #41426, whichever lands later rebases. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
