Spark DAG creation

Hi,

I would like to know as to when exactly a DAG is created. In case a spark job is submitted and in case of spark-shell. I am not talking about DAG scheduler but about DAG of operators.
Will it be generated at the time of parsing(spark submit) or coding(spark-shell) or only at the time when a Action is encountered.
Pleas provide info in detail
ID is sharathc904434

Thanks