Skip to content

Commit

Permalink
fix: clippy fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
duonganhthu43 committed Apr 5, 2024
1 parent 5b46ee2 commit 1636c16
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 296 deletions.
1 change: 0 additions & 1 deletion dozer-ingestion/aerospike/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,6 @@ pub(crate) fn map_value_to_field(
check_type("int8")?;
let string = value.as_str().ok_or_else(unsupported_type)?;
Ok(Field::Int8(string.parse()?))

}
FieldType::U128 => {
check_type("str")?;
Expand Down
3 changes: 3 additions & 0 deletions dozer-ingestion/tests/test_suite/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ fn assert_record_matches_schema(record: &Record, schema: &Schema, only_match_pk:
FieldType::Int => {
assert!(value.as_int().is_some())
}
FieldType::Int8 => {
assert!(value.as_int().is_some())
}
FieldType::I128 => {
assert!(value.as_i128().is_some())
}
Expand Down
13 changes: 13 additions & 0 deletions dozer-ingestion/tests/test_suite/connectors/object_store/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ fn field_type_to_arrow(field_type: FieldType) -> Option<arrow::datatypes::DataTy
FieldType::UInt => Some(arrow::datatypes::DataType::UInt64),
FieldType::U128 => None,
FieldType::Int => Some(arrow::datatypes::DataType::Int64),
FieldType::Int8 => Some(arrow::datatypes::DataType::Int64),
FieldType::I128 => None,
FieldType::Float => Some(arrow::datatypes::DataType::Float64),
FieldType::Boolean => Some(arrow::datatypes::DataType::Boolean),
Expand Down Expand Up @@ -349,6 +350,18 @@ fn fields_to_arrow<'a, F: IntoIterator<Item = &'a Field>>(
}
Arc::new(builder.finish())
}
FieldType::Int8 => {
let mut builder = arrow::array::Int64Array::builder(count);
for field in fields {
match field {
Field::Int(value) => builder.append_value(*value),
Field::Int8(value) => builder.append_value(*value as i64),
Field::Null => builder.append_null(),
_ => panic!("Unexpected field type"),
}
}
Arc::new(builder.finish())
}
FieldType::I128 => panic!("Unexpected field type"),
FieldType::Float => {
let mut builder = arrow::array::Float64Array::builder(count);
Expand Down
2 changes: 2 additions & 0 deletions dozer-ingestion/tests/test_suite/connectors/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ fn field_type_to_sql(field_type: FieldType) -> Option<String> {
FieldType::UInt => None,
FieldType::U128 => None,
FieldType::Int => Some("INT8".to_string()),
FieldType::Int8 => Some("INT8".to_string()),
FieldType::I128 => None,
FieldType::Float => Some("FLOAT8".to_string()),
FieldType::Boolean => Some("BOOLEAN".to_string()),
Expand Down Expand Up @@ -229,6 +230,7 @@ fn field_to_sql(field: &Field) -> String {
Field::UInt(i) => i.to_string(),
Field::U128(i) => i.to_string(),
Field::Int(i) => i.to_string(),
Field::Int8(i) => i.to_string(),
Field::I128(i) => i.to_string(),
Field::Float(f) => f.to_string(),
Field::Boolean(b) => b.to_string(),
Expand Down
6 changes: 5 additions & 1 deletion dozer-sink-aerospike/src/aerospike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,11 @@ pub(crate) unsafe fn new_record_map(
as_orderedmap_set(map, key, check_alloc(as_integer_new(*v)) as *const as_val);
}
Field::Int8(v) => {
as_orderedmap_set(map, key, check_alloc(as_integer_new((*v).into())) as *const as_val);
as_orderedmap_set(
map,
key,
check_alloc(as_integer_new((*v).into())) as *const as_val,
);
}
Field::I128(v) => {
map_set_str(map, key, v, allocated_strings);
Expand Down
2 changes: 1 addition & 1 deletion dozer-sink-clickhouse/src/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl ClickhouseSink {
) -> Self {
let mut schema = schema.clone();

if table.engine == "CollapsingMergeTree" && schema.fields.len() > 0 {
if table.engine == "CollapsingMergeTree" && !schema.fields.is_empty() {
// get source from any field in schema
let source = schema.fields[0].source.clone();
schema.fields.push(FieldDefinition {
Expand Down
9 changes: 4 additions & 5 deletions dozer-sql/expression/src/comparison/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,10 +862,9 @@ pub fn evaluate_lt(
Field::Float(right_v) => Ok(Field::Boolean((left_v as f64) < *right_v)),
// left: Int, right: Decimal
Field::Decimal(right_v) => {
let left_v_d = Decimal::from_i64(left_v as i64).ok_or(PipelineError::UnableToCast(
format!("{}", left_v),
"Decimal".to_string(),
))?;
let left_v_d = Decimal::from_i64(left_v as i64).ok_or(
PipelineError::UnableToCast(format!("{}", left_v), "Decimal".to_string()),
)?;
Ok(Field::Boolean(left_v_d < right_v))
}
// left: Int, right: String or Text
Expand Down Expand Up @@ -903,7 +902,7 @@ pub fn evaluate_lt(
Field::I128(right_v) => Ok(Field::Boolean(left_v < right_v)),
// left: I128, right: UInt
Field::UInt(right_v) => Ok(Field::Boolean(left_v < (right_v as i128))),

// left: I128, right: U128
Field::U128(right_v) => Ok(Field::Boolean(left_v < (right_v as i128))),
// left: I128, right: Float
Expand Down
Loading

0 comments on commit 1636c16

Please sign in to comment.