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: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to