alex-plekhanov commented on a change in pull request #9826:
URL: https://github.com/apache/ignite/pull/9826#discussion_r827927161



##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteTypeCoercion.java
##########
@@ -34,6 +41,61 @@ public IgniteTypeCoercion(RelDataTypeFactory typeFactory, 
SqlValidator validator
         super(typeFactory, validator);
     }
 
+    /** {@inheritDoc} */
+    @Override protected boolean coerceOperandType(
+        SqlValidatorScope scope,
+        SqlCall call,
+        int idx,
+        RelDataType targetType)
+    {
+        if (targetType instanceof UuidType) {
+            SqlNode operand = call.getOperandList().get(idx);
+
+            if (operand instanceof SqlDynamicParam)
+                return false;
+
+            RelDataType fromType = validator.deriveType(scope, operand);
+
+            if (fromType == null)
+                return false;
+
+            if (SqlTypeUtil.inCharFamily(fromType)) {
+                targetType = factory.createTypeWithNullability(targetType, 
fromType.isNullable());
+
+                SqlNode desired = SqlStdOperatorTable.CAST.createCall(
+                    SqlParserPos.ZERO,
+                    operand,
+                    new SqlDataTypeSpec(new SqlUserDefinedTypeNameSpec("UUID", 
SqlParserPos.ZERO),
+                        
SqlParserPos.ZERO).withNullable(targetType.isNullable())
+                );
+
+                call.setOperand(idx, desired);
+                updateInferredType(desired, targetType);
+
+                return true;
+            }
+            else
+                return false;
+

Review comment:
       Redundant NL




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to