There is no concept of indexing in Spark Sql. That is why you are getting error. The fundamental reason why indexing over external data sources is not in the Spark scope is that Spark is not a data management system but a batch data processing engine. Spark Sql provides the interface to run queries.
Hope this will help