You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "dqkqd (via GitHub)" <gi...@apache.org> on 2025/11/02 00:05:21 UTC
[PR] feat: parse `DataType::Union` [arrow-rs]
dqkqd opened a new pull request, #8765:
URL: https://github.com/apache/arrow-rs/pull/8765
# 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.
- Closes #8648
# 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 these changes tested?
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
# 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: parse `DataType::Union`, `DataType::Map`, `DataType::RunEndEncoded` [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #8765:
URL: https://github.com/apache/arrow-rs/pull/8765#discussion_r2486607302
##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -88,80 +88,88 @@ impl<'a> Parser<'a> {
Token::LargeListView => self.parse_large_list_view(),
Token::FixedSizeList => self.parse_fixed_size_list(),
Token::Struct => self.parse_struct(),
+ Token::Union => self.parse_union(),
+ Token::Map => self.parse_map(),
+ Token::RunEndEncoded => self.parse_run_end_encoded(),
tok => Err(make_error(
self.val,
&format!("finding next type, got unexpected '{tok}'"),
)),
}
}
- /// Parses list field name. Returns default field name if not found.
- fn parse_list_field_name(&mut self, context: &str) -> ArrowResult<String> {
- // field must be after a comma
- if self
+ /// parses Field, this is the inversion of `format_field` in `datatype_display.rs`.
+ /// E.g: "a": nullable Int64
+ ///
+ /// TODO: support metadata: `"a": nullable Int64 metadata: {"foo": "value"}`
+ fn parse_field(&mut self) -> ArrowResult<Field> {
Review Comment:
Maybe we can file a follow on ticket to unify them
--
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: parse `DataType::Union`, `DataType::Map`, `DataType::RunEndEncoded` [arrow-rs]
Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on code in PR #8765:
URL: https://github.com/apache/arrow-rs/pull/8765#discussion_r2487789888
##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -88,80 +88,88 @@ impl<'a> Parser<'a> {
Token::LargeListView => self.parse_large_list_view(),
Token::FixedSizeList => self.parse_fixed_size_list(),
Token::Struct => self.parse_struct(),
+ Token::Union => self.parse_union(),
+ Token::Map => self.parse_map(),
+ Token::RunEndEncoded => self.parse_run_end_encoded(),
tok => Err(make_error(
self.val,
&format!("finding next type, got unexpected '{tok}'"),
)),
}
}
- /// Parses list field name. Returns default field name if not found.
- fn parse_list_field_name(&mut self, context: &str) -> ArrowResult<String> {
- // field must be after a comma
- if self
+ /// parses Field, this is the inversion of `format_field` in `datatype_display.rs`.
+ /// E.g: "a": nullable Int64
+ ///
+ /// TODO: support metadata: `"a": nullable Int64 metadata: {"foo": "value"}`
+ fn parse_field(&mut self) -> ArrowResult<Field> {
Review Comment:
I filed #8775
--
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: parse `DataType::Union`, `DataType::Map`, `DataType::RunEndEncoded` [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #8765:
URL: https://github.com/apache/arrow-rs/pull/8765
--
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: parse `DataType::Union`, `DataType::Map`, `DataType::RunEndEncoded` [arrow-rs]
Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on code in PR #8765:
URL: https://github.com/apache/arrow-rs/pull/8765#discussion_r2484043798
##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -88,80 +88,88 @@ impl<'a> Parser<'a> {
Token::LargeListView => self.parse_large_list_view(),
Token::FixedSizeList => self.parse_fixed_size_list(),
Token::Struct => self.parse_struct(),
+ Token::Union => self.parse_union(),
+ Token::Map => self.parse_map(),
+ Token::RunEndEncoded => self.parse_run_end_encoded(),
tok => Err(make_error(
self.val,
&format!("finding next type, got unexpected '{tok}'"),
)),
}
}
- /// Parses list field name. Returns default field name if not found.
- fn parse_list_field_name(&mut self, context: &str) -> ArrowResult<String> {
- // field must be after a comma
- if self
+ /// parses Field, this is the inversion of `format_field` in `datatype_display.rs`.
+ /// E.g: "a": nullable Int64
+ ///
+ /// TODO: support metadata: `"a": nullable Int64 metadata: {"foo": "value"}`
+ fn parse_field(&mut self) -> ArrowResult<Field> {
Review Comment:
There are `parse_field` and `parse_list_field` because we have two representation for `Field`:
- In `Struct`, `Union`, `Map`, `RunEndEncoded`: `"a": nullable Int64`
- In `List` types: `nullable Int64, field: 'a'`
I don't think having two different representation for `Field` is a wise choice,
but I don't change it in this PR.
--
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: parse `DataType::Union`, `DataType::Map`, `DataType::RunEndEncoded` [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8765:
URL: https://github.com/apache/arrow-rs/pull/8765#issuecomment-3487612825
Thanks again @DDtKey
--
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: parse `DataType::Union`, `DataType::Map`, `DataType::RunEndEncoded` [arrow-rs]
Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on code in PR #8765:
URL: https://github.com/apache/arrow-rs/pull/8765#discussion_r2484111667
##########
arrow-schema/src/datatype_display.rs:
##########
@@ -139,8 +139,9 @@ impl fmt::Display for DataType {
Ok(())
}
Self::Union(union_fields, union_mode) => {
- write!(f, "Union({union_mode:?}, ")?;
+ write!(f, "Union({union_mode:?}")?;
if !union_fields.is_empty() {
+ write!(f, ", ")?;
Review Comment:
Allow empty union to be displayed like `Union(Dense)`, instead of `Union(Dense, )`
--
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