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/11/23 08:41:53 UTC

[GitHub] [shardingsphere] strongduanmu commented on issue #22360: About digital presentation,Proxy have different with DB

strongduanmu commented on issue #22360:
URL: https://github.com/apache/shardingsphere/issues/22360#issuecomment-1324712401

   Yes, you are right. Now, ShardingSphere only supports 4 decimal places, which seems to be the behavior of mysql.
   
   ```java
   /**
    * Average aggregation unit.
    */
   @RequiredArgsConstructor
   public final class AverageAggregationUnit implements AggregationUnit {
       
       private BigDecimal count;
       
       private BigDecimal sum;
       
       @Override
       public void merge(final List<Comparable<?>> values) {
           if (null == values || null == values.get(0) || null == values.get(1)) {
               return;
           }
           if (null == count) {
               count = new BigDecimal("0");
           }
           if (null == sum) {
               sum = new BigDecimal("0");
           }
           count = count.add(new BigDecimal(values.get(0).toString()));
           sum = sum.add(new BigDecimal(values.get(1).toString()));
       }
       
       @Override
       public Comparable<?> getResult() {
           if (null == count || BigDecimal.ZERO.equals(count)) {
               return count;
           }
           // TODO use metadata to fetch float number precise for database field
           return sum.divide(count, 4, RoundingMode.HALF_UP);
       }
   }
   ```


-- 
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