@Test
  public void testHashCode() {
    assertTrue(one.hashCode() != two.hashCode());
    assertTrue(zero.hashCode() != one.hashCode());
    assertTrue(zero.hashCode() != two.hashCode());

    assertEquals(zero.hashCode(), new Decimal128(0).hashCode());
    assertEquals(one.hashCode(), new Decimal128(1).hashCode());
    assertEquals(two.hashCode(), new Decimal128(2).hashCode());

    // scaled value might be not equal, but after scaling it should.
    Decimal128 oneScaled = new Decimal128(1L, (short) 3);
    oneScaled.changeScaleDestructive((short) 0);
    assertEquals(one.hashCode(), oneScaled.hashCode());
  }
This code was based on code from Microsoft's PolyBase.
common/src/test/org/apache/hadoop/hive/common/type/TestDecimal128.java