You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SPARK-49960][SQL] Custom ExpressionEncoder support and TransformingEncoder fixes
### What changes were proposed in this pull request?
4.0.0-preview2 introduced, as part of SPARK-49025 pr apache#47785, changes which drive ExpressionEncoder derivation purely from AgnosticEncoders. This PR adds a trait:
```scala
DeveloperApi
trait AgnosticExpressionPathEncoder[T]
extends AgnosticEncoder[T] {
def toCatalyst(input: Expression): Expression
def fromCatalyst(inputPath: Expression): Expression
}
```
and hooks in the De/SerializationBuildHelper matches to allow seamless extension of non-connect custom encoders (such as [frameless](https://github.com/typelevel/frameless) or [sparksql-scalapb](https://github.com/scalapb/sparksql-scalapb)).
SPARK-49960 provides the same information.
Additionally this PR provides fixes necessary to use TransformingEncoder as a root encoder with an OptionalEncoder, use as an ArrayType and MapType entry/key.
### Why are the changes needed?
Without this change (or similar) there is no way for custom encoders to integrate with 4.0.0-preview2 derived encoders, something which has worked and devs have benefited from since pre 2.4 days. This stops code such as Dataset.joinWith from deriving a tuple encoder which works (as the provided ExpressionEncoder is now discarded under preview2). Supplying a custom AgnosticEncoder under preview2 also fails as only the preview2 AgnosticEncoders are supported in De/SerializationBuildHelper, triggering a MatchError.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Test was added using a "custom" string encoder and joinWith based on an existing joinWith test. Removing the case statements in either BuildHelper will trigger the MatchError.
### Was this patch authored or co-authored using generative AI tooling?
No
Closesapache#50023 from chris-twiner/temp/expressionEncoder_compat_TransformingEncoder_fixes.
Authored-by: Chris Twiner <[email protected]>
Signed-off-by: Herman van Hovell <[email protected]>
0 commit comments