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

Support for casting StringViewArray to DecimalArray #6720

Merged
merged 4 commits into from
Nov 16, 2024

Conversation

tlm365
Copy link
Contributor

@tlm365 tlm365 commented Nov 12, 2024

Which issue does this PR close?

Closes #6715.

Rationale for this change

What changes are included in this PR?

  • Add support cast string view (Utf8View) to numeric(Int/Float/Decimal).
  • Unit tests.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Nov 12, 2024
@@ -2483,14 +2484,28 @@ where
Ok(Arc::new(byte_array_builder.finish()))
}

trait StringArrayType<'a>: ArrayAccessor<Item = &'a str> + Sized {
Copy link
Contributor

Choose a reason for hiding this comment

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

We would now have this in arrow-string and arrow-cast. Perhaps this would be best moved to arrow-array alongside ArrayAccessor ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Omega359 Thanks so much for reviewing.

We would now have this in arrow-string and arrow-cast. Perhaps this would be best moved to arrow-array alongside ArrayAccessor ?

Makes sense to me 👍

@tlm365 tlm365 marked this pull request as ready for review November 12, 2024 19:07
@alamb alamb changed the title [arrow-cast] Improve support for casting string view to numeric Support for casting StringViewArray to DecimalArray Nov 15, 2024
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 @tlm365 - this looks good to me 👍

Thank you @Omega359 foe the revew

@@ -570,6 +572,40 @@ pub trait ArrayAccessor: Array {
unsafe fn value_unchecked(&self, index: usize) -> Self::Item;
}

/// A trait for Arrow String Arrays, currently three types are supported:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is nice to start making public -- we use it in DataFusion a bit as well, so starting to consolidate on a single implementation will be good

@alamb alamb merged commit 8b33f96 into apache:master Nov 16, 2024
27 checks passed
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.

Add support for Utf8View -> numeric in can_cast_types
3 participants