Causal queries can be several. One I encountered was when I skipped to use query locator in my batch apex.
Represents the record set returned by Database.getQueryLocator and used with Batch Apex.
Using string query was giving error though using ‘Database.QueryLocator’ and returning that as below solved the error.
public Database.QueryLocator start(Database.BatchableContext bc){
string accon = ‘Select ID,Name,(Select Id,Company__c FROM CONTACTS) From Account’;
return Database.getQueryLocator(accon);