TCast constToCol = casts.cast(constType, columnType);
if (constToCol != null) {
TCast colToConst = casts.cast(columnType, constType);
if (colToConst != null) {
TPreptimeValue constValue = right.getPreptimeValue();
ValueSource asColType = castValue(constToCol, constValue, columnType);
TPreptimeValue asColTypeTpv = (asColType == null)
? null
: new TPreptimeValue(columnType, asColType);
ValueSource backToConstType = castValue(colToConst, asColTypeTpv, constType);
if (ValueSources.areEqual(constValue.value(), backToConstType)) {
TPreptimeValue constTpv = new TPreptimeValue(columnType, asColType);
ConstantExpression constCasted = new ConstantExpression(constTpv);
expression.setRight(constCasted);
assert columnType.equals(type(expression.getRight()));