'save output over Scala spark

I executed one simple SQL query and wanted to save the output as a text file on my server. It started to run for almost 3 days and nothing happened. Can you say what is the problem? Or maybe what other codes can I use to save and measure the run time of queries over spark scala?

val in = spark.read.option("header","true").csv("mytablename.csv")
in.registerTempTable("mytablename")
val dn = spark.sql("select * from mytablename").show(10)
val df = spark.time(df.show(10))
df.write.text("file://hadoop/location/text.txt")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source