mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-12-05 08:50:58 +00:00
test: cover invalid decimals in gRPC column types and nested arrow types
Signed-off-by: dayan02dev <pawarudayan92@gmail.com>
This commit is contained in:
1 parent
821b44b385
commit
5f16c38538
2 files changed
+31
No files matched your search
@@ -1557,6 +1557,30 @@ mod tests {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_try_new_decimal_column_datatype() {
|
||||
let decimal_ext = |precision, scale| {
|
||||
ColumnDataTypeWrapper::decimal128_datatype(precision, scale).datatype_ext
|
||||
};
|
||||
let wrapper =
|
||||
ColumnDataTypeWrapper::try_new(ColumnDataType::Decimal128 as i32, decimal_ext(10, 2))
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
ConcreteDataType::decimal128_datatype(10, 2),
|
||||
ConcreteDataType::from(wrapper)
|
||||
);
|
||||
for (precision, scale) in [(0, 0), (39, 0), (65, 30), (266, 2), (5, -1), (5, 6)] {
|
||||
assert!(
|
||||
ColumnDataTypeWrapper::try_new(
|
||||
ColumnDataType::Decimal128 as i32,
|
||||
decimal_ext(precision, scale)
|
||||
)
|
||||
.is_err(),
|
||||
"Decimal({precision}, {scale}) should be rejected"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_column_datatype_from_concrete_datatype() {
|
||||
assert_eq!(
|
||||
|
||||
@@ -942,6 +942,13 @@ mod tests {
|
||||
"{arrow_type} should be rejected"
|
||||
);
|
||||
}
|
||||
let invalid_decimal = ArrowDataType::Decimal128(10, -2);
|
||||
let list_type =
|
||||
ArrowDataType::List(Arc::new(Field::new("item", invalid_decimal.clone(), true)));
|
||||
assert!(ConcreteDataType::try_from(&list_type).is_err());
|
||||
let dictionary_type =
|
||||
ArrowDataType::Dictionary(Box::new(ArrowDataType::Int32), Box::new(invalid_decimal));
|
||||
assert!(ConcreteDataType::try_from(&dictionary_type).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user