Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Fixed error
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Aug 24, 2021
1 parent a9932a6 commit 6ebce50
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/array/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ macro_rules! dyn_dict {
.downcast_ref::<DictionaryArray<$ty>>()
.unwrap();
let keys = a.keys();
let display = get_value_display(a.values().as_ref());
let display = get_display(a.values().as_ref());
Box::new(move |row: usize| display(keys.value(row) as usize))
}};
}
Expand Down
25 changes: 25 additions & 0 deletions tests/it/io/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,31 @@ fn write_dictionary() -> Result<()> {
Ok(())
}

#[test]
fn dictionary_validities() -> Result<()> {
// define a schema.
let field_type = DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::Int32));
let schema = Arc::new(Schema::new(vec![Field::new("d1", field_type, true)]));

let keys = PrimitiveArray::<i32>::from([Some(1), None, Some(0)]);
let values = PrimitiveArray::<i32>::from([None, Some(10)]);
let array = DictionaryArray::<i32>::from_data(keys, Arc::new(values));

let batch = RecordBatch::try_new(schema, vec![Arc::new(array)])?;

let table = write(&[batch]);

let expected = vec![
"+----+", "| d1 |", "+----+", "| 10 |", "| |", "| |", "+----+",
];

let actual: Vec<&str> = table.lines().collect();

assert_eq!(expected, actual, "Actual result:\n{}", table);

Ok(())
}

/// Generate an array with type $ARRAYTYPE with a numeric value of
/// $VALUE, and compare $EXPECTED_RESULT to the output of
/// formatting that array with `write`
Expand Down

0 comments on commit 6ebce50

Please sign in to comment.