This type of error tends to occur when running a SQL query in Spark SQL where result set is not limited. When you run the query on a small data set, it works fine, but as soon as you run the same query on a larger data set, you would likely hit this exception. To increase to a larger limit, add the following line to spark-defaults.conf file.
$ spark.driver.maxResultSize 4G
Hope this will help.