static boolean isDecimalType()

in c3r-sdk-parquet/src/main/java/com/amazonaws/c3r/data/ParquetDataType.java [160:181]


    static boolean isDecimalType(final org.apache.parquet.schema.Type type) {
        if (!type.isPrimitive()) {
            return false;
        }
        final PrimitiveType pt = type.asPrimitiveType();
        final LogicalTypeAnnotation annotation = pt.getLogicalTypeAnnotation();
        // Multiple primitive types can be used to store DECIMAL values depending on the precision
        if ((pt.getPrimitiveTypeName().equals(PrimitiveTypeName.INT32)
                || pt.getPrimitiveTypeName().equals(PrimitiveTypeName.INT64)
                || pt.getPrimitiveTypeName().equals(PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY)
                || pt.getPrimitiveTypeName().equals(PrimitiveTypeName.BINARY)) && type.getLogicalTypeAnnotation() != null) {
            /*
             * Because the decimal annotation is a parameterized type (LogicalTypeAnnotation.decimalType(scale, precision)),
             * we can't do a direct equality check of the type name since the scale and precision information isn't known here:
             *   type.getLogicalAnnotation().equals(LogicalTypeAnnotation.decimalType(scale, precision)
             * Regardless of scale and precision, all are an instance of the DecimalLogicalTypeAnnotation class so we use:
             *   type.getLogicalTypeAnnotation() instanceof LogicalTypeAnnotation.DecimalLogicalTypeAnnotation
             */
            return annotation instanceof LogicalTypeAnnotation.DecimalLogicalTypeAnnotation;
        }
        return false;
    }