Got the issue. The problem was that the query was without limits. Pentaho needs Limit in queries. When I changed the above query to
SELECT * FROM surveys LIMIT 1
it worked. Hope this helps others.
There might be other factors which generate the above error, but in this case, it was due to the query.