Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-48113][CONNECT] Allow Plugins to integrate with Spark Connect #46364

Closed
wants to merge 6 commits into from

Conversation

tomvanbussel
Copy link
Contributor

What changes were proposed in this pull request?

This PR enables Spark Connect plugins to process Relations and Expressions using SparkConnectPlanner on the server side and to create DataFrames using Relations on the client side. This has been difficult due to the shading of the protobuf libraries, which meant that Java classes generated for the plugin's Protobuf message usage different base classes than the Java classes for Spark's protobuf messages. This was previously worked around by adding methods that accept a byte array (containing a serialized protobuf message) instead of a protobuf message. Unfortunately, this was not scalable as a lot of methods (such as DataTypeProtoConverter.toCatalystType) did not have this alternative. Luckily, we can avoid having to do this as the generated Java classes are not shaded and can still be used from plugins. Instead, plugins should serialize their own version of the generated Java classes for Spark Connect's protobuf messages and then parse them using Spark's (using the ConnectProtoUtils added in this PR).

Why are the changes needed?

Enable the development of Spark Connect plugins.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existing tests

Was this patch authored or co-authored using generative AI tooling?

No

@dongjoon-hyun
Copy link
Member

Could you re-trigger CIs, @tomvanbussel ?

@HyukjinKwon
Copy link
Member

Merged to master.

JacobZheng0927 pushed a commit to JacobZheng0927/spark that referenced this pull request May 11, 2024
### What changes were proposed in this pull request?

This PR enables Spark Connect plugins to process `Relation`s and `Expression`s using `SparkConnectPlanner` on the server side and to create `DataFrame`s using `Relation`s on the client side. This has been difficult due to the shading of the protobuf libraries, which meant that Java classes generated for the plugin's Protobuf message usage different base classes than the Java classes for Spark's protobuf messages. This was previously worked around by adding methods that accept a byte array (containing a serialized protobuf message) instead of a protobuf message. Unfortunately, this was not scalable as a lot of methods (such as `DataTypeProtoConverter.toCatalystType`) did not have this alternative. Luckily, we can avoid having to do this as the generated Java classes are not shaded and can still be used from plugins. Instead, plugins should serialize their own version of the generated Java classes for Spark Connect's protobuf messages and then parse them using Spark's (using the `ConnectProtoUtils` added in this PR).

### Why are the changes needed?

Enable the development of Spark Connect plugins.

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Existing tests

### Was this patch authored or co-authored using generative AI tooling?

No

Closes apache#46364 from tomvanbussel/SPARK-48113.

Authored-by: Tom van Bussel <tom.vanbussel@databricks.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
@nchammas
Copy link
Contributor

What's a Spark Connect Plugin? And where can we read some documentation about how to create one?

I see there is this blog post describing how to extend Spark Connect, but I assume we have (or should have) our own documentation about this, no?

@nchammas
Copy link
Contributor

Looks like the docs I am looking for are in #45340.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants