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-48373][PYTHON] Allow schema parameter of createDataFrame() to be length-1 list or tuple of StructType #46687

Closed
wants to merge 2 commits into from

Conversation

ianmcook
Copy link
Member

@ianmcook ianmcook commented May 21, 2024

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 added a commit to ianmcook/spark that referenced this pull request May 21, 2024
ianmcook added a commit to ianmcook/spark that referenced this pull request May 21, 2024
@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
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
Member Author

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 ianmcook closed this May 22, 2024
ianmcook added a commit to ianmcook/spark that referenced this pull request May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants