Skip to content

Commit

Permalink
lint and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 committed Jun 28, 2023
1 parent c6c2790 commit 7fa16f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rust/src/action/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ fn filter_binary(schema: &Schema) -> Schema {
Schema::new(
schema
.get_fields()
.into_iter()
.iter()
.flat_map(|f| match f.get_type() {
SchemaDataType::primitive(p) => {
if p != "binary" {
Expand Down
4 changes: 3 additions & 1 deletion rust/src/action/parquet_read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ fn primitive_parquet_field_to_json_value(field: &Field) -> Result<serde_json::Va
Field::Float(value) => Ok(json!(value)),
Field::Double(value) => Ok(json!(value)),
Field::Str(value) => Ok(json!(value)),
Field::Decimal(decimal) => Ok(serde_json::Value::String(BigInt::from_signed_bytes_be(decimal.data()).to_string())),
Field::Decimal(decimal) => Ok(serde_json::Value::String(
BigInt::from_signed_bytes_be(decimal.data()).to_string(),
)),
Field::TimestampMicros(timestamp) => Ok(serde_json::Value::String(
convert_timestamp_micros_to_string(*timestamp)?,
)),
Expand Down
14 changes: 7 additions & 7 deletions rust/src/writer/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ impl StatsScalar {

let decimal_string = if val.len() > *scale as usize {
let (integer_part, fractional_part) = val.split_at(val.len() - *scale as usize);
if fractional_part.len() == 0 {
if fractional_part.is_empty() {
integer_part.to_string()
} else {
format!("{}.{}", integer_part, fractional_part)
}
} else if *scale < 0 {
let abs_scale = scale.abs() as usize;
let abs_scale = scale.unsigned_abs() as usize;
let decimal_zeros = "0".repeat(abs_scale);
format!("{}{}", val, decimal_zeros)
} else {
Expand Down Expand Up @@ -518,15 +518,15 @@ mod tests {
scale: 3,
precision: 4,
}),
Value::from(1.234),
Value::from("1.234"),
),
(
simple_parquet_stat!(Statistics::Int32, 1234),
Some(LogicalType::Decimal {
scale: -1,
precision: 4,
}),
Value::from(12340.0),
Value::from("12340"),
),
(
simple_parquet_stat!(Statistics::Int32, 737821),
Expand Down Expand Up @@ -563,15 +563,15 @@ mod tests {
scale: 3,
precision: 4,
}),
Value::from(1.234),
Value::from("1.234"),
),
(
simple_parquet_stat!(Statistics::Int64, 1234),
Some(LogicalType::Decimal {
scale: -1,
precision: 4,
}),
Value::from(12340.0),
Value::from("12340"),
),
(
simple_parquet_stat!(Statistics::Int64, 1234),
Expand All @@ -597,7 +597,7 @@ mod tests {
scale: 3,
precision: 16,
}),
Value::from(1243124142314.423),
Value::from("1243124142314.423"),
),
];

Expand Down
9 changes: 7 additions & 2 deletions rust/tests/checkpoint_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod fs_common;
#[cfg(all(feature = "arrow", feature = "parquet"))]
mod simple_checkpoint {
use arrow::datatypes::Schema as ArrowSchema;
use arrow_array::{BinaryArray, RecordBatch, Decimal128Array};
use arrow_array::{BinaryArray, Decimal128Array, RecordBatch};
use arrow_schema::{DataType, Field};
use deltalake::writer::{DeltaWriter, RecordBatchWriter};
use deltalake::*;
Expand Down Expand Up @@ -80,7 +80,12 @@ mod simple_checkpoint {
let mut dt = context.table;
let mut writer = RecordBatchWriter::for_table(&dt)?;

write(&mut writer, &mut dt, get_batch(vec![&[1, 2]], vec![18446744073709551614])?).await?;
write(
&mut writer,
&mut dt,
get_batch(vec![&[1, 2]], vec![18446744073709551614])?,
)
.await?;

// Just checking that this doesn't fail. https://github.com/delta-io/delta-rs/issues/1493
checkpoints::create_checkpoint(&dt).await?;
Expand Down

0 comments on commit 7fa16f5

Please sign in to comment.