Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-10169

[Rust] Nulls should be rendered as "" rather than default value when pretty printing arrays

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.0.0
    • Rust

    Description

      Null values should be printed as "" when pretty printing. However, as of now, null values in primative arrays are rendered as the type's default value .

      For example:

          fn test_pretty_format_batches() -> Result<()> {
              // define a schema.
              let schema = Arc::new(Schema::new(vec![
                  Field::new("a", DataType::Utf8, true),
                  Field::new("b", DataType::Int32, true),
              ]));
      
              // define data.
              let batch = RecordBatch::try_new(
                  schema,
                  vec![
                      Arc::new(array::StringArray::from(vec![Some("a"), Some("b"), None, Some("d")])),
                      Arc::new(array::Int32Array::from(vec![Some(1), None, Some(10), Some(100)])),
                  ],
              )?;
      
              println!(pretty_format_batches(&[batch])?);
      
              Ok(())
          }
      

      Outputs:

      +---+-----+
      | a | b   |
      +---+-----+
      | a | 1   |
      | b | 0   |
      |   | 10  |
      | d | 100 |
      +---+-----+
      

      The second row of b should be '', not 0. The third row of a should also be '', which I think t is by accident

      Thanks to jhorstmann horstmann for pointing this out on https://github.com/apache/arrow/pull/8331#issuecomment-702964608

      Attachments

        Issue Links

          Activity

            People

              alamb Andrew Lamb
              alamb Andrew Lamb
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m