[SPARK-56256][PYTHON] Add emptyDataFrame API to SparkSession#55055
Open
zhengruifeng wants to merge 3 commits intoapache:masterfrom
Open
[SPARK-56256][PYTHON] Add emptyDataFrame API to SparkSession#55055zhengruifeng wants to merge 3 commits intoapache:masterfrom
zhengruifeng wants to merge 3 commits intoapache:masterfrom
Conversation
Co-authored-by: Isaac
Co-authored-by: Isaac
Co-authored-by: Isaac
dongjoon-hyun
approved these changes
Mar 27, 2026
Member
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM because this is a Python version of the following
Member
There was a problem hiding this comment.
Could you follow the Apache Spark and ASF guideline, @zhengruifeng ? We need the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
Apache Spark Guideline
spark/.github/PULL_REQUEST_TEMPLATE
Lines 55 to 56 in e0df769
ASF Guideline
HyukjinKwon
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add a new
SparkSession.emptyDataFrame(schema)API that creates an empty DataFrame with the specified schema.Why are the changes needed?
Creating an empty DataFrame with a given schema is a common operation, but currently requires calling
spark.createDataFrame([], schema)which is not very intuitive. This new API provides a more readable and discoverable way to create empty DataFrames.Does this PR introduce any user-facing change?
Yes. Adds a new public API
SparkSession.emptyDataFrame(schema: Union[StructType, str]) -> DataFrame.How was this patch tested?
Added unit tests in
test_creation.pycovering bothStructTypeand DDL string schema inputs. Tests are shared via the mixin and run for both classic and Spark Connect.Was this patch authored or co-authored using generative AI tooling?
Yes.