Skip to content
Merged
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
27 changes: 25 additions & 2 deletions crates/control_plane/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,16 @@ impl ColumnInfo {
| DataType::UInt8
| DataType::UInt16
| DataType::UInt32
| DataType::UInt64
| DataType::Float32 => {
| DataType::UInt64 => {
column_info.r#type = "fixed".to_string();
column_info.precision = Some(38);
column_info.scale = Some(0);
}
DataType::Float16 | DataType::Float32 | DataType::Float64 => {
column_info.r#type = "real".to_string();
column_info.precision = Some(38);
column_info.scale = Some(16);
}
DataType::Decimal128(precision, scale) | DataType::Decimal256(precision, scale) => {
column_info.r#type = "fixed".to_string();
column_info.precision = Some(i32::from(*precision));
Expand Down Expand Up @@ -773,6 +777,25 @@ mod tests {
assert_eq!(column_info.r#type, "text");
assert_eq!(column_info.byte_length, None);
assert_eq!(column_info.length, None);

let floats = [
(DataType::Float16, 16, true),
(DataType::Float32, 16, true),
(DataType::Float64, 16, true),
(DataType::Float64, 17, false),
];
for (float_datatype, scale, outcome) in floats {
let field = Field::new("test_field", float_datatype, false);
let column_info = ColumnInfo::from_field(&field);
assert_eq!(column_info.name, "test_field");
assert_eq!(column_info.r#type, "real");
assert_eq!(column_info.precision.unwrap(), 38);
if outcome {
assert_eq!(column_info.scale.unwrap(), scale);
} else {
assert_ne!(column_info.scale.unwrap(), scale);
}
}
}

#[tokio::test]
Expand Down
4 changes: 4 additions & 0 deletions crates/control_plane/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,11 @@ mod tests {
assert!(result.is_ok());
let sessions = service.df_sessions.read().await;
assert!(!sessions.contains_key(&session_id));
}

#[tokio::test]
async fn test_delete_non_existent_session() {
let service = service();
let session_id = "non_existent_session".to_string();
let result = service.delete_session(session_id.clone()).await;
assert!(result.is_ok());
Expand Down
11 changes: 9 additions & 2 deletions crates/control_plane/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,11 @@ mod tests {
assert_eq!(converted_timestamp_array.value(2), 1_627_846_262);
}

#[allow(clippy::needless_pass_by_value)]
#[allow(
clippy::needless_pass_by_value,
clippy::cast_sign_loss,
clippy::cast_possible_truncation
)]
fn check_record_batches_uint_to_int(
batches: Vec<RecordBatch>,
converted_batches: Vec<RecordBatch>,
Expand Down Expand Up @@ -540,7 +544,10 @@ mod tests {
assert_eq!(column_info.scale.unwrap(), metadata_scale);
match field.data_type() {
DataType::UInt64 => {
assert_eq!(*converted_field.data_type(), DataType::Decimal128(38, 0));
assert_eq!(
*converted_field.data_type(),
DataType::Decimal128(metadata_precision as u8, metadata_scale as i8)
);
let values: Decimal128Array = converted_column
.as_any()
.downcast_ref::<Decimal128Array>()
Expand Down
Loading