You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Rich-T-kid (via GitHub)" <gi...@apache.org> on 2026/08/25 14:29:04 UTC

[PR] fix: ree display [arrow-rs]

Rich-T-kid opened a new pull request, #10840:
URL: https://github.com/apache/arrow-rs/pull/10840

   # 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 #8351.
   
   # Rationale for this change
   
   the current display method for `DataType:REE` is a big verbose & not pretty.
   
   <!--
   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?
   
   Before: `RunEndEncoded("run_ends": non-null Int16, "values": Utf8)`
   After: `RunEndEncoded("run_ends": Int16, "values": Utf8)`
   
   note - the values field can still display null if the field is nullable thanks to `format_field`, the non-null was only removed from the run_end field because it cannot be null as noted by the arrow spec
   
   <!--
   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?
   yes
   <!--
   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)?
   
   If this PR claims a performance improvement, please include evidence such as benchmark results.
   -->
   
   # Are there any user-facing changes?
   yes, users printing REE can expect a different output format now.
   <!--
   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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#issuecomment-5604966740

   sweet, thanks @Jefffrey 


-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3958004847


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -173,11 +174,31 @@ impl Display for DataType {
                 Ok(())
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
+                let default_names = run_ends_field.name() == Field::REE_RUN_ENDS_FIELD_DEFAULT_NAME
+                    && values_field.name() == Field::REE_VALUES_FIELD_DEFAULT_NAME;
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
-                let values_str = format_field(values_field);
-
-                write!(f, "{run_ends_str}, {values_str})")?;
+                let re_null = format_nullability(run_ends_field);
+                let v_null = format_nullability(values_field);
+                let v_meta = format_metadata(values_field.metadata());
+                if default_names {
+                    write!(
+                        f,
+                        "{re_null}{}, {v_null}{}{})",
+                        run_ends_field.data_type(),
+                        values_field.data_type(),
+                        v_meta,
+                    )?;
+                } else {
+                    write!(
+                        f,
+                        "\"{}\": {}, \"{}\": {v_null}{}{})",

Review Comment:
   we should include the run ends nullability here too for consistency



##########
arrow-schema/src/datatype_display.rs:
##########
@@ -173,11 +174,31 @@ impl Display for DataType {
                 Ok(())
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
+                let default_names = run_ends_field.name() == Field::REE_RUN_ENDS_FIELD_DEFAULT_NAME
+                    && values_field.name() == Field::REE_VALUES_FIELD_DEFAULT_NAME;
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
-                let values_str = format_field(values_field);
-
-                write!(f, "{run_ends_str}, {values_str})")?;
+                let re_null = format_nullability(run_ends_field);
+                let v_null = format_nullability(values_field);
+                let v_meta = format_metadata(values_field.metadata());

Review Comment:
   i feel we should include both metadata of run ends & values, instead of only values; likely we should fallback to the original format `"{run_ends_str}, {values_str})"` when we have any metadata at all
   
   im imagining just two forms of display:
   
   `RunEndEncoded(non-null UInt32, Int32)`
   
   - simplified form
   - only when no metadata in either, and field names are default
   
   `RunEndEncoded(\"run_ends\": non-null UInt32, metadata: {\"key\": \"value\"}, \"values\": Int32)`
   
   - complex form (current form on main)
   - when any metadata is present or field names are custom



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#issuecomment-5604829789

   thanks all


-- 
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] fix: ree display [arrow-rs]

Posted by "mhilton (via GitHub)" <gi...@apache.org>.
mhilton commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3854121728


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -478,7 +481,7 @@ mod tests {
         let values_field = Arc::new(Field::new("values", DataType::Int32, true));
         let ree_data_type = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
         let ree_data_type_string = ree_data_type.to_string();
-        let expected_string = "RunEndEncoded(\"run_ends\": non-null UInt32, \"values\": Int32)";
+        let expected_string = "RunEndEncoded('run_ends': UInt32, \"values\": Int32)";

Review Comment:
   I'd suggest picking one type of quote mark to use for this string.



##########
arrow-schema/src/datatype_display.rs:
##########
@@ -174,10 +174,13 @@ impl Display for DataType {
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
                 let values_str = format_field(values_field);
 
-                write!(f, "{run_ends_str}, {values_str})")?;
+                write!(

Review Comment:
   Out of interest is there some reason that you chose to encode this as `RunEndEncoded('run_ends': Int32, "values": String)` rather than the more succinct `RunEndEncoded(Int32, String)`. This looks to be more akin to a Dictionary than anything else, and those use a form more like the latter.



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3873264816


##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -1217,20 +1249,44 @@ mod test {
                 true,
             ),
             DataType::RunEndEncoded(
-                Arc::new(Field::new("run_ends", DataType::UInt32, false)),
+                Arc::new(Field::new("run_ends", DataType::UInt32, true)),
                 Arc::new(Field::new("values", DataType::Int32, true)),
             ),
             DataType::RunEndEncoded(
                 Arc::new(Field::new(
-                    "nested_run_end_encoded",
+                    "run_ends",
                     DataType::RunEndEncoded(
-                        Arc::new(Field::new("run_ends", DataType::UInt32, false)),
+                        Arc::new(Field::new("run_ends", DataType::UInt32, true)),

Review Comment:
   https://arrow.apache.org/docs/format/Columnar.html#run-end-encoded-layout. the run ends cannot be null.
   
   🤔 
   
   I had this flipped. false => no nulls. thank you for the catch



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3958433360


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -173,11 +174,31 @@ impl Display for DataType {
                 Ok(())
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
+                let default_names = run_ends_field.name() == Field::REE_RUN_ENDS_FIELD_DEFAULT_NAME
+                    && values_field.name() == Field::REE_VALUES_FIELD_DEFAULT_NAME;
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
-                let values_str = format_field(values_field);
-
-                write!(f, "{run_ends_str}, {values_str})")?;
+                let re_null = format_nullability(run_ends_field);
+                let v_null = format_nullability(values_field);
+                let v_meta = format_metadata(values_field.metadata());

Review Comment:
   https://github.com/apache/arrow-rs/pull/10840/changes/857c98364a50baf435e1248fd0c1553cbd0e3232 adds this but in a slightly different format. the metadata for ree comes right after the ree field, same for the values. Also added a test



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#issuecomment-5556385322

   > thinking about it more, im leaning towards keeping the explicit `non-null`; itll keep us aligned with map as well which i think is the only other example of a datatype with a required non-null, and it currently will always display it
   
   ill bump this comment


-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3958433360


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -173,11 +174,31 @@ impl Display for DataType {
                 Ok(())
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
+                let default_names = run_ends_field.name() == Field::REE_RUN_ENDS_FIELD_DEFAULT_NAME
+                    && values_field.name() == Field::REE_VALUES_FIELD_DEFAULT_NAME;
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
-                let values_str = format_field(values_field);
-
-                write!(f, "{run_ends_str}, {values_str})")?;
+                let re_null = format_nullability(run_ends_field);
+                let v_null = format_nullability(values_field);
+                let v_meta = format_metadata(values_field.metadata());

Review Comment:
   https://github.com/apache/arrow-rs/pull/10840/changes/857c98364a50baf435e1248fd0c1553cbd0e3232 adds this & a test



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#issuecomment-5441577560

   > im still unsure on if we should omit the `non-null` for the runs type or not, might be good to get a second opinion
   
   i'm in favor of removing at since its redundant.
   
   @etseidl any thoughts? 


-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840


-- 
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] fix: ree display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3864212690


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -174,10 +174,13 @@ impl Display for DataType {
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
                 let values_str = format_field(values_field);
 
-                write!(f, "{run_ends_str}, {values_str})")?;
+                write!(

Review Comment:
   > another thing to consider is would this new format roundtrip through parsing? i dont know if we have existing 100% guarantee that all formatted displays can also be parsed, but maybe thats something we should aim for
   
   we do have `test_parse_data_type` and it covers REE. 



-- 
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] fix: ree display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#issuecomment-5427562050

   I asked claude to help make diagram of the ree display state after https://github.com/apache/arrow-rs/pull/10840/commits/94fa3fe0928c312cea0fca7c1ef0c39da68192cf
   
   ```
   ┌───────────────┬─────────────┬─────────────────┬──────────────┬─────────────────────────────────────────────────────────┐
   │ run_ends name │ values name │ values nullable │ Display form │                         Example                         │
   ├───────────────┼─────────────┼─────────────────┼──────────────┼─────────────────────────────────────────────────────────┤
   │ default       │ default     │ nullable        │ compact      │ RunEndEncoded(Int32, Int32)                             │
   ├───────────────┼─────────────┼─────────────────┼──────────────┼─────────────────────────────────────────────────────────┤
   │ default       │ default     │ non-null        │ compact      │ RunEndEncoded(Int32, non-null Utf8)                     │
   ├───────────────┼─────────────┼─────────────────┼──────────────┼─────────────────────────────────────────────────────────┤
   │ default       │ custom      │ nullable        │ verbose      │ RunEndEncoded('run_ends': Int32, 'vals': Int32)         │
   ├───────────────┼─────────────┼─────────────────┼──────────────┼─────────────────────────────────────────────────────────┤
   │ default       │ custom      │ non-null        │ verbose      │ RunEndEncoded('run_ends': Int32, 'vals': non-null Utf8) │
   ├───────────────┼─────────────┼─────────────────┼──────────────┼─────────────────────────────────────────────────────────┤
   │ custom        │ default     │ nullable        │ verbose      │ RunEndEncoded('re': Int32, 'values': Int32)             │
   ├───────────────┼─────────────┼─────────────────┼──────────────┼─────────────────────────────────────────────────────────┤
   │ custom        │ default     │ non-null        │ verbose      │ RunEndEncoded('re': Int32, 'values': non-null Utf8)     │
   ├───────────────┼─────────────┼─────────────────┼──────────────┼─────────────────────────────────────────────────────────┤
   │ custom        │ custom      │ nullable        │ verbose      │ RunEndEncoded('re': Int32, 'vals': Int32)               │
   ├───────────────┼─────────────┼─────────────────┼──────────────┼─────────────────────────────────────────────────────────┤
   │ custom        │ custom      │ non-null        │ verbose      │ RunEndEncoded('re': Int32, 'vals': non-null Utf8)       │
   └───────────────┴─────────────┴─────────────────┴──────────────┴─────────────────────────────────────────────────────────┘
   ```


-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3873336351


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -174,10 +174,13 @@ impl Display for DataType {
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
                 let values_str = format_field(values_field);
 
-                write!(f, "{run_ends_str}, {values_str})")?;
+                write!(

Review Comment:
   make sense to me



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3963482998


##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -251,6 +251,19 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parses the next double-quoted string
+    fn parse_quoted_string(&mut self, context: &str) -> ArrowResult<String> {

Review Comment:
   this exists as `parse_double_quoted_string()`



##########
arrow-schema/src/datatype_display.rs:
##########
@@ -173,11 +174,34 @@ impl Display for DataType {
                 Ok(())
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
+                let default_names = run_ends_field.name() == Field::REE_RUN_ENDS_FIELD_DEFAULT_NAME
+                    && values_field.name() == Field::REE_VALUES_FIELD_DEFAULT_NAME;
+                let no_metadata =
+                    run_ends_field.metadata().is_empty() && values_field.metadata().is_empty();
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
-                let values_str = format_field(values_field);
-
-                write!(f, "{run_ends_str}, {values_str})")?;
+                let re_null = format_nullability(run_ends_field);
+                let v_null = format_nullability(values_field);
+                let re_meta = format_metadata(run_ends_field.metadata());
+                let v_meta = format_metadata(values_field.metadata());
+                if default_names && no_metadata {
+                    write!(
+                        f,
+                        "{re_null}{}, {v_null}{})",
+                        run_ends_field.data_type(),
+                        values_field.data_type(),
+                    )?;
+                } else {
+                    write!(

Review Comment:
   we can simplify this by using the existing `format_field()` function, e.g.
   
   ```rust
   let default_names = run_ends_field.name() == Field::REE_RUN_ENDS_FIELD_DEFAULT_NAME
       && values_field.name() == Field::REE_VALUES_FIELD_DEFAULT_NAME;
   let no_metadata =
       run_ends_field.metadata().is_empty() && values_field.metadata().is_empty();
   write!(f, "RunEndEncoded(")?;
   if default_names && no_metadata {
       let re_null = format_nullability(run_ends_field);
       let v_null = format_nullability(values_field);
       write!(
           f,
           "{re_null}{}, {v_null}{})",
           run_ends_field.data_type(),
           values_field.data_type(),
       )?;
   } else {
       let run_ends_str = format_field(run_ends_field);
       let values_str = format_field(values_field);
       write!(f, "{run_ends_str}, {values_str})")?;
   }
   ```



##########
arrow-schema/src/field.rs:
##########
@@ -162,6 +162,14 @@ impl Field {
     ///
     /// See [Arrow Spec](https://github.com/apache/arrow/blob/b19c4761b558ade94ae05743062d92aacedef10e/format/Schema.fbs#L127-L138))
     pub const MAP_VALUE_FIELD_DEFAULT_NAME: &'static str = "value";
+    /// Default field name for the run-ends field for RunEndEncoded
+    ///
+    /// See [Arrow Spec](https://arrow.apache.org/docs/format/Columnar.html#run-end-encoded-layout)
+    pub const REE_RUN_ENDS_FIELD_DEFAULT_NAME: &'static str = "run_ends";
+    /// Default field name for the values field for RunEndEncoded
+    ///
+    /// See [Arrow Spec](https://arrow.apache.org/docs/format/Columnar.html#run-end-encoded-layout)
+    pub const REE_VALUES_FIELD_DEFAULT_NAME: &'static str = "values";

Review Comment:
   in a followup PR we can wire this in to more places where its used, similar to the map consts above



##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -597,20 +610,52 @@ impl<'a> Parser<'a> {
         }
     }
 
-    /// Parses the next RunEndEncoded (called after `RunEndEncoded` has been consumed)
-    /// E.g: RunEndEncoded("run_ends": UInt32, "values": nonnull Int32)
+    /// Parses the next RunEndEncoded (called after `RunEndEncoded` has been consumed).
+    ///
+    /// Compact form (default field names): `RunEndEncoded(non-null Int32, non-null Utf8)`
+    /// Verbose form (custom field names):  `RunEndEncoded("re": Int32, "v": non-null Utf8)`
     fn parse_run_end_encoded(&mut self) -> ArrowResult<DataType> {
         self.expect_token(Token::LParen)?;
-        let run_ends = self.parse_field()?;
-        self.expect_token(Token::Comma)?;
-        let values = self.parse_field()?;
+
+        // Distinguish compact from verbose by peeking: verbose starts with a double-quoted name.
+        let verbose = matches!(
+            self.tokenizer.peek(),
+            Some(Ok(Token::DoubleQuotedString(_)))
+        );
+
+        let (run_ends, values) = if verbose {
+            let run_ends = self.parse_ree_verbose_field()?;
+            self.expect_token(Token::Comma)?;
+            let values = self.parse_ree_verbose_field()?;
+            (run_ends.with_nullable(false), values)

Review Comment:
   i do wonder with our approach here; should it be permissive and override to the correct nullability, or more strict and explicitly fail
   
   i looked at map parsing but it seems its too permissive and doesnt actually check its of the right form (struct with non null keys)
   
   so perhaps we can explore in a followup



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3964577400


##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -597,20 +610,52 @@ impl<'a> Parser<'a> {
         }
     }
 
-    /// Parses the next RunEndEncoded (called after `RunEndEncoded` has been consumed)
-    /// E.g: RunEndEncoded("run_ends": UInt32, "values": nonnull Int32)
+    /// Parses the next RunEndEncoded (called after `RunEndEncoded` has been consumed).
+    ///
+    /// Compact form (default field names): `RunEndEncoded(non-null Int32, non-null Utf8)`
+    /// Verbose form (custom field names):  `RunEndEncoded("re": Int32, "v": non-null Utf8)`
     fn parse_run_end_encoded(&mut self) -> ArrowResult<DataType> {
         self.expect_token(Token::LParen)?;
-        let run_ends = self.parse_field()?;
-        self.expect_token(Token::Comma)?;
-        let values = self.parse_field()?;
+
+        // Distinguish compact from verbose by peeking: verbose starts with a double-quoted name.
+        let verbose = matches!(
+            self.tokenizer.peek(),
+            Some(Ok(Token::DoubleQuotedString(_)))
+        );
+
+        let (run_ends, values) = if verbose {
+            let run_ends = self.parse_ree_verbose_field()?;
+            self.expect_token(Token::Comma)?;
+            let values = self.parse_ree_verbose_field()?;
+            (run_ends.with_nullable(false), values)

Review Comment:
   can also make a follow up for this but I think its a slightly separate discussion. Would we want to throw an error here if the run ends are nullable?  



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3873264816


##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -1217,20 +1249,44 @@ mod test {
                 true,
             ),
             DataType::RunEndEncoded(
-                Arc::new(Field::new("run_ends", DataType::UInt32, false)),
+                Arc::new(Field::new("run_ends", DataType::UInt32, true)),
                 Arc::new(Field::new("values", DataType::Int32, true)),
             ),
             DataType::RunEndEncoded(
                 Arc::new(Field::new(
-                    "nested_run_end_encoded",
+                    "run_ends",
                     DataType::RunEndEncoded(
-                        Arc::new(Field::new("run_ends", DataType::UInt32, false)),
+                        Arc::new(Field::new("run_ends", DataType::UInt32, true)),

Review Comment:
   https://arrow.apache.org/docs/format/Columnar.html#run-end-encoded-layout. the run ends cannot be null.
   
   I had this flipped. false => no nulls. thank you for the catch



-- 
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] fix: ree display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3860167961


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -174,10 +174,13 @@ impl Display for DataType {
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
                 let values_str = format_field(values_field);
 
-                write!(f, "{run_ends_str}, {values_str})")?;
+                write!(

Review Comment:
   what if we follow how list formats it by doing
   
   `RunEndEncoded(Int32, non-null String)`
   
   and then we expand to the verbose form if we have different names for the fields, other than the default
   
   `RunEndEncoded('run_ends': Int32, "named_values": non-null String)`
   
   i know i suggested omitting the `non-null` for key since thats enforced, but i wonder if that just causes confusion and maybe we're better off leaving it in 🤔 
   
   another thing to consider is would this new format roundtrip through parsing? i dont know if we have existing 100% guarantee that all formatted displays can also be parsed, but maybe thats something we should aim for



-- 
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] fix: ree display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3854391933


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -174,10 +174,13 @@ impl Display for DataType {
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
                 let values_str = format_field(values_field);
 
-                write!(f, "{run_ends_str}, {values_str})")?;
+                write!(

Review Comment:
   yea I think the nullability of the values type was important to keep in the display string.



-- 
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] fix: ree display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3864197848


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -478,7 +481,7 @@ mod tests {
         let values_field = Arc::new(Field::new("values", DataType::Int32, true));
         let ree_data_type = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
         let ree_data_type_string = ree_data_type.to_string();
-        let expected_string = "RunEndEncoded(\"run_ends\": non-null UInt32, \"values\": Int32)";
+        let expected_string = "RunEndEncoded('run_ends': UInt32, \"values\": Int32)";

Review Comment:
   good suggestion 



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3890052214


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -474,24 +490,34 @@ mod tests {
 
     #[test]
     fn test_display_run_end_encoded() {
+        // Compact form: default field names "run_ends" and "values"
         let run_ends_field = Arc::new(Field::new("run_ends", DataType::UInt32, false));
         let values_field = Arc::new(Field::new("values", DataType::Int32, true));
-        let ree_data_type = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
-        let ree_data_type_string = ree_data_type.to_string();
-        let expected_string = "RunEndEncoded(\"run_ends\": non-null UInt32, \"values\": Int32)";
-        assert_eq!(ree_data_type_string, expected_string);
+        let ree = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
+        assert_eq!(ree.to_string(), "RunEndEncoded(UInt32, Int32)");
+
+        // Compact form: non-null values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let values_field_str = Arc::new(Field::new("values", DataType::Utf8, false));
+        let ree2 = DataType::RunEndEncoded(run_ends_field, values_field_str);
+        assert_eq!(ree2.to_string(), "RunEndEncoded(Int32, non-null Utf8)");
+
+        // Verbose form: non-default field name on values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let named_values = Arc::new(Field::new("named_values", DataType::Utf8, false));
+        let ree3 = DataType::RunEndEncoded(run_ends_field, named_values);
+        assert_eq!(
+            ree3.to_string(),
+            "RunEndEncoded('run_ends': Int32, 'named_values': non-null Utf8)"

Review Comment:
   changes are in https://github.com/apache/arrow-rs/pull/10840/changes/ebfa71e3a3c4edc735d97a01784b39989dc9baee now



##########
arrow-schema/src/datatype_display.rs:
##########
@@ -474,24 +490,34 @@ mod tests {
 
     #[test]
     fn test_display_run_end_encoded() {
+        // Compact form: default field names "run_ends" and "values"
         let run_ends_field = Arc::new(Field::new("run_ends", DataType::UInt32, false));
         let values_field = Arc::new(Field::new("values", DataType::Int32, true));
-        let ree_data_type = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
-        let ree_data_type_string = ree_data_type.to_string();
-        let expected_string = "RunEndEncoded(\"run_ends\": non-null UInt32, \"values\": Int32)";
-        assert_eq!(ree_data_type_string, expected_string);
+        let ree = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
+        assert_eq!(ree.to_string(), "RunEndEncoded(UInt32, Int32)");
+
+        // Compact form: non-null values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let values_field_str = Arc::new(Field::new("values", DataType::Utf8, false));
+        let ree2 = DataType::RunEndEncoded(run_ends_field, values_field_str);
+        assert_eq!(ree2.to_string(), "RunEndEncoded(Int32, non-null Utf8)");
+
+        // Verbose form: non-default field name on values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let named_values = Arc::new(Field::new("named_values", DataType::Utf8, false));
+        let ree3 = DataType::RunEndEncoded(run_ends_field, named_values);
+        assert_eq!(
+            ree3.to_string(),
+            "RunEndEncoded('run_ends': Int32, 'named_values': non-null Utf8)"

Review Comment:
   changes are in https://github.com/apache/arrow-rs/pull/10840/changes/ebfa71e3a3c4edc735d97a01784b39989dc9baee 



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3888415928


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -474,24 +490,34 @@ mod tests {
 
     #[test]
     fn test_display_run_end_encoded() {
+        // Compact form: default field names "run_ends" and "values"
         let run_ends_field = Arc::new(Field::new("run_ends", DataType::UInt32, false));
         let values_field = Arc::new(Field::new("values", DataType::Int32, true));
-        let ree_data_type = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
-        let ree_data_type_string = ree_data_type.to_string();
-        let expected_string = "RunEndEncoded(\"run_ends\": non-null UInt32, \"values\": Int32)";
-        assert_eq!(ree_data_type_string, expected_string);
+        let ree = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
+        assert_eq!(ree.to_string(), "RunEndEncoded(UInt32, Int32)");
+
+        // Compact form: non-null values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let values_field_str = Arc::new(Field::new("values", DataType::Utf8, false));
+        let ree2 = DataType::RunEndEncoded(run_ends_field, values_field_str);
+        assert_eq!(ree2.to_string(), "RunEndEncoded(Int32, non-null Utf8)");
+
+        // Verbose form: non-default field name on values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let named_values = Arc::new(Field::new("named_values", DataType::Utf8, false));
+        let ree3 = DataType::RunEndEncoded(run_ends_field, named_values);
+        assert_eq!(
+            ree3.to_string(),
+            "RunEndEncoded('run_ends': Int32, 'named_values': non-null Utf8)"

Review Comment:
   changes dont seem to have been pushed



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3964569549


##########
arrow-schema/src/field.rs:
##########
@@ -162,6 +162,14 @@ impl Field {
     ///
     /// See [Arrow Spec](https://github.com/apache/arrow/blob/b19c4761b558ade94ae05743062d92aacedef10e/format/Schema.fbs#L127-L138))
     pub const MAP_VALUE_FIELD_DEFAULT_NAME: &'static str = "value";
+    /// Default field name for the run-ends field for RunEndEncoded
+    ///
+    /// See [Arrow Spec](https://arrow.apache.org/docs/format/Columnar.html#run-end-encoded-layout)
+    pub const REE_RUN_ENDS_FIELD_DEFAULT_NAME: &'static str = "run_ends";
+    /// Default field name for the values field for RunEndEncoded
+    ///
+    /// See [Arrow Spec](https://arrow.apache.org/docs/format/Columnar.html#run-end-encoded-layout)
+    pub const REE_VALUES_FIELD_DEFAULT_NAME: &'static str = "values";

Review Comment:
   filed an issue for this



-- 
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] fix: ree display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3864195894


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -174,10 +174,13 @@ impl Display for DataType {
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
                 let values_str = format_field(values_field);
 
-                write!(f, "{run_ends_str}, {values_str})")?;
+                write!(

Review Comment:
   > RunEndEncoded(Int32, non-null String)
   
   looks cleaner than the alternative.
   
   > and then we expand to the verbose form if we have different names for the fields,
   
   what would be the use cases of building a REE with a slightly different name. I'll include this in the PR but im not sure that this code path would be hit.
   
   > another thing to consider is would this new format roundtrip through parsing? i dont know if we have existing 100% guarantee that all formatted displays can also be parsed, but maybe thats something we should aim for
   
   ill check. if its relatively small ill try and fit them into one 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] fix: ree display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3869308221


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -174,10 +174,13 @@ impl Display for DataType {
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
                 let values_str = format_field(values_field);
 
-                write!(f, "{run_ends_str}, {values_str})")?;
+                write!(

Review Comment:
   > what would be the use cases of building a REE with a slightly different name. I'll include this in the PR but im not sure that this code path would be hit.
   
   mainly for consistency with how list treats such fields; it omits the default `item` name but if theres a custom name it explicitly outputs 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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3873338932


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -173,11 +173,27 @@ impl Display for DataType {
                 Ok(())
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
+                let default_names =
+                    run_ends_field.name() == "run_ends" && values_field.name() == "values";

Review Comment:
   its a pretty small change so I included it in the revised 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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#issuecomment-5557466174

   > > thinking about it more, im leaning towards keeping the explicit `non-null`; itll keep us aligned with map as well which i think is the only other example of a datatype with a required non-null, and it currently will always display it
   > 
   > ill bump this comment
   
   @Jefffrey missed this. latest commit include this 👍 


-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3970477709


##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -597,20 +610,52 @@ impl<'a> Parser<'a> {
         }
     }
 
-    /// Parses the next RunEndEncoded (called after `RunEndEncoded` has been consumed)
-    /// E.g: RunEndEncoded("run_ends": UInt32, "values": nonnull Int32)
+    /// Parses the next RunEndEncoded (called after `RunEndEncoded` has been consumed).
+    ///
+    /// Compact form (default field names): `RunEndEncoded(non-null Int32, non-null Utf8)`
+    /// Verbose form (custom field names):  `RunEndEncoded("re": Int32, "v": non-null Utf8)`
     fn parse_run_end_encoded(&mut self) -> ArrowResult<DataType> {
         self.expect_token(Token::LParen)?;
-        let run_ends = self.parse_field()?;
-        self.expect_token(Token::Comma)?;
-        let values = self.parse_field()?;
+
+        // Distinguish compact from verbose by peeking: verbose starts with a double-quoted name.
+        let verbose = matches!(
+            self.tokenizer.peek(),
+            Some(Ok(Token::DoubleQuotedString(_)))
+        );
+
+        let (run_ends, values) = if verbose {
+            let run_ends = self.parse_ree_verbose_field()?;
+            self.expect_token(Token::Comma)?;
+            let values = self.parse_ree_verbose_field()?;
+            (run_ends.with_nullable(false), values)

Review Comment:
   yeah thats something would need to be determined



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3958433360


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -173,11 +174,31 @@ impl Display for DataType {
                 Ok(())
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
+                let default_names = run_ends_field.name() == Field::REE_RUN_ENDS_FIELD_DEFAULT_NAME
+                    && values_field.name() == Field::REE_VALUES_FIELD_DEFAULT_NAME;
                 write!(f, "RunEndEncoded(")?;
-                let run_ends_str = format_field(run_ends_field);
-                let values_str = format_field(values_field);
-
-                write!(f, "{run_ends_str}, {values_str})")?;
+                let re_null = format_nullability(run_ends_field);
+                let v_null = format_nullability(values_field);
+                let v_meta = format_metadata(values_field.metadata());

Review Comment:
   https://github.com/apache/arrow-rs/pull/10840/changes/857c98364a50baf435e1248fd0c1553cbd0e3232 adds this and a test



-- 
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] fix: ree display [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3873028281


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -474,24 +490,34 @@ mod tests {
 
     #[test]
     fn test_display_run_end_encoded() {
+        // Compact form: default field names "run_ends" and "values"
         let run_ends_field = Arc::new(Field::new("run_ends", DataType::UInt32, false));
         let values_field = Arc::new(Field::new("values", DataType::Int32, true));
-        let ree_data_type = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
-        let ree_data_type_string = ree_data_type.to_string();
-        let expected_string = "RunEndEncoded(\"run_ends\": non-null UInt32, \"values\": Int32)";
-        assert_eq!(ree_data_type_string, expected_string);
+        let ree = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
+        assert_eq!(ree.to_string(), "RunEndEncoded(UInt32, Int32)");
+
+        // Compact form: non-null values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let values_field_str = Arc::new(Field::new("values", DataType::Utf8, false));
+        let ree2 = DataType::RunEndEncoded(run_ends_field, values_field_str);
+        assert_eq!(ree2.to_string(), "RunEndEncoded(Int32, non-null Utf8)");
+
+        // Verbose form: non-default field name on values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let named_values = Arc::new(Field::new("named_values", DataType::Utf8, false));
+        let ree3 = DataType::RunEndEncoded(run_ends_field, named_values);
+        assert_eq!(
+            ree3.to_string(),
+            "RunEndEncoded('run_ends': Int32, 'named_values': non-null Utf8)"
+        );
 
-        // Test with metadata

Review Comment:
   we probably should keep the metadata formatting too



##########
arrow-schema/src/datatype_display.rs:
##########
@@ -173,11 +173,27 @@ impl Display for DataType {
                 Ok(())
             }
             Self::RunEndEncoded(run_ends_field, values_field) => {
+                let default_names =
+                    run_ends_field.name() == "run_ends" && values_field.name() == "values";

Review Comment:
   maybe in a followup PR we can create constants for these like so
   
   https://github.com/apache/arrow-rs/blob/4ae884085e52305dab5515f6c21f28e8b537bb06/arrow-schema/src/field.rs#L151-L164



##########
arrow-schema/src/datatype_display.rs:
##########
@@ -474,24 +490,34 @@ mod tests {
 
     #[test]
     fn test_display_run_end_encoded() {
+        // Compact form: default field names "run_ends" and "values"
         let run_ends_field = Arc::new(Field::new("run_ends", DataType::UInt32, false));
         let values_field = Arc::new(Field::new("values", DataType::Int32, true));
-        let ree_data_type = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
-        let ree_data_type_string = ree_data_type.to_string();
-        let expected_string = "RunEndEncoded(\"run_ends\": non-null UInt32, \"values\": Int32)";
-        assert_eq!(ree_data_type_string, expected_string);
+        let ree = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
+        assert_eq!(ree.to_string(), "RunEndEncoded(UInt32, Int32)");
+
+        // Compact form: non-null values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let values_field_str = Arc::new(Field::new("values", DataType::Utf8, false));
+        let ree2 = DataType::RunEndEncoded(run_ends_field, values_field_str);
+        assert_eq!(ree2.to_string(), "RunEndEncoded(Int32, non-null Utf8)");
+
+        // Verbose form: non-default field name on values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let named_values = Arc::new(Field::new("named_values", DataType::Utf8, false));
+        let ree3 = DataType::RunEndEncoded(run_ends_field, named_values);
+        assert_eq!(
+            ree3.to_string(),
+            "RunEndEncoded('run_ends': Int32, 'named_values': non-null Utf8)"

Review Comment:
   map/structs/unions seem to favour double quotes; it seems only lists use single quotes, but thats because its a value and not a key 🤔 
   
   https://github.com/apache/arrow-rs/blob/4ae884085e52305dab5515f6c21f28e8b537bb06/arrow-schema/src/datatype_display.rs#L468
   
   https://github.com/apache/arrow-rs/blob/4ae884085e52305dab5515f6c21f28e8b537bb06/arrow-schema/src/datatype_display.rs#L410
   
   https://github.com/apache/arrow-rs/blob/4ae884085e52305dab5515f6c21f28e8b537bb06/arrow-schema/src/datatype_display.rs#L329



##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -1217,20 +1249,44 @@ mod test {
                 true,
             ),
             DataType::RunEndEncoded(
-                Arc::new(Field::new("run_ends", DataType::UInt32, false)),
+                Arc::new(Field::new("run_ends", DataType::UInt32, true)),
                 Arc::new(Field::new("values", DataType::Int32, true)),
             ),
             DataType::RunEndEncoded(
                 Arc::new(Field::new(
-                    "nested_run_end_encoded",
+                    "run_ends",
                     DataType::RunEndEncoded(
-                        Arc::new(Field::new("run_ends", DataType::UInt32, false)),
+                        Arc::new(Field::new("run_ends", DataType::UInt32, true)),

Review Comment:
   why are these nullabilities changed



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#issuecomment-5442565869

   > > im still unsure on if we should omit the `non-null` for the runs type or not, might be good to get a second opinion
   > 
   > i'm in favor of removing at since its redundant.
   > 
   > @etseidl any thoughts?
   
   Sorry, I'm going to waffle 😅. I see your point about it being required so the `non-null` is redundant, but then I wonder if that's obvious to all consumers of this. I'm fine with whatever you and @Jefffrey agree to. 😄 


-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#discussion_r3873273042


##########
arrow-schema/src/datatype_display.rs:
##########
@@ -474,24 +490,34 @@ mod tests {
 
     #[test]
     fn test_display_run_end_encoded() {
+        // Compact form: default field names "run_ends" and "values"
         let run_ends_field = Arc::new(Field::new("run_ends", DataType::UInt32, false));
         let values_field = Arc::new(Field::new("values", DataType::Int32, true));
-        let ree_data_type = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
-        let ree_data_type_string = ree_data_type.to_string();
-        let expected_string = "RunEndEncoded(\"run_ends\": non-null UInt32, \"values\": Int32)";
-        assert_eq!(ree_data_type_string, expected_string);
+        let ree = DataType::RunEndEncoded(run_ends_field.clone(), values_field.clone());
+        assert_eq!(ree.to_string(), "RunEndEncoded(UInt32, Int32)");
+
+        // Compact form: non-null values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let values_field_str = Arc::new(Field::new("values", DataType::Utf8, false));
+        let ree2 = DataType::RunEndEncoded(run_ends_field, values_field_str);
+        assert_eq!(ree2.to_string(), "RunEndEncoded(Int32, non-null Utf8)");
+
+        // Verbose form: non-default field name on values
+        let run_ends_field = Arc::new(Field::new("run_ends", DataType::Int32, false));
+        let named_values = Arc::new(Field::new("named_values", DataType::Utf8, false));
+        let ree3 = DataType::RunEndEncoded(run_ends_field, named_values);
+        assert_eq!(
+            ree3.to_string(),
+            "RunEndEncoded('run_ends': Int32, 'named_values': non-null Utf8)"

Review Comment:
   will switch



-- 
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] Prettify RunEndEncoded datatype display [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on PR #10840:
URL: https://github.com/apache/arrow-rs/pull/10840#issuecomment-5595709401

   no worries @Jefffrey , I think this one is the one 😄  


-- 
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