public static String getNormalisedPartitionValue(String partitionValue, String type) {

    LOG.debug("Converting '" + partitionValue + "' to type: '" + type + "'.");

    if (type.equalsIgnoreCase("tinyint")
    || type.equalsIgnoreCase("smallint")
    || type.equalsIgnoreCase("int")){
      return Integer.toString(Integer.parseInt(partitionValue));
    } else if (type.equalsIgnoreCase("bigint")){
      return Long.toString(Long.parseLong(partitionValue));
    } else if (type.equalsIgnoreCase("float")){
      return Float.toString(Float.parseFloat(partitionValue));
    } else if (type.equalsIgnoreCase("double")){
      return Double.toString(Double.parseDouble(partitionValue));
    } else if (type.startsWith("decimal")){
      // Decimal datatypes are stored like decimal(10,10)
      return new BigDecimal(partitionValue).stripTrailingZeros().toPlainString();
    }
    return partitionValue;
  }
@Test
  public void testConversionToSignificantNumericTypes() {
    assertEquals("1", MetaStoreServerUtils.getNormalisedPartitionValue("0001", "tinyint"));
    assertEquals("1", MetaStoreServerUtils.getNormalisedPartitionValue("0001", "smallint"));
    assertEquals("10", MetaStoreServerUtils.getNormalisedPartitionValue("00010", "int"));
    assertEquals("-10", MetaStoreServerUtils.getNormalisedPartitionValue("-00010", "int"));

    assertEquals("10", MetaStoreServerUtils.getNormalisedPartitionValue("00010", "bigint"));
    assertEquals("-10", MetaStoreServerUtils.getNormalisedPartitionValue("-00010", "bigint"));

    assertEquals("1.01", MetaStoreServerUtils.getNormalisedPartitionValue("0001.0100", "float"));
    assertEquals("-1.01", MetaStoreServerUtils.getNormalisedPartitionValue("-0001.0100", "float"));
    assertEquals("1.01", MetaStoreServerUtils.getNormalisedPartitionValue("0001.010000", "double"));
    assertEquals("-1.01", MetaStoreServerUtils.getNormalisedPartitionValue("-0001.010000", "double"));
    assertEquals("1.01", MetaStoreServerUtils.getNormalisedPartitionValue("0001.0100", "decimal"));
    assertEquals("-1.01", MetaStoreServerUtils.getNormalisedPartitionValue("-0001.0100", "decimal"));
  }