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

fix: fix string repeat for negative numbers #10760

Merged
merged 2 commits into from
Jun 3, 2024
Merged

Conversation

tshauck
Copy link
Contributor

@tshauck tshauck commented Jun 2, 2024

Which issue does this PR close?

Closes #10759

Rationale for this change

Repeat should not panic and should match the behavior of other common engines.

What changes are included in this PR?

Updates the main repeat function's logic to only try to cast the i64 to a usize when the count is greater than or equal to 0, otherwise returns an empty string.

Are these changes tested?

Added a sqllogictest.

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Jun 2, 2024
Copy link
Member

@waynexia waynexia left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

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

Thanks @tshauck

@andygrove andygrove mentioned this pull request Jun 2, 2024
4 tasks
@waynexia waynexia merged commit 59bfe77 into apache:main Jun 3, 2024
23 checks passed
@tshauck tshauck deleted the fix-repeat branch June 3, 2024 03:45
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
* fix: fix string repeat for negative numbers

* style: run cargo fmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Repeat scalar function panics on negative repeat counts.
3 participants