aihuaxu opened a new issue, #13676:
URL: https://github.com/apache/iceberg/issues/13676

   ### Feature Request / Improvement
   
   Variant spec for decimals 
(https://github.com/apache/parquet-format/blob/master/VariantEncoding.md) 
requires: 
   
   Decimal Precision | Decimal value type
   -- | --
   1 <= precision <= 9 | int32
   10 <= precision <= 18 | int64
   18 <= precision <= 38 | int128
   \> 38 | Not supported
   
   While we are checking based on the unscaled value size. We need to choose 
different decimal type based on the precision. 
   
   ```
     public static VariantPrimitive<BigDecimal> of(BigDecimal value) {
       int bitLength = value.unscaledValue().bitLength();
       if (bitLength < 32) {
         return new PrimitiveWrapper<>(PhysicalType.DECIMAL4, value);
       } else if (bitLength < 64) {
         return new PrimitiveWrapper<>(PhysicalType.DECIMAL8, value);
       } else if (bitLength < 128) {
         return new PrimitiveWrapper<>(PhysicalType.DECIMAL16, value);
       }
   
       throw new UnsupportedOperationException("Unsupported decimal precision: 
" + value.precision());
     }
   ```
   
   ### Query engine
   
   None
   
   ### Willingness to contribute
   
   - [x] I can contribute this improvement/feature independently
   - [ ] I would be willing to contribute this improvement/feature with 
guidance from the Iceberg community
   - [ ] I cannot contribute this improvement/feature at this time


-- 
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: issues-unsubscr...@iceberg.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to