Skip to content

Commit 1cd8789

Browse files
author
Devdutt Shenoi
committed
style: anyhow::Result
1 parent aa0befa commit 1cd8789

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/event/format/mod.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::{
2424
sync::Arc,
2525
};
2626

27-
use anyhow::{anyhow, Error as AnyError};
27+
use anyhow::anyhow;
2828
use arrow_array::RecordBatch;
2929
use arrow_schema::{DataType, Field, Schema, TimeUnit};
3030
use chrono::{DateTime, Utc};
@@ -119,14 +119,14 @@ pub trait EventFormat: Sized {
119119
schema_version: SchemaVersion,
120120
) -> anyhow::Result<(EventSchema, IsFirstEvent)>;
121121

122-
fn decode(data: Self::Data, schema: Arc<Schema>) -> Result<RecordBatch, AnyError>;
122+
fn decode(data: Self::Data, schema: Arc<Schema>) -> anyhow::Result<RecordBatch>;
123123

124124
/// Updates inferred schema with `p_timestamp` field and ensures it adheres to expectations
125125
fn prepare_and_validate_schema(
126126
mut schema: EventSchema,
127127
storage_schema: &HashMap<String, Arc<Field>>,
128128
static_schema_flag: bool,
129-
) -> Result<EventSchema, AnyError> {
129+
) -> anyhow::Result<EventSchema> {
130130
if get_field(&schema, DEFAULT_TIMESTAMP_KEY).is_some() {
131131
return Err(anyhow!("field {DEFAULT_TIMESTAMP_KEY} is a reserved field",));
132132
}
@@ -160,7 +160,7 @@ pub trait EventFormat: Sized {
160160
schema: &EventSchema,
161161
time_partition: Option<&String>,
162162
schema_version: SchemaVersion,
163-
) -> Result<RecordBatch, AnyError> {
163+
) -> anyhow::Result<RecordBatch> {
164164
// prepare the record batch and new fields to be added
165165
let mut new_schema = Arc::new(Schema::new(schema.clone()));
166166
new_schema =
@@ -176,7 +176,7 @@ pub trait EventFormat: Sized {
176176
Ok(rb)
177177
}
178178

179-
fn into_event(self, stream: &Stream) -> Result<Event, AnyError>;
179+
fn into_event(self, stream: &Stream) -> anyhow::Result<Event>;
180180
}
181181

182182
pub fn get_existing_field_names(
@@ -234,7 +234,7 @@ pub fn update_field_type_in_schema(
234234
inferred_schema: Arc<Schema>,
235235
existing_schema: Option<&HashMap<String, Arc<Field>>>,
236236
time_partition: Option<&String>,
237-
log_records: Option<&[Json]>,
237+
log_records: Option<&Json>,
238238
schema_version: SchemaVersion,
239239
) -> Arc<Schema> {
240240
let mut updated_schema = inferred_schema.clone();
@@ -245,11 +245,9 @@ pub fn update_field_type_in_schema(
245245
updated_schema = override_existing_timestamp_fields(existing_schema, updated_schema);
246246
}
247247

248-
if let Some(log_records) = log_records {
249-
for log_record in log_records {
250-
updated_schema =
251-
override_data_type(updated_schema.clone(), log_record.clone(), schema_version);
252-
}
248+
if let Some(log_record) = log_records {
249+
updated_schema =
250+
override_data_type(updated_schema.clone(), log_record.clone(), schema_version);
253251
}
254252

255253
let Some(time_partition) = time_partition else {

0 commit comments

Comments
 (0)