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

unify substring for binary&utf8 #4442

Merged
merged 1 commit into from
Jun 26, 2023
Merged

unify substring for binary&utf8 #4442

merged 1 commit into from
Jun 26, 2023

Conversation

jackwener
Copy link
Member

@jackwener jackwener commented Jun 22, 2023

Which issue does this PR close?

Closes #.

Rationale for this change

What changes are included in this PR?

After arrow-rs have GenericByteArray, we can unify substring of binary & utf8.

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jun 22, 2023
@jackwener jackwener marked this pull request as draft June 22, 2023 06:45
@jackwener jackwener force-pushed the unify branch 2 times, most recently from 7c0c8ab to a89686a Compare June 22, 2023 06:51
@jackwener jackwener marked this pull request as ready for review June 22, 2023 07:07
@jackwener jackwener requested review from tustvold, viirya and alamb June 22, 2023 07:07
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @jackwener -- the idea here is great and reducing code is 💯

My only concern is about utf8 boundary checking

maybe @tustvold has some thoughts

arrow-string/src/substring.rs Outdated Show resolved Hide resolved
arrow-string/src/substring.rs Outdated Show resolved Hide resolved
@jackwener jackwener force-pushed the unify branch 5 times, most recently from 3f0a1cc to 34615bb Compare June 22, 2023 18:17
@jackwener
Copy link
Member Author

My only concern is about utf8 boundary checking

Thanks for @alamb review, I have added code to check just when array is StringArray/LargeStringArray

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @jackwener -- looks great to me

@@ -1020,4 +968,17 @@ mod tests {
let err = substring(&array, 0, Some(5)).unwrap_err().to_string();
assert!(err.contains("invalid utf-8 boundary"));
}

#[test]
fn non_utf8_bytes() {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@tustvold tustvold merged commit 8e65b58 into apache:master Jun 26, 2023
@jackwener jackwener deleted the unify branch June 26, 2023 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants