Skip to content

Commit

Permalink
review comments incorporated
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsinhaparseable committed Dec 10, 2024
1 parent f52bd18 commit 2f56ac7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/event/format/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ fn valid_type(data_type: &DataType, value: &Value) -> bool {
DataType::Boolean => value.is_boolean(),
DataType::Int8 | DataType::Int16 | DataType::Int32 | DataType::Int64 => value.is_i64(),
DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64 => value.is_u64(),
DataType::Float16 | DataType::Float32 | DataType::Float64 => {
value.is_f64() || value.is_i64() || value.is_u64()
}
DataType::Float16 | DataType::Float32 => value.is_f64(),
// NOTE: All numbers can be ingested as Float64
DataType::Float64 => value.is_number(),
DataType::Utf8 => value.is_string(),
DataType::List(field) => {
let data_type = field.data_type();
Expand Down
10 changes: 2 additions & 8 deletions src/event/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,14 @@ pub fn override_timestamp_fields(
Arc::new(Schema::new(updated_fields))
}

/// All number fields from inferred schema are forced into Float64
pub fn override_num_fields_from_schema(schema: Arc<Schema>) -> Arc<Schema> {
Arc::new(Schema::new(
schema
.fields()
.iter()
.map(|field| {
if field.data_type() == &DataType::Int64
|| field.data_type() == &DataType::Int32
|| field.data_type() == &DataType::Int16
|| field.data_type() == &DataType::Int8
|| field.data_type() == &DataType::Float64
|| field.data_type() == &DataType::Float32
|| field.data_type() == &DataType::Float16
{
if field.data_type().is_numeric() {
Arc::new(Field::new(
field.name(),
DataType::Float64,
Expand Down

0 comments on commit 2f56ac7

Please sign in to comment.