Skip to content

Commit e301e19

Browse files
authored
Merge pull request #7102 from benesch/slt-float-integer-cast
sqllogictest: correct printing floats as integers
2 parents 3e10e70 + de67876 commit e301e19

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
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(),

test/sqllogictest/arithmetic.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ SELECT 1 + CAST ('5' AS double precision)
259259
----
260260
6
261261

262-
query II
262+
query TT
263263
SELECT CAST ('+Inf' AS double precision), CAST ('inf' AS double precision)
264264
----
265265
inf inf

0 commit comments

Comments
 (0)