Skip to content

Commit 07c9b2b

Browse files
committed
sqllogictest: correct printing floats as integers
In SQLite's SLT, floats are printed as integers by casting the float to an integer then printing the integer. Our SLT runner was printing floats rounding the float then printing the float with zero digits after the decimal point. This is almost the same thing, except that "0" is printed as "-0" since rust-lang/rust#78618. Future proof the code (and make it work the same way in the nightly coverage build) by following the SQLite approach. Supersedes MaterializeInc#7096.
1 parent 744217d commit 07c9b2b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sqllogictest/src/runner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ fn format_datum(d: Slt, typ: &Type, mode: Mode, col: usize) -> String {
426426
(Type::Integer, Value::Int4(i)) => i.to_string(),
427427
(Type::Integer, Value::Int8(i)) => i.to_string(),
428428
(Type::Integer, Value::Numeric(d)) => format!("{:.0}", d),
429-
(Type::Integer, Value::Float4(f)) => format!("{:.0}", f.trunc()),
430-
(Type::Integer, Value::Float8(f)) => format!("{:.0}", f.trunc()),
429+
(Type::Integer, Value::Float4(f)) => format!("{}", f as i64),
430+
(Type::Integer, Value::Float8(f)) => format!("{}", f as i64),
431431
// This is so wrong, but sqlite needs it.
432432
(Type::Integer, Value::Text(_)) => "0".to_string(),
433433
(Type::Integer, Value::Bool(b)) => i8::from(b).to_string(),

0 commit comments

Comments
 (0)