-
Notifications
You must be signed in to change notification settings - Fork 737
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
implement DataType::try_form(&str)
#5994
Conversation
|
||
use crate::{DataType, ArrowError, TimeUnit, IntervalUnit, Field}; | ||
|
||
pub(crate) fn parse_data_type(val: &str) -> ArrowResult<DataType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alamb we could make this public and return Result<DataType, String>
. So we can use it in datafusion arrow_cast
without having to consider the other members of the ArrowError
enum.
Or we could leave this as is and in arrow_cast
do
match arrow_error_from_parse_data_type {
ArrowError:ParseError(e) => DatafusinoError:Plan(e),
e => DatafusionError:ArrowError(e, None),
}
LMK what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we could leave this as is and in
arrow_cast
do
I think leaving the API surface area small (and hence not making this pub) is the better choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me @samuelcolvin ❤️
I got inspired to improve the DataType documentation as well based on this PR (to make the feature potentially more discoverable -- PR in #5997)
|
||
use crate::{DataType, ArrowError, TimeUnit, IntervalUnit, Field}; | ||
|
||
pub(crate) fn parse_data_type(val: &str) -> ArrowResult<DataType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we could leave this as is and in
arrow_cast
do
I think leaving the API surface area small (and hence not making this pub) is the better choice.
Great 👍 |
That's fine, thanks for the quick response. If it becomes a problem, I can copy and paste |
FWIW I made apache/datafusion#11254 to use this function upstream in DataFusion ❤️ |
Which issue does this PR close?
Closes #3821
Rationale for this change
I would like to use this functionality, currently it's private in datafusion.
What changes are included in this PR?
DataType::from_str
is moved here from DataFusion.Are there any user-facing changes?
DataType::from_str
is now public.