[MONDRIAN-1860] avoid executing invalid sql by checking types before
generating.