Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arrow-avro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ authors = { workspace = true }
license = { workspace = true }
keywords = { workspace = true }
include = { workspace = true }
edition = { workspace = true }
edition = "2024"
rust-version = { workspace = true }

[lib]
Expand Down Expand Up @@ -93,4 +93,4 @@ harness = false

[[bench]]
name = "avro_writer"
harness = false
harness = false
10 changes: 5 additions & 5 deletions arrow-avro/benches/avro_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ extern crate criterion;
extern crate once_cell;

use arrow_array::{
ArrayRef, BinaryArray, BooleanArray, Decimal32Array, Decimal64Array, Decimal128Array,
Decimal256Array, FixedSizeBinaryArray, Float32Array, Float64Array, ListArray, PrimitiveArray,
RecordBatch, StringArray, StructArray,
builder::{ListBuilder, StringBuilder},
types::{Int32Type, Int64Type, IntervalMonthDayNanoType, TimestampMicrosecondType},
ArrayRef, BinaryArray, BooleanArray, Decimal128Array, Decimal256Array, Decimal32Array,
Decimal64Array, FixedSizeBinaryArray, Float32Array, Float64Array, ListArray, PrimitiveArray,
RecordBatch, StringArray, StructArray,
};
use arrow_avro::writer::AvroWriter;
use arrow_buffer::i256;
use arrow_schema::{DataType, Field, IntervalUnit, Schema, TimeUnit};
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput};
use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use once_cell::sync::Lazy;
use rand::{
Rng, SeedableRng,
distr::uniform::{SampleRange, SampleUniform},
rngs::StdRng,
Rng, SeedableRng,
};
use std::collections::HashMap;
use std::io::Cursor;
Expand Down
6 changes: 3 additions & 3 deletions arrow-avro/benches/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ extern crate once_cell;
extern crate uuid;

use apache_avro::types::Value;
use apache_avro::{to_avro_datum, Decimal, Schema as ApacheSchema};
use arrow_avro::schema::{Fingerprint, FingerprintAlgorithm, CONFLUENT_MAGIC, SINGLE_OBJECT_MAGIC};
use apache_avro::{Decimal, Schema as ApacheSchema, to_avro_datum};
use arrow_avro::schema::{CONFLUENT_MAGIC, Fingerprint, FingerprintAlgorithm, SINGLE_OBJECT_MAGIC};
use arrow_avro::{reader::ReaderBuilder, schema::AvroSchema};
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput};
use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use once_cell::sync::Lazy;
use std::{hint::black_box, time::Duration};
use uuid::Uuid;
Expand Down
2 changes: 1 addition & 1 deletion arrow-avro/examples/decode_kafka_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
use arrow_array::{Int64Array, RecordBatch, StringArray};
use arrow_avro::reader::ReaderBuilder;
use arrow_avro::schema::{
AvroSchema, Fingerprint, FingerprintAlgorithm, SchemaStore, CONFLUENT_MAGIC,
AvroSchema, CONFLUENT_MAGIC, Fingerprint, FingerprintAlgorithm, SchemaStore,
};
use arrow_schema::ArrowError;

Expand Down
22 changes: 11 additions & 11 deletions arrow-avro/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
// under the License.

use crate::schema::{
make_full_name, Array, Attributes, AvroSchema, ComplexType, Enum, Fixed, Map, Nullability,
PrimitiveType, Record, Schema, Type, TypeName, AVRO_ENUM_SYMBOLS_METADATA_KEY,
AVRO_FIELD_DEFAULT_METADATA_KEY, AVRO_ROOT_RECORD_DEFAULT_NAME,
AVRO_ENUM_SYMBOLS_METADATA_KEY, AVRO_FIELD_DEFAULT_METADATA_KEY, AVRO_ROOT_RECORD_DEFAULT_NAME,
Array, Attributes, AvroSchema, ComplexType, Enum, Fixed, Map, Nullability, PrimitiveType,
Record, Schema, Type, TypeName, make_full_name,
};
use arrow_schema::{
ArrowError, DataType, Field, Fields, IntervalUnit, TimeUnit, UnionFields, UnionMode,
DECIMAL128_MAX_PRECISION, DECIMAL256_MAX_PRECISION,
ArrowError, DECIMAL128_MAX_PRECISION, DECIMAL256_MAX_PRECISION, DataType, Field, Fields,
IntervalUnit, TimeUnit, UnionFields, UnionMode,
};
#[cfg(feature = "small_decimals")]
use arrow_schema::{DECIMAL32_MAX_PRECISION, DECIMAL64_MAX_PRECISION};
Expand Down Expand Up @@ -318,14 +318,14 @@ impl AvroDataType {
Codec::Null => {
return Err(ArrowError::SchemaError(
"Default for `null` type must be JSON null".to_string(),
))
));
}
Codec::Boolean => match default_json {
Value::Bool(b) => AvroLiteral::Boolean(*b),
_ => {
return Err(ArrowError::SchemaError(
"Boolean default must be a JSON boolean".to_string(),
))
));
}
},
Codec::Int32 | Codec::Date32 | Codec::TimeMillis => {
Expand Down Expand Up @@ -387,7 +387,7 @@ impl AvroDataType {
_ => {
return Err(ArrowError::SchemaError(
"Default value must be a JSON array for Avro array type".to_string(),
))
));
}
},
Codec::Map(val_dt) => match default_json {
Expand All @@ -401,7 +401,7 @@ impl AvroDataType {
_ => {
return Err(ArrowError::SchemaError(
"Default value must be a JSON object for Avro map type".to_string(),
))
));
}
},
Codec::Struct(fields) => match default_json {
Expand Down Expand Up @@ -443,7 +443,7 @@ impl AvroDataType {
_ => {
return Err(ArrowError::SchemaError(
"Default value for record/struct must be a JSON object".to_string(),
))
));
}
},
Codec::Union(encodings, _, _) => {
Expand Down Expand Up @@ -1603,7 +1603,7 @@ impl<'a> Maker<'a> {
_ => {
return Err(ArrowError::ParseError(format!(
"Illegal promotion {write_primitive:?} to {read_primitive:?}"
)))
)));
}
};
let mut datatype = self.parse_type(reader_schema, None)?;
Expand Down
4 changes: 2 additions & 2 deletions arrow-avro/src/reader/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

//! Decoder for [`Header`]

use crate::compression::{CompressionCodec, CODEC_METADATA_KEY};
use crate::compression::{CODEC_METADATA_KEY, CompressionCodec};
use crate::reader::vlq::VLQDecoder;
use crate::schema::{Schema, SCHEMA_METADATA_KEY};
use crate::schema::{SCHEMA_METADATA_KEY, Schema};
use arrow_schema::ArrowError;

#[derive(Debug)]
Expand Down
20 changes: 10 additions & 10 deletions arrow-avro/src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@
//! ---
use crate::codec::{AvroField, AvroFieldBuilder};
use crate::schema::{
compare_schemas, AvroSchema, Fingerprint, FingerprintAlgorithm, Schema, SchemaStore,
CONFLUENT_MAGIC, SINGLE_OBJECT_MAGIC,
AvroSchema, CONFLUENT_MAGIC, Fingerprint, FingerprintAlgorithm, SINGLE_OBJECT_MAGIC, Schema,
SchemaStore, compare_schemas,
};
use arrow_array::{Array, RecordBatch, RecordBatchReader};
use arrow_schema::{ArrowError, SchemaRef};
Expand Down Expand Up @@ -717,7 +717,7 @@ impl Decoder {
None => {
return Err(ArrowError::ParseError(
"Missing magic bytes and fingerprint".to_string(),
))
));
}
}
}
Expand Down Expand Up @@ -1291,10 +1291,10 @@ mod test {
use crate::compression::CompressionCodec;
use crate::reader::record::RecordDecoder;
use crate::reader::vlq::VLQDecoder;
use crate::reader::{read_header, Decoder, Reader, ReaderBuilder};
use crate::reader::{Decoder, Reader, ReaderBuilder, read_header};
use crate::schema::{
AvroSchema, Fingerprint, FingerprintAlgorithm, PrimitiveType, Schema as AvroRaw,
SchemaStore, AVRO_ENUM_SYMBOLS_METADATA_KEY, CONFLUENT_MAGIC, SINGLE_OBJECT_MAGIC,
AVRO_ENUM_SYMBOLS_METADATA_KEY, AvroSchema, CONFLUENT_MAGIC, Fingerprint,
FingerprintAlgorithm, PrimitiveType, SINGLE_OBJECT_MAGIC, Schema as AvroRaw, SchemaStore,
};
use crate::test_util::arrow_test_data;
use arrow::array::ArrayDataBuilder;
Expand All @@ -1310,22 +1310,22 @@ mod test {
use arrow_array::types::{Int32Type, IntervalMonthDayNanoType};
use arrow_array::*;
use arrow_buffer::{
i256, Buffer, IntervalMonthDayNano, NullBuffer, OffsetBuffer, ScalarBuffer,
Buffer, IntervalMonthDayNano, NullBuffer, OffsetBuffer, ScalarBuffer, i256,
};
use arrow_schema::{
ArrowError, DataType, Field, FieldRef, Fields, IntervalUnit, Schema, TimeUnit, UnionFields,
UnionMode,
};
use bytes::{Buf, BufMut, Bytes};
use futures::executor::block_on;
use futures::{stream, Stream, StreamExt, TryStreamExt};
use serde_json::{json, Value};
use futures::{Stream, StreamExt, TryStreamExt, stream};
use serde_json::{Value, json};
use std::collections::HashMap;
use std::fs;
use std::fs::File;
use std::io::{BufReader, Cursor, Read};
use std::sync::Arc;
use std::task::{ready, Poll};
use std::task::{Poll, ready};

fn read_file(path: &str, batch_size: usize, utf8_view: bool) -> RecordBatch {
let file = File::open(path).unwrap();
Expand Down
10 changes: 5 additions & 5 deletions arrow-avro/src/reader/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ use crate::codec::{
};
use crate::reader::cursor::AvroCursor;
use crate::schema::Nullability;
use arrow_array::builder::{Decimal128Builder, Decimal256Builder, IntervalMonthDayNanoBuilder};
#[cfg(feature = "small_decimals")]
use arrow_array::builder::{Decimal32Builder, Decimal64Builder};
use arrow_array::builder::{Decimal128Builder, Decimal256Builder, IntervalMonthDayNanoBuilder};
use arrow_array::types::*;
use arrow_array::*;
use arrow_buffer::*;
use arrow_schema::{
ArrowError, DataType, Field as ArrowField, FieldRef, Fields, Schema as ArrowSchema, SchemaRef,
UnionFields, UnionMode, DECIMAL128_MAX_PRECISION, DECIMAL256_MAX_PRECISION,
ArrowError, DECIMAL128_MAX_PRECISION, DECIMAL256_MAX_PRECISION, DataType, Field as ArrowField,
FieldRef, Fields, Schema as ArrowSchema, SchemaRef, UnionFields, UnionMode,
};
#[cfg(feature = "small_decimals")]
use arrow_schema::{DECIMAL32_MAX_PRECISION, DECIMAL64_MAX_PRECISION};
Expand Down Expand Up @@ -3904,8 +3904,8 @@ mod tests {
}

#[test]
fn test_record_append_default_missing_fields_without_projector_defaults_yields_type_nulls_or_empties(
) {
fn test_record_append_default_missing_fields_without_projector_defaults_yields_type_nulls_or_empties()
{
let fields = vec![("a", DataType::Int32, true), ("b", DataType::Utf8, true)];
let mut field_refs: Vec<FieldRef> = Vec::new();
let mut encoders: Vec<Decoder> = Vec::new();
Expand Down
14 changes: 8 additions & 6 deletions arrow-avro/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use arrow_schema::{
UnionMode,
};
use serde::{Deserialize, Serialize};
use serde_json::{json, Map as JsonMap, Value};
use serde_json::{Map as JsonMap, Value, json};
#[cfg(feature = "sha256")]
use sha2::{Digest, Sha256};
use std::cmp::PartialEq;
Expand Down Expand Up @@ -1388,7 +1388,7 @@ fn datatype_to_avro(
_ => {
return Err(ArrowError::SchemaError(
"Map 'entries' field must be Struct(key,value)".into(),
))
));
}
};
let values_schema = process_datatype(
Expand Down Expand Up @@ -1493,7 +1493,7 @@ fn datatype_to_avro(
other => {
return Err(ArrowError::NotYetImplemented(format!(
"Arrow type {other:?} has no Avro representation"
)))
)));
}
};
Ok((val, extras))
Expand Down Expand Up @@ -1979,9 +1979,11 @@ mod tests {
store.lookup(&Fingerprint::Rabin(fp_val)).cloned(),
Some(schema.clone())
);
assert!(store
.lookup(&Fingerprint::Rabin(fp_val.wrapping_add(1)))
.is_none());
assert!(
store
.lookup(&Fingerprint::Rabin(fp_val.wrapping_add(1)))
.is_none()
);
}
Fingerprint::Id(id) => {
unreachable!("This test should only generate Rabin fingerprints")
Expand Down
Loading
Loading