public static SqlDecimal widen(final SqlType t0, final SqlType t1) {
    final SqlDecimal lDecimal = DecimalUtil.toSqlDecimal(t0);
    final SqlDecimal rDecimal = DecimalUtil.toSqlDecimal(t1);

    final int wholePrecision = Math.max(
        lDecimal.getPrecision() - lDecimal.getScale(),
        rDecimal.getPrecision() - rDecimal.getScale()
    );

    final int scale = Math.max(lDecimal.getScale(), rDecimal.getScale());

    return SqlTypes.decimal(wholePrecision + scale, scale);
  }
@Test
  public void shouldWidenDecimalAndDecimal() {
    assertThat(
        "first contained",
        DecimalUtil.widen(
            SqlTypes.decimal(1, 0),
            SqlTypes.decimal(14, 3)
        ),
        is(SqlTypes.decimal(14, 3))
    );

    assertThat(
        "second contained",
        DecimalUtil.widen(
            SqlTypes.decimal(14, 3),
            SqlTypes.decimal(1, 0)
        ),
        is(SqlTypes.decimal(14, 3))
    );

    assertThat(
        "fractional",
        DecimalUtil.widen(
            SqlTypes.decimal(14, 14),
            SqlTypes.decimal(1, 1)
        ),
        is(SqlTypes.decimal(14, 14))
    );

    assertThat(
        "overlap",
        DecimalUtil.widen(
            SqlTypes.decimal(14, 4),
            SqlTypes.decimal(14, 5)
        ),
        is(SqlTypes.decimal(15, 5))
    );
  }