[CALCITE-550]: Fix case sensitive issue for subquery when LEX is other t...

...han ORACLE. Add more unit tests for LEX other than ORACLE.

Refactor code and add more unit test.

More unit test.