You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/10/10 06:41:24 UTC
[GitHub] [shardingsphere] cucuzi opened a new issue, #16787: Get select sum decimal precision error
cucuzi opened a new issue, #16787:
URL: https://github.com/apache/shardingsphere/issues/16787
## Bug Report
I select a list, but the decimal is wrong.
using shardingsphere-jdbc: 5.1.0
### Expected behavior
list string:
[BookClassStatistic(classChar=A, classNum=2, bookNum=3, sumPrice=89.10), BookClassStatistic(classChar=B, classNum=2, bookNum=3, sumPrice=121.60), BookClassStatistic(classChar=D, classNum=2, bookNum=2, sumPrice=38.80), BookClassStatistic(classChar=Z, classNum=1, bookNum=2, sumPrice=5.52)]
**By the way, changing database field ( book.price ) type to decimal will get true result.**
### Actual behavior
list string:
[BookClassStatistic(classChar=A, classNum=2, bookNum=3, sumPrice=89.10000228881836), BookClassStatistic(classChar=B, classNum=2, bookNum=3, sumPrice=121.5999984741211), BookClassStatistic(classChar=D, classNum=2, bookNum=2, sumPrice=38.79999923706055), BookClassStatistic(classChar=Z, classNum=1, bookNum=2, sumPrice=5.519999980926514)]
### Example codes
**SELECT SQL**
```
SELECT UPPER(LEFT(bg.class_no, 1)) class_char,
count(DISTINCT (bg.class_no)) class_num,
count(b.id) book_num,
sum(b.price) sum_price
FROM book b
JOIN bibliography bg ON b.bibliography_id = bg.id
WHERE b.user_id = ?
GROUP BY class_char
```
**Object**
```
@Data
public class BookClassStatistic {
private String classChar;
private Integer classNum;
private Integer bookNum;
private BigDecimal sumPrice;
}
```
**Sharding rule**
```
spring:
shardingsphere:
rules:
sharding:
tables:
book:
actual-data-nodes: db0.book_$->{0..2}
table-strategy:
standard:
sharding-column: user_id
sharding-algorithm-name: table-inline
key-generate-strategy:
column: id
key-generator-name: snowflake
sharding-algorithms:
table-inline:
type: INLINE
props:
algorithm-expression: book_$->{user_id % 3}
```
**SQL FILE**
[demo1.zip](https://github.com/apache/shardingsphere/files/8478431/demo1.zip)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] github-actions[bot] closed issue #16787: Get select sum decimal precision error
Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #16787: Get select sum decimal precision error
URL: https://github.com/apache/shardingsphere/issues/16787
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Get select sum decimal precision error [shardingsphere]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #16787:
URL: https://github.com/apache/shardingsphere/issues/16787#issuecomment-2026020762
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on issue #16787: Get select sum decimal precision error
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #16787:
URL: https://github.com/apache/shardingsphere/issues/16787#issuecomment-1097582004
@cucuzi Thank you for your contribution, I will investigate this issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] github-actions[bot] commented on issue #16787: Get select sum decimal precision error
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #16787:
URL: https://github.com/apache/shardingsphere/issues/16787#issuecomment-1272350037
Hello , this issue has not received a reply for several days.
This issue is supposed to be closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org