@Override
  public RelDataType deriveDecimalModType(
      RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2) {
    return deriveDecimalRelDataType(
        typeFactory,
        type1,
        type2,
        (p1, s1, p2, s2) -> {
          if (s1 == 0 && s2 == 0) {
            return type2;
          }
          DecimalType result = LogicalTypeMerging.findModuloDecimalType(p1, s1, p2, s2);
          return typeFactory.createSqlType(DECIMAL, result.getPrecision(), result.getScale());
        });
  }
Custom type system for Flink.

<p>Copied from flink-1.18.
amoro-format-mixed/amoro-mixed-flink/amoro-mixed-flink-common/src/main/java/org/apache/amoro/flink/planner/calcite/FlinkTypeSystem.java