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-48794][CONNECT] df.mergeInto support for Spark Connect (Scala and Python) #46960

Closed
wants to merge 19 commits into from

Conversation

xupefei
Copy link
Contributor

@xupefei xupefei commented Jun 12, 2024

What changes were proposed in this pull request?

This PR introduces df.mergeInto support for Spark Connect Scala and Python clients.

This work contains four components:

  1. New Protobuf messages: command MergeIntoTableCommand and expression MergeAction.
  2. Spark Connect planner change: translate proto messages into real MergeIntoCommands.
  3. Connect Scala client: MetgeIntoWriter that allows users to build merges.
  4. Connect Python client: MetgeIntoWriter that allows users to build merges.

Components 3 and 4 and independent to each other. They both depends on Component 1.

Why are the changes needed?

We need to increase the functionality of Spark Connect to be on par with Classic.

Does this PR introduce any user-facing change?

Yes, new Dataframe APIs are introduced.

How was this patch tested?

Added new tests.

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

No.

@xupefei xupefei marked this pull request as ready for review June 19, 2024 14:45
HyukjinKwon pushed a commit that referenced this pull request Jul 3, 2024
### What changes were proposed in this pull request?

Spark 4.0 added a new `df.mergeInto` API, but it is missing from PySpark. This PR fixes that.
The support for this API in Spark Connect Python API will be added later by #46960.

### Why are the changes needed?

Because PySpark does not support `df.mergeInto`.

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

Yes, the user would be able to use the `df.mergeInto` API.

### How was this patch tested?

New unit tests.

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

No.

Closes #47086 from xupefei/pyspark-mergeinto.

Authored-by: Paddy Xu <xupaddy@gmail.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
# Conflicts:
#	python/pyspark/sql/connect/proto/expressions_pb2.py
@xupefei xupefei changed the title [Connect][WIP] Dataset.mergeInto [Connect][SPARK-48794] df.mergeInto support for Spark Connect (Scala and Python) Jul 3, 2024
@xupefei
Copy link
Contributor Author

xupefei commented Jul 3, 2024

@HyukjinKwon and @grundprinzip Could you review this PR? Thanks!

@xupefei xupefei changed the title [Connect][SPARK-48794] df.mergeInto support for Spark Connect (Scala and Python) [SPARK-48794][Connect] df.mergeInto support for Spark Connect (Scala and Python) Jul 3, 2024
@HyukjinKwon HyukjinKwon changed the title [SPARK-48794][Connect] df.mergeInto support for Spark Connect (Scala and Python) [SPARK-48794][CONNECT] df.mergeInto support for Spark Connect (Scala and Python) Jul 3, 2024
Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine otherwise


// (Required) Whether to enable schema evolution.
bool with_schema_evolution = 7;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need some reviews from @hvanhovell and/or @grundprinzip

@HyukjinKwon
Copy link
Member

cc @zhengruifeng and @ueshin too

@github-actions github-actions bot added the BUILD label Jul 4, 2024
@xupefei xupefei requested a review from HyukjinKwon July 4, 2024 09:52
ericm-db pushed a commit to ericm-db/spark that referenced this pull request Jul 10, 2024
### What changes were proposed in this pull request?

Spark 4.0 added a new `df.mergeInto` API, but it is missing from PySpark. This PR fixes that.
The support for this API in Spark Connect Python API will be added later by apache#46960.

### Why are the changes needed?

Because PySpark does not support `df.mergeInto`.

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

Yes, the user would be able to use the `df.mergeInto` API.

### How was this patch tested?

New unit tests.

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

No.

Closes apache#47086 from xupefei/pyspark-mergeinto.

Authored-by: Paddy Xu <xupaddy@gmail.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
@HyukjinKwon
Copy link
Member

@xupefei mind resolving conflicts? I will just merge

@xupefei
Copy link
Contributor Author

xupefei commented Jul 12, 2024

@xupefei mind resolving conflicts? I will just merge

Done!

@HyukjinKwon
Copy link
Member

Merged to master.

@xupefei xupefei deleted the merge-builder branch July 12, 2024 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants