You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "irenjj (via GitHub)" <gi...@apache.org> on 2025/01/31 12:23:48 UTC
[PR] feat: impl display for `DataType::List` [arrow-rs]
irenjj opened a new pull request, #7051:
URL: https://github.com/apache/arrow-rs/pull/7051
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #7048
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please call them out.
-->
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "emilk (via GitHub)" <gi...@apache.org>.
emilk commented on PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#issuecomment-3263855037
I'll take a stab at it!
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "emilk (via GitHub)" <gi...@apache.org>.
emilk commented on PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#issuecomment-3245220100
Thanks for working on this!
Note that a lot of error messages actually uses the `Debug` format of `DataType`, and so it would be great if that too was improved (e.g. would defer to the `Display` implementation)
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#discussion_r1938279517
##########
arrow-schema/src/datatype.rs:
##########
@@ -458,7 +458,16 @@ pub enum UnionMode {
impl fmt::Display for DataType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{self:?}")
+ match self {
+ DataType::List(field) => {
Review Comment:
Right -- so if `field.name() != "item"` perhaps it could look like
```
List(Int8;N, field='foo')
```
Likewise, if there is metadata I think it should also be displayed like
```
List(Int8;N, field='foo', metadata)
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "Blizzara (via GitHub)" <gi...@apache.org>.
Blizzara commented on PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#issuecomment-2782860684
The Arrow docstring on datatype says the Display should be also reversible - look at the code of datatype_parse it doesn't seem like lists were parseable even before, but maybe it'd be good to add as part of this PR given the new format should be easier to parse? :)
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "irenjj (via GitHub)" <gi...@apache.org>.
irenjj commented on PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#issuecomment-2628913757
Thanks @tustvold , I have made the changes as you suggested. Could you please help review it again?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "irenjj (via GitHub)" <gi...@apache.org>.
irenjj commented on code in PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#discussion_r2040660087
##########
arrow-schema/src/datatype.rs:
##########
@@ -458,7 +458,25 @@ pub enum UnionMode {
impl fmt::Display for DataType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{self:?}")
+ match self {
+ DataType::List(field) => {
Review Comment:
Thanks @Blizzara for your advice, that's good idea!
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#discussion_r1938266705
##########
arrow-schema/src/datatype.rs:
##########
@@ -458,7 +458,16 @@ pub enum UnionMode {
impl fmt::Display for DataType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{self:?}")
+ match self {
+ DataType::List(field) => {
Review Comment:
We also need to print the field name here if it isn't the default of item
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "Blizzara (via GitHub)" <gi...@apache.org>.
Blizzara commented on code in PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#discussion_r2030957726
##########
arrow-schema/src/datatype.rs:
##########
@@ -458,7 +458,25 @@ pub enum UnionMode {
impl fmt::Display for DataType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{self:?}")
+ match self {
+ DataType::List(field) => {
Review Comment:
maybe add the same for LargeList and FixedSizeList?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#issuecomment-3261765692
Marking as draft as I think this PR is no longer waiting on feedback and I am trying to make it easier to find PRs in need of review. Please mark it as ready for review when it is ready for another look
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#issuecomment-2850956868
Thanks @irenjj for working on this. I agree with @Blizzara. The display result should be reversible. I prefer to format the `List` type like the following way:
```rust
DataType::List(field) => {
write!(f, "List({})", field.data_type())
}
```
The result would be something like `List(Int64)`. It can be parsed by `parse_data_type`.
I think other list types can be formatted in the same way.
Then, it's better to add the corresponding test cases at `list_datatypes`, where we will test the round-trip of data type parsing.
https://github.com/apache/arrow-rs/blob/7905545537c50590fdb4dc645e3e0130fce80b57/arrow-schema/src/datatype_parse.rs#L604
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#issuecomment-3258388786
@irenjj do you plan to work on this any more? If not, perhaps someone else wants to pick it up to get it ready to go?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#discussion_r1937409651
##########
arrow-schema/src/datatype.rs:
##########
@@ -1129,4 +1138,18 @@ mod tests {
let data_type: DataType = "UInt64".parse().unwrap();
assert_eq!(data_type, DataType::UInt64);
}
+
+ #[test]
+ fn test_display_list() {
+ let list_data_type = DataType::List(Arc::new(Field::new_list_field(DataType::Int32, true)));
+ let list_data_type_string = list_data_type.to_string();
+ let expected_string = "List(Int32;N)";
+ assert_eq!(list_data_type_string, expected_string);
+
+ let list_data_type =
+ DataType::List(Arc::new(Field::new_list_field(DataType::UInt64, false)));
+ let list_data_type_string = list_data_type.to_string();
+ let expected_string = "List(UInt64)";
+ assert_eq!(list_data_type_string, expected_string);
Review Comment:
Perhaps we could get a test of a nested list as well
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "irenjj (via GitHub)" <gi...@apache.org>.
irenjj commented on PR #7051:
URL: https://github.com/apache/arrow-rs/pull/7051#issuecomment-3258664591
> @irenjj do you plan to work on this any more? If not, perhaps someone else wants to pick it up to get it ready to go?
I've been a bit busy lately, if anyone is interested, feel free to take it.:)
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: impl display for `DataType::List` [arrow-rs]
Posted by "mbrobbel (via GitHub)" <gi...@apache.org>.
mbrobbel closed pull request #7051: feat: impl display for `DataType::List`
URL: https://github.com/apache/arrow-rs/pull/7051
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org