@Override
    PrimitiveConverter getConverter(final PrimitiveType type, final int index, final ConverterParent parent, TypeInfo hiveTypeInfo) {
      if (hiveTypeInfo != null) {
        String typeName = TypeInfoUtils.getBaseName(hiveTypeInfo.getTypeName());
        final double minValue = getMinValue(typeName, Double.MIN_VALUE);
        final double maxValue = getMaxValue(typeName, Double.MAX_VALUE);

        switch (typeName) {
        case serdeConstants.FLOAT_TYPE_NAME:
          return new PrimitiveConverter() {
            @Override
            public void addBinary(Binary value) {
              HiveDecimalWritable decimalWritable =
                  new HiveDecimalWritable(value.getBytes(), getScale(type));
              setValue(decimalWritable.doubleValue(), decimalWritable.floatValue());
            }

            @Override
            public void addInt(final int value) {
              HiveDecimal hiveDecimal = HiveDecimal.create(value, getScale(type));
              setValue(hiveDecimal.doubleValue(), hiveDecimal.floatValue());
            }

            @Override
            public void addLong(final long value) {
              HiveDecimal hiveDecimal = HiveDecimal.create(value, getScale(type));
              setValue(hiveDecimal.doubleValue(), hiveDecimal.floatValue());
            }

            private void setValue(double doubleValue, float floatValue) {
              double absDoubleValue = (doubleValue < 0) ? (doubleValue * -1) : doubleValue;
              if (((absDoubleValue >= minValue) && (absDoubleValue <= maxValue)) || absDoubleValue == 0d) {
                parent.set(index, new FloatWritable(floatValue));
              } else {
                parent.set(index, null);
              }
            }

            private int getScale(PrimitiveType type) {
              DecimalLogicalTypeAnnotation logicalType = (DecimalLogicalTypeAnnotation) type.getLogicalTypeAnnotation();
              return logicalType.getScale();
            }
          };
        case serdeConstants.DOUBLE_TYPE_NAME:
          return new PrimitiveConverter() {
            @Override
            public void addBinary(Binary value) {
              HiveDecimalWritable decimalWritable =
                  new HiveDecimalWritable(value.getBytes(), getScale(type));
              parent.set(index, new DoubleWritable(decimalWritable.doubleValue()));
            }

            @Override
            public void addInt(final int value) {
              HiveDecimal hiveDecimal = HiveDecimal.create(value, getScale(type));
              parent.set(index, new DoubleWritable(hiveDecimal.doubleValue()));
            }

            @Override
            public void addLong(final long value) {
              HiveDecimal hiveDecimal = HiveDecimal.create(value, getScale(type));
              parent.set(index, new DoubleWritable(hiveDecimal.doubleValue()));
            }

            private int getScale(PrimitiveType type) {
              DecimalLogicalTypeAnnotation logicalType = (DecimalLogicalTypeAnnotation) type.getLogicalTypeAnnotation();
              return logicalType.getScale();
            }
          };
        case serdeConstants.BIGINT_TYPE_NAME:
          return new PrimitiveConverter() {
            @Override
            public void addBinary(Binary value) {
              HiveDecimalWritable decimalWritable =
                  new HiveDecimalWritable(value.getBytes(), getScale(type));
              setValue(decimalWritable.doubleValue(), decimalWritable.longValue());
            }

            @Override
            public void addInt(final int value) {
              HiveDecimal hiveDecimal = HiveDecimal.create(value, getScale(type));
              setValue(hiveDecimal.doubleValue(), hiveDecimal.longValue());
            }

            @Override
            public void addLong(final long value) {
              HiveDecimal hiveDecimal = HiveDecimal.create(value, getScale(type));
              setValue(hiveDecimal.doubleValue(), hiveDecimal.longValue());
            }

            private void setValue(double doubleValue, long longValue) {
              if ((doubleValue >= minValue) && (doubleValue <= maxValue) && (doubleValue % 1 == 0)) {
                parent.set(index, new LongWritable(longValue));
              } else {
                parent.set(index, null);
              }
            }

            private int getScale(PrimitiveType type) {
              DecimalLogicalTypeAnnotation logicalType = (DecimalLogicalTypeAnnotation) type.getLogicalTypeAnnotation();
              return logicalType.getScale();
            }
          };
        case serdeConstants.INT_TYPE_NAME:
        case serdeConstants.SMALLINT_TYPE_NAME:
        case serdeConstants.TINYINT_TYPE_NAME:
          return new PrimitiveConverter() {
            @Override
            public void addBinary(Binary value) {
              HiveDecimalWritable decimalWritable =
                  new HiveDecimalWritable(value.getBytes(), getScale(type));
              setValue(decimalWritable.doubleValue(), decimalWritable.intValue());
            }

            @Override
            public void addInt(final int value) {
              HiveDecimal hiveDecimal = HiveDecimal.create(value, getScale(type));
              setValue(hiveDecimal.doubleValue(), hiveDecimal.intValue());
            }

            @Override
            public void addLong(final long value) {
              HiveDecimal hiveDecimal = HiveDecimal.create(value, getScale(type));
              setValue(hiveDecimal.doubleValue(), hiveDecimal.intValue());
            }

            private void setValue(double doubleValue, int intValue) {
              if ((doubleValue >= minValue) && (doubleValue <= maxValue) && (doubleValue % 1 == 0)) {
                parent.set(index, new IntWritable(intValue));
              } else {
                parent.set(index, null);
              }
            }

            private int getScale(PrimitiveType type) {
              DecimalLogicalTypeAnnotation logicalType = (DecimalLogicalTypeAnnotation) type.getLogicalTypeAnnotation();
              return logicalType.getScale();
            }
          };
        case serdeConstants.CHAR_TYPE_NAME:
          return new BinaryConverterForDecimalType<HiveCharWritable>(type, parent, index, hiveTypeInfo) {
            @Override
            protected HiveCharWritable convert(Binary binary) {
              return new HiveCharWritable(convertToBytes(binary), ((CharTypeInfo) hiveTypeInfo).getLength());
            }
          };
        case serdeConstants.VARCHAR_TYPE_NAME:
          return new BinaryConverterForDecimalType<HiveVarcharWritable>(type, parent, index, hiveTypeInfo) {
            @Override
            protected HiveVarcharWritable convert(Binary binary) {
              return new HiveVarcharWritable(convertToBytes(binary), ((VarcharTypeInfo) hiveTypeInfo).getLength());
            }
          };
        case serdeConstants.STRING_TYPE_NAME:
          return new BinaryConverterForDecimalType<BytesWritable>(type, parent, index, hiveTypeInfo) {
            @Override
            protected BytesWritable convert(Binary binary) {
              return new BytesWritable(convertToBytes(binary));
            }
          };
        default:
          return new BinaryConverter<HiveDecimalWritable>(type, parent, index, hiveTypeInfo) {
            @Override
            protected HiveDecimalWritable convert(Binary binary) {
              DecimalLogicalTypeAnnotation logicalType = (DecimalLogicalTypeAnnotation) type.getLogicalTypeAnnotation();
              return HiveDecimalUtils.enforcePrecisionScale(
                  new HiveDecimalWritable(binary.getBytes(), logicalType.getScale()),
                  (DecimalTypeInfo) hiveTypeInfo);
            }

            // TODO HIVE-27529 Add dictionary encoding support for parquet decimal types
            @Override
            public boolean hasDictionarySupport() {
              return false;
            }
            @Override
            public void addInt(final int value) {
              addDecimal(value);
            }

            @Override
            public void addLong(final long value) {
              addDecimal(value);
            }

            private void addDecimal(long value) {
              DecimalTypeInfo decimalInfo = (DecimalTypeInfo) hiveTypeInfo;
              HiveDecimal hiveDecimal = HiveDecimal.create(value, decimalInfo.scale());
              HiveDecimalWritable result = HiveDecimalUtils.enforcePrecisionScale(new HiveDecimalWritable(hiveDecimal),
                  (DecimalTypeInfo) hiveTypeInfo);
              parent.set(index, result);
            }
          };
        }
      }
      return new BinaryConverter<HiveDecimalWritable>(type, parent, index) {
        @Override
        protected HiveDecimalWritable convert(Binary binary) {
          DecimalLogicalTypeAnnotation logicalType =
              (DecimalLogicalTypeAnnotation) type.getLogicalTypeAnnotation();
          return new HiveDecimalWritable(binary.getBytes(), logicalType.getScale());
        }
      };
    }
ETypeConverter is an easy way to set the converter for the right type.
ql/src/java/org/apache/hadoop/hive/ql/io/parquet/convert/ETypeConverter.java