alamb opened a new issue, #3821: URL: https://github.com/apache/arrow-rs/issues/3821
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.** As part of implementing https://github.com/apache/arrow-datafusion/issues/5016 in DataFusion I needed some way to convert from a string passed in by the user to a `DataType`. Since we already had a function `arrow_typeof` that provides a useful human readable type name by calling `DataType::to_string()` I wanted the opposite: A way to take the output of `DataType::to_string()` and make a `DataType` **Describe the solution you'd like** I think having `FromStr` implementation that matches the https://docs.rs/arrow/34.0.0/arrow/datatypes/enum.DataType.html#impl-Display-for-DataType implementation for DataType would be very nice. Example usage: ```rust let data_type = DataType:Int32; // use (existing) Display impl to get a string representaiton let data_type_string = data_type.to_string(); assert_eq!(data_type_string, "Int32"); // use proposed FromStr impl to get the DataType back let parsed_datatype: DataType = data_type_string.parse()? assert_eq!(parsed_datatype, DataType::Int32); ``` **Describe alternatives you've considered** @tustvold pointed out that there is already a way to encode data types in String for the IPC format https://arrow.apache.org/docs/format/CDataInterface.html#data-type-description-format-strings While this format is (designed to be) easy to parse by computers, I don't think it is easy to parse by Humans (quick quiz, what type does `tdD` represent?) **Additional context** See https://github.com/apache/arrow-datafusion/pull/5166#discussion_r1129692579 We can probably lift the implementation from https://github.com/apache/arrow-datafusion/pull/5166 into Arrow-rs The implementation in https://github.com/apache/arrow-datafusion/pull/5166 currently does not cover: - [ ] Parsing Timezones in Timestamp types (@waitingkuo expressed interest in this) - [ ] Parsing Struct, Union, Map or List types (though it does handle `Dictionary`) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
