Source:
public ValueNode bindExpression( FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregateVector) throws StandardException { super.bindExpression(fromList, subqueryList, aggregateVector); TypeId leftType = leftOperand.getTypeId(); TypeId rightType = rightOperand.getTypeId(); DataTypeDescriptor leftDTS = leftOperand.getTypeServices(); DataTypeDescriptor rightDTS = rightOperand.getTypeServices(); if (leftType.isStringTypeId() && rightType.isNumericTypeId()) { boolean nullableResult; nullableResult = leftDTS.isNullable() || rightDTS.isNullable(); int precision = rightDTS.getPrecision(); int scale = rightDTS.getScale(); int maxWidth = rightDTS.getMaximumWidth(); if (rightType.isDecimalTypeId()) { int charMaxWidth = leftDTS.getMaximumWidth(); precision += (2 * charMaxWidth); scale += charMaxWidth; maxWidth = DataTypeUtilities.computeMaxWidth(precision, scale); } leftOperand = (ValueNode) getNodeFactory().getNode( C_NodeTypes.CAST_NODE, leftOperand, new DataTypeDescriptor(rightType, precision, scale, nullableResult, maxWidth), getContextManager()); ((CastNode) leftOperand).bindCastNodeOnly(); } else if (rightType.isStringTypeId() && leftType.isNumericTypeId()) { boolean nullableResult; nullableResult = leftDTS.isNullable() || rightDTS.isNullable(); int precision = leftDTS.getPrecision(); int scale = leftDTS.getScale(); int maxWidth = leftDTS.getMaximumWidth(); if (leftType.isDecimalTypeId()) { int charMaxWidth = rightDTS.getMaximumWidth(); precision += (2 * charMaxWidth); scale += charMaxWidth; maxWidth = precision + 3; } rightOperand = (ValueNode) getNodeFactory().getNode( C_NodeTypes.CAST_NODE, rightOperand, new DataTypeDescriptor(leftType, precision, scale, nullableResult, maxWidth), getContextManager()); ((CastNode) rightOperand).bindCastNodeOnly(); } setType(leftOperand.getTypeCompiler(). resolveArithmeticOperation( leftOperand.getTypeServices(), rightOperand.getTypeServices(), operator ) ); return this; }

Target:
public ValueNode bindExpression( FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregateVector) throws StandardException { super.bindExpression(fromList, subqueryList, aggregateVector); TypeId leftType = leftOperand.getTypeId(); TypeId rightType = rightOperand.getTypeId(); DataTypeDescriptor leftDTS = leftOperand.getTypeServices(); DataTypeDescriptor rightDTS = rightOperand.getTypeServices(); if (leftType.isStringTypeId() && rightType.isNumericTypeId()) { boolean nullableResult; nullableResult = leftDTS.isNullable() || rightDTS.isNullable(); int precision = rightDTS.getPrecision(); int scale = rightDTS.getScale(); int maxWidth = rightDTS.getMaximumWidth(); if (rightType.isDecimalTypeId()) { int charMaxWidth = leftDTS.getMaximumWidth(); precision += (2 * charMaxWidth); scale += charMaxWidth; maxWidth = DataTypeUtilities.computeMaxWidth(precision, scale); } leftOperand = (ValueNode) getNodeFactory().getNode( C_NodeTypes.CAST_NODE, leftOperand, new DataTypeDescriptor(rightType, precision, scale, nullableResult, maxWidth), getContextManager()); ((CastNode) leftOperand).bindCastNodeOnly(); } else if (rightType.isStringTypeId() && leftType.isNumericTypeId()) { boolean nullableResult; nullableResult = leftDTS.isNullable() || rightDTS.isNullable(); int precision = leftDTS.getPrecision(); int scale = leftDTS.getScale(); int maxWidth = leftDTS.getMaximumWidth(); if (leftType.isDecimalTypeId()) { int charMaxWidth = rightDTS.getMaximumWidth(); precision += (2 * charMaxWidth); scale += charMaxWidth; maxWidth = DataTypeUtilities.computeMaxWidth(precision, scale); } rightOperand = (ValueNode) getNodeFactory().getNode( C_NodeTypes.CAST_NODE, rightOperand, new DataTypeDescriptor(leftType, precision, scale, nullableResult, maxWidth), getContextManager()); ((CastNode) rightOperand).bindCastNodeOnly(); } setType(leftOperand.getTypeCompiler(). resolveArithmeticOperation( leftOperand.getTypeServices(), rightOperand.getTypeServices(), operator ) ); return this; }