Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions datafusion/common/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ impl ScalarValue {
) {
return _internal_err!("Invalid precision and scale {err}");
}
if *scale <= 0 {
if *scale < 0 {
return _internal_err!("Negative scale is not supported");
}
match i128::from(10).checked_pow((*scale + 1) as u32) {
Expand All @@ -1644,7 +1644,7 @@ impl ScalarValue {
) {
return _internal_err!("Invalid precision and scale {err}");
}
if *scale <= 0 {
if *scale < 0 {
return _internal_err!("Negative scale is not supported");
}
match i256::from(10).checked_pow((*scale + 1) as u32) {
Expand Down Expand Up @@ -5429,8 +5429,7 @@ mod tests {
ScalarValue::new_ten(&DataType::Decimal128(7, 2)).unwrap(),
ScalarValue::Decimal128(Some(1000), 7, 2)
);
// No negative or zero scale
assert!(ScalarValue::new_ten(&DataType::Decimal128(5, 0)).is_err());
// No negative scale
assert!(ScalarValue::new_ten(&DataType::Decimal128(5, -1)).is_err());
// Invalid combination
assert!(ScalarValue::new_ten(&DataType::Decimal128(0, 2)).is_err());
Expand All @@ -5452,8 +5451,7 @@ mod tests {
ScalarValue::new_ten(&DataType::Decimal256(7, 2)).unwrap(),
ScalarValue::Decimal256(Some(1000.into()), 7, 2)
);
// No negative or zero scale
assert!(ScalarValue::new_ten(&DataType::Decimal256(5, 0)).is_err());
// No negative scale
assert!(ScalarValue::new_ten(&DataType::Decimal256(5, -1)).is_err());
// Invalid combination
assert!(ScalarValue::new_ten(&DataType::Decimal256(0, 2)).is_err());
Expand Down
2 changes: 2 additions & 0 deletions datafusion/functions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ uuid = { version = "1.18", features = ["v4"], optional = true }
[dev-dependencies]
arrow = { workspace = true, features = ["test_utils"] }
criterion = { workspace = true }
ctor = { workspace = true }
env_logger = { workspace = true }
rand = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt", "sync"] }

Expand Down
7 changes: 7 additions & 0 deletions datafusion/functions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ pub fn register_all(registry: &mut dyn FunctionRegistry) -> Result<()> {
Ok(())
}

#[cfg(test)]
#[ctor::ctor]
fn init() {
// Enable RUST_LOG logging configuration for test
let _ = env_logger::try_init();
}

#[cfg(test)]
mod tests {
use crate::all_default_functions;
Expand Down
Loading