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

Commit

Permalink
Added test showing support for logical types.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Oct 6, 2021
1 parent fc94dc6 commit a1232ff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/it/io/avro/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ fn schema() -> (AvroSchema, Schema) {
{"name": "a", "type": "long"},
{"name": "b", "type": "string"},
{"name": "c", "type": "int"},
{
"name": "date",
"type": "int",
"logicalType": "date"
},
{"name": "d", "type": "bytes"},
{"name": "e", "type": "double"},
{"name": "f", "type": "boolean"},
Expand Down Expand Up @@ -52,6 +57,7 @@ fn schema() -> (AvroSchema, Schema) {
Field::new("a", DataType::Int64, false),
Field::new("b", DataType::Utf8, false),
Field::new("c", DataType::Int32, false),
Field::new("date", DataType::Date32, false),
Field::new("d", DataType::Binary, false),
Field::new("e", DataType::Float64, false),
Field::new("f", DataType::Boolean, false),
Expand Down Expand Up @@ -86,6 +92,7 @@ fn write() -> Result<(Vec<u8>, RecordBatch)> {
record.put("a", 27i64);
record.put("b", "foo");
record.put("c", 1i32);
record.put("date", 1i32);
record.put("d", b"foo".as_ref());
record.put("e", 1.0f64);
record.put("f", true);
Expand All @@ -109,6 +116,7 @@ fn write() -> Result<(Vec<u8>, RecordBatch)> {
record.put("b", "bar");
record.put("a", 47i64);
record.put("c", 1i32);
record.put("date", 2i32);
record.put("d", b"bar".as_ref());
record.put("e", 2.0f64);
record.put("f", false);
Expand Down Expand Up @@ -140,6 +148,7 @@ fn write() -> Result<(Vec<u8>, RecordBatch)> {
Arc::new(Int64Array::from_slice([27, 47])) as Arc<dyn Array>,
Arc::new(Utf8Array::<i32>::from_slice(["foo", "bar"])) as Arc<dyn Array>,
Arc::new(Int32Array::from_slice([1, 1])) as Arc<dyn Array>,
Arc::new(Int32Array::from_slice([1, 2]).to(DataType::Date32)) as Arc<dyn Array>,
Arc::new(BinaryArray::<i32>::from_slice([b"foo", b"bar"])) as Arc<dyn Array>,
Arc::new(PrimitiveArray::<f64>::from_slice([1.0, 2.0])) as Arc<dyn Array>,
Arc::new(BooleanArray::from_slice([true, false])) as Arc<dyn Array>,
Expand Down

0 comments on commit a1232ff

Please sign in to comment.