HHH-9100 - Improve CAST function support
(cherry picked from commit 137c2daf8171a9fb47df58cb119d23c10fddf105)