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 shouldWidenBigIntAndDecimal() {
    // Given:
    final SqlDecimal smallerPrecision = SqlTypes.decimal(14, 3);
    final SqlDecimal largerPrecision = SqlTypes.decimal(20, 0);

    // Then:
    assertThat(
        DecimalUtil.widen(smallerPrecision, SqlTypes.BIGINT),
        is(SqlTypes.decimal(22, 3))
    );

    assertThat(
        DecimalUtil.widen(SqlTypes.BIGINT, largerPrecision),
        is(SqlTypes.decimal(20, 0))
    );
  }