Skip to content

Commit

Permalink
topk support decimal type, fix decimal256 display err
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed Feb 23, 2023
1 parent 46491e0 commit 55680ef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/query/expression/src/utils/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ fn display_decimal_256(num: i256, scale: u8) -> String {
buf,
"{}.{:0>width$}",
num / pow_scale,
num % pow_scale,
num % pow_scale.abs(),
width = scale as usize
)
.unwrap();
Expand Down
6 changes: 5 additions & 1 deletion src/query/storages/common/index/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ pub trait Index {
let inner_type = data_type.remove_nullable();
matches!(
inner_type,
DataType::Number(_) | DataType::Date | DataType::Timestamp | DataType::String
DataType::Number(_)
| DataType::Date
| DataType::Timestamp
| DataType::String
| DataType::Decimal(_)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -330,24 +330,27 @@ statement ok
insert into t(c1) select CAST(0 AS DECIMAL(6, 2))

query I
select * from t order by c1 desc;
select * from t order by c1 desc
----
2.34
0.00
-2.34

query I
select * from t order by c1 asc;
select * from t order by c1 asc
----
-2.34
0.00
2.34

statement error 1067
query I
select * from t order by c1 asc limit 0,2
----
-2.34
0.00

query I
select * from t order by c1 asc limit 1,2;
select * from t order by c1 asc limit 1,2
----
0.00
2.34
Expand Down

0 comments on commit 55680ef

Please sign in to comment.