Skip to content

[SPARK-51815] Add Row struct #63

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

Closed
wants to merge 2 commits into from

Conversation

dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Apr 16, 2025

What changes were proposed in this pull request?

This PR aims to add Row struct and use it.

Why are the changes needed?

To make DataFrame APIs return Row instead of [String?] in Swift.

- public func collect() async throws -> [[String?]] {
+ public func collect() async throws -> [Row] {

- public func head(_ n: Int32 = 1) async throws -> [[String?]] {
+ public func head(_ n: Int32 = 1) async throws -> [Row] {

Note that Row is added to support general type fields, but this PR replaces the existing API's [String?] signature into Row-based signature. The detailed one-to-one mapping among other types will be handled later.

Does this PR introduce any user-facing change?

Yes, but this is a change to the unreleased version.

How was this patch tested?

Pass the CIs.

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

No.

@dongjoon-hyun dongjoon-hyun force-pushed the SPARK-51815 branch 2 times, most recently from a538a15 to 1ef9013 Compare April 16, 2025 06:12
@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Apr 16, 2025

Could you review this Row when you have some time, @viirya ? As you pointed out previously in the following of the previous collect PR, Row was not added until now. And, this PR is the first implementation.

@@ -217,7 +217,7 @@ public actor DataFrame: Sendable {
values.append(str.asString(i))
Copy link
Member

Choose a reason for hiding this comment

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

This is still stored the value as string? So we still cannot insert column values into Row in their types?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes~ This is a part-one implementation to introduce Row struct like the note in the PR description.

Note that Row is added to support general type fields, but this PR replaces the existing API's [String?] signature into Row-based signature. The detailed one-to-one mapping among other types will be handled later.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Thank you.

Comment on lines +4 to +5
[Location,*]
[Owner,*]
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, why the the second elements of the two items ["Location","file:/opt/spark/work-dir/spark-warehouse"],["Owner","185"] are * now?

Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Apr 16, 2025

Choose a reason for hiding this comment

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

During the Catalog PR, the cleaning methods were added previously. While regenerating answer files Today, I used the cleaned strings because the cleaned one is better in the GitHub repo.

private func cleanUp(_ str: String) -> String {
return removeOwner(removeID(removeLocation(str)))
}
private func removeID(_ str: String) -> String {
return str.replacing(regexPlanId, with: "plan_id=").replacing(regexID, with: "#")
}
private func removeLocation(_ str: String) -> String {
return str.replacing(regexLocation, with: "*")
}
private func removeOwner(_ str: String) -> String {
return str.replacing(regexOwner, with: "*")
}

Copy link
Member

Choose a reason for hiding this comment

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

I see. Thank you.

@dongjoon-hyun
Copy link
Member Author

Thank you! Merged to main.

@dongjoon-hyun dongjoon-hyun deleted the SPARK-51815 branch April 16, 2025 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants