DonnyZone commented on a change in pull request #1899: [CALCITE-3898]
RelOptPredicateList may generate incorrect map of cons…
URL: https://github.com/apache/calcite/pull/1899#discussion_r404497632
##########
File path: core/src/main/java/org/apache/calcite/rex/RexUtil.java
##########
@@ -454,15 +454,48 @@ private static void decompose(Set<RexNode> set, RexNode
rexNode) {
* <li>{@code canAssignFrom(BIGINT, VARCHAR)} returns {@code false}</li>
* </ul>
*/
- private static boolean canAssignFrom(RelDataType type1, RelDataType type2) {
+ private static boolean canAssignFrom(RelDataType type1, RelDataType type2,
+ RelDataTypeFactory typeFactory) {
final SqlTypeName name1 = type1.getSqlTypeName();
final SqlTypeName name2 = type2.getSqlTypeName();
if (name1.getFamily() == name2.getFamily()) {
switch (name1.getFamily()) {
case NUMERIC:
- return name1.compareTo(name2) >= 0;
+ if (SqlTypeUtil.isExactNumeric(type1)
+ && SqlTypeUtil.isExactNumeric(type2)) {
+ int precision1;
+ int scale1;
+ if (name1 == SqlTypeName.DECIMAL) {
+ precision1 = type1.getPrecision();
Review comment:
Do we need to consider `JavaType`, which returns an invalid `precision` and
`scale`.
It is specially handled in many places, e.g.,
`RelDataTypeSystem#deriveDecimalPlusType/deriveDecimalMultiplyType...`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services