Yes, Apache Spark SQL is lazy.
In Spark, the concept of “laziness” refers to the fact that computations are not executed immediately when they are invoked, but rather are recorded and executed only when an action is called. This means that Spark will not execute any transformations or computations on the data until an action is called, such as
For example, when you write a query using Spark SQL, the query is not executed immediately. Instead, it is recorded and analyzed, and a logical execution plan is constructed. This logical plan is then optimized and executed only when an action is called. This allows Spark to optimize the execution plan by taking into account the entire data flow, rather than executing each query or transformation as it is encountered.
When it comes to Spark SQL, the execution of a SQL query is also recorded, and executed only when an action is called. This allows Spark to optimize the query for the specific data source it is reading from. For example, if the data is stored in Parquet or ORC files, Spark can use specific readers for those file formats to optimize the query execution.
In summary, Spark SQL is lazy, which means that it does not execute the query immediately but records it and waits for the action to be called. This allows Spark to optimize the execution plan and execute the query efficiently.
Spark important urls to refer