[SPARK-4274] [SQL] Fix NPE in printing the details of the query plan