Fixed bug in OutputFunction's output name and added SQL generation for Cloud queries.