Skip to content

[SPARK-48373][PYTHON] Allow schema parameter of createDataFrame() to be length-1 list or tuple of StructType - #46687

Closed
ianmcook wants to merge 2 commits into
apache:masterfrom
ianmcook:SPARK-48373
Closed

[SPARK-48373][PYTHON] Allow schema parameter of createDataFrame() to be length-1 list or tuple of StructType#46687
ianmcook wants to merge 2 commits into
apache:masterfrom
ianmcook:SPARK-48373

Conversation

@ianmcook

@ianmcookianmcook commented May 21, 2024

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Users will no longer get an error if they pass a length-1 list or tuple of StructType as the schema argument to createDataFrame()

Why are the changes needed?

In Python code it is easy to accidentally create a length-1 tuple of StructType instead of just a StructType if you leave a trailing comma at the end of a line.

Does this PR introduce any user-facing change?

It prevents an unhelpful error message in this case.

How was this patch tested?

I modified one of the existing tests to test this.

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

No

@ianmcook
ianmcook marked this pull request as ready for review May 21, 2024 18:26
assert_frame_equal(pdf_arrow, pdf)
for schema in [
self.schema,
(self.schema,),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While I get the intention, let's probably don't do this. There are a lot of places like this, and I think it's not worthwhile fixing them all.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Understood. Thanks for considering it.

ianmcook added a commit to ianmcook/spark that referenced this pull request May 30, 2024
Sign up for freeto 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.

2 participants

@ianmcook@HyukjinKwon