[SPARK-3688][SQL]LogicalPlan can't resolve column correctlly

we should add some judgements base on the datatype to handle some particular sql described in https://issues.apache.org/jira/browse/SPARK-3688
It would be good to add some test cases to make sure errors are thrown for some of the ambiguous cases that were brought up in the PR discussion.