The patch includes one improvement and one bug fix related to this bug.
One improvement is to eliminate constant casting. Currently, a casting operation remains even if the casting is for constant. This improvement removes a constant casting operation and just replaces it by a pre-casted constant value. This improvement does not allow this bug case.
It also fixes a bug of LogicalPlanner::checkIfBeEvaluatedAtRelation. It works incorrectly if there is no column references (i.e., constant value) which is the same case to this bug. Hyoung jun pointed out this bug in offline, and I included it to this patch.