You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "korlov42 (via GitHub)" <gi...@apache.org> on 2023/06/30 07:42:56 UTC

[GitHub] [ignite-3] korlov42 commented on a diff in pull request #2196: IGNITE-19615: Index is not used while performing SELECT over an indexed column.

korlov42 commented on code in PR #2196:
URL: https://github.com/apache/ignite-3/pull/2196#discussion_r1247545689


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/TypeUtils.java:
##########
@@ -533,6 +535,55 @@ public static NativeType columnType2NativeType(ColumnType columnType, int precis
         }
     }
 
+    /** Checks whether cast operation is necessary in {@code SearchBound}. */
+    public static boolean needCastInSearchBounds(IgniteTypeFactory typeFactory, RelDataType fromType, RelDataType toType) {
+        // Check custom data types first.
+        if (toType.getSqlTypeName() == SqlTypeName.ANY || fromType.getSqlTypeName() == SqlTypeName.ANY) {
+            return customDataTypeNeedCast(typeFactory, fromType, toType);
+        }
+
+        // No need to cast between char and varchar.
+        if (SqlTypeUtil.isCharacter(toType) && SqlTypeUtil.isCharacter(fromType)) {
+            return false;
+        }
+
+        // No need to cast if the source type precedence list
+        // contains target type. i.e. do not cast from
+        // tinyint to int or int to bigint.
+        if (fromType.getPrecedenceList().containsType(toType)
+                && SqlTypeUtil.isIntType(fromType)
+                && SqlTypeUtil.isIntType(toType)) {
+            return false;
+        }
+
+        // Implicit type coercion does not handle nullability.
+        if (SqlTypeUtil.equalSansNullability(typeFactory, fromType, toType)) {
+            return false;
+        }
+        // Should keep sync with rules in SqlTypeCoercionRule.
+        assert SqlTypeUtil.canCastFrom(toType, fromType, true);
+        return true;
+    }
+
+    /**
+     * Checks whether one type can be casted to another if one of type is a custom data type.
+     * This method expects at least one of its arguments to be a custom data type.

Review Comment:
   ```suggestion
        * Checks whether one type can be casted to another if one of type is a custom data type.
        *
        * <p>This method expects at least one of its arguments to be a custom data type.
   ```



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org