Skip to content

[SPARK-51079][PYTHON] Support large variable types in pandas UDF, createDataFrame and toPandas with Arrow - #49790

Closed
HyukjinKwon wants to merge 5 commits into
apache:masterfrom
HyukjinKwon:SPARK-39979-followup2
Closed

HyukjinKwon wants to merge 5 commits into
apache:masterfrom
HyukjinKwon:SPARK-39979-followup2

Conversation

@HyukjinKwon

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This PR is a retry of #41569 that implements to use large variable types within PySpark everywhere.

#39572 implemented the core logic but it only supports large variable types in the bold cases below:

  • mapInArrow: JVM -> Python -> JVM
  • Pandas UDF/Function API: JVM -> Python -> JVM
  • createDataFrame with Arrow: Python -> JVM
  • toPandas with Arrow: JVM -> Python

This PR completes them all.

Why are the changes needed?

To consistently support the large variable types.

Does this PR introduce any user-facing change?

spark.sql.execution.arrow.useLargeVarTypes is not released out yet so it doesn't affect any end users.

How was this patch tested?

Existing tests with spark.sql.execution.arrow.useLargeVarTypes enabled.

@HyukjinKwon HyukjinKwon changed the title Support large variable types in pandas UDF, createDataFrame and toPan… [SPARK-51079][PYTHON] Support large variable types in pandas UDF, createDataFrame and toPandas with Arrow Feb 4, 2025
@HyukjinKwon
HyukjinKwon marked this pull request as draft February 4, 2025 09:54
@HyukjinKwon
HyukjinKwon force-pushed the SPARK-39979-followup2 branch 3 times, most recently from 8c1328d to 003587d Compare February 4, 2025 11:03
@github-actions github-actions Bot added the R label Feb 4, 2025
@HyukjinKwon

Copy link
Copy Markdown
Member Author

@Kimahriman FYI

@HyukjinKwon

Copy link
Copy Markdown
Member Author

Seems like panads <> Arrow conversion is fixed in their releases

@HyukjinKwon

Copy link
Copy Markdown
Member Author

cc @ueshin @zhengruifeng too

@HyukjinKwon
HyukjinKwon force-pushed the SPARK-39979-followup2 branch 3 times, most recently from 5aacead to 61f2ea2 Compare February 4, 2025 12:55
Comment thread python/pyspark/worker.py Resolved
Comment thread python/pyspark/worker.py Resolved
Comment thread python/pyspark/worker.py Resolved
@HyukjinKwon
HyukjinKwon force-pushed the SPARK-39979-followup2 branch 4 times, most recently from 58c2d84 to d4d80ff Compare February 5, 2025 01:18
Comment thread python/pyspark/sql/pandas/conversion.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: probably we can also fetch all configs via py4j in batch in the future.

Comment thread python/pyspark/sql/pandas/conversion.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel we are using more and more configs, probably we can also combine them into a runner_conf: Dict[str, str] later

@HyukjinKwon
HyukjinKwon force-pushed the SPARK-39979-followup2 branch from d4d80ff to 3fe735e Compare February 5, 2025 03:09
@HyukjinKwon
HyukjinKwon force-pushed the SPARK-39979-followup2 branch from 3fe735e to 3024d4c Compare February 5, 2025 03:11
@HyukjinKwon

Copy link
Copy Markdown
Member Author

Should be ready to go once it passes

@HyukjinKwon
HyukjinKwon marked this pull request as ready for review February 5, 2025 03:12
@HyukjinKwon
HyukjinKwon force-pushed the SPARK-39979-followup2 branch from e981783 to e3dfe23 Compare February 5, 2025 05:54
@HyukjinKwon
HyukjinKwon force-pushed the SPARK-39979-followup2 branch from e3dfe23 to 484bd01 Compare February 5, 2025 06:19
@HyukjinKwon
HyukjinKwon force-pushed the SPARK-39979-followup2 branch from 8ea00fd to 4decd33 Compare February 5, 2025 23:57
@HyukjinKwon

Copy link
Copy Markdown
Member Author

Merged to master and branch-4.0.

HyukjinKwon added a commit that referenced this pull request Feb 5, 2025
…ateDataFrame and toPandas with Arrow

### What changes were proposed in this pull request?

This PR is a retry of #41569 that implements to use large variable types within PySpark everywhere.

#39572 implemented the core logic but it only supports large variable types in the bold cases below:

- `mapInArrow`: **JVM -> Python -> JVM**
- Pandas UDF/Function API: **JVM -> Python** -> JVM
- createDataFrame with Arrow: Python -> JVM
- toPandas with Arrow: JVM -> Python

This PR completes them all.

### Why are the changes needed?

To consistently support the large variable types.

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

`spark.sql.execution.arrow.useLargeVarTypes` is not released out yet so it doesn't affect any end users.

### How was this patch tested?

Existing tests with `spark.sql.execution.arrow.useLargeVarTypes` enabled.

Closes #49790 from HyukjinKwon/SPARK-39979-followup2.

Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
(cherry picked from commit e2ef5a4)
Signed-off-by: Hyukjin Kwon <[email protected]>
HyukjinKwon pushed a commit that referenced this pull request Apr 7, 2025
…atibility

### What changes were proposed in this pull request?

Previously, [PR](#49790) extends ArrowSerializer class to support large variable types in pandas UDF. This PR makes it more backward-compatible by adding a new constructor for cases where the flag for large variable is irrelevant (default to false).

### Why are the changes needed?
To achieve versionless in spark connect, we need to be careful about changing a client API in Scala. For example, the change of an interface like this could affect Scala UDF referring to this class (as it is part of the spark connect client package) but running with an older spark connect client.

### How was this patch tested?
N/A. It's a new constructor.

Closes #50513 from haiyangsun-db/SPARK-51079.

Authored-by: Haiyang Sun <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
HyukjinKwon pushed a commit that referenced this pull request Apr 7, 2025
…atibility

### What changes were proposed in this pull request?

Previously, [PR](#49790) extends ArrowSerializer class to support large variable types in pandas UDF. This PR makes it more backward-compatible by adding a new constructor for cases where the flag for large variable is irrelevant (default to false).

### Why are the changes needed?
To achieve versionless in spark connect, we need to be careful about changing a client API in Scala. For example, the change of an interface like this could affect Scala UDF referring to this class (as it is part of the spark connect client package) but running with an older spark connect client.

### How was this patch tested?
N/A. It's a new constructor.

Closes #50513 from haiyangsun-db/SPARK-51079.

Authored-by: Haiyang Sun <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
(cherry picked from commit 75d80c7)
Signed-off-by: Hyukjin Kwon <[email protected]>
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 14, 2025
…ateDataFrame and toPandas with Arrow

### What changes were proposed in this pull request?

This PR is a retry of apache#41569 that implements to use large variable types within PySpark everywhere.

apache#39572 implemented the core logic but it only supports large variable types in the bold cases below:

- `mapInArrow`: **JVM -> Python -> JVM**
- Pandas UDF/Function API: **JVM -> Python** -> JVM
- createDataFrame with Arrow: Python -> JVM
- toPandas with Arrow: JVM -> Python

This PR completes them all.

### Why are the changes needed?

To consistently support the large variable types.

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

`spark.sql.execution.arrow.useLargeVarTypes` is not released out yet so it doesn't affect any end users.

### How was this patch tested?

Existing tests with `spark.sql.execution.arrow.useLargeVarTypes` enabled.

Closes apache#49790 from HyukjinKwon/SPARK-39979-followup2.

Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
(cherry picked from commit 454111a)
Signed-off-by: Hyukjin Kwon <[email protected]>
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 14, 2025
…atibility

### What changes were proposed in this pull request?

Previously, [PR](apache#49790) extends ArrowSerializer class to support large variable types in pandas UDF. This PR makes it more backward-compatible by adding a new constructor for cases where the flag for large variable is irrelevant (default to false).

### Why are the changes needed?
To achieve versionless in spark connect, we need to be careful about changing a client API in Scala. For example, the change of an interface like this could affect Scala UDF referring to this class (as it is part of the spark connect client package) but running with an older spark connect client.

### How was this patch tested?
N/A. It's a new constructor.

Closes apache#50513 from haiyangsun-db/SPARK-51079.

Authored-by: Haiyang Sun <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
(cherry picked from commit 0c50c2c)
Signed-off-by: Hyukjin Kwon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants