Implement better resolution of window aggregate return types
Fixes https://issues.apache.org/jira/browse/OPTIQ-292