title: Can I recursively apply transformations to a Spark dataframe in scala?
body: <p>Noodling around with Spark, using <code>union</code> to build up a suitably large test dataset. This works OK:</p>
  
  <p><code>
  val df = spark.read.json("/opt/spark/examples/src/main/resources/people.json")
  df.union(df).union(df).count()
  </code>
  But I'd like to do something like this:
  <code>
  val df = spark.read.json("/opt/spark/examples/src/main/resources/people.json")
  for (a &lt;- 1 until 10){
    df = df.union(df)
  }
  </code>
  that barfs with error
  <code>
  &lt;console&gt;:27: error: reassignment to val
           df = df.union(df)
              ^
  </code>
  I know this technique would work using python, but this is my first time using scala so I'm unsure of the syntax.</p>
  
  <p>How can I recursively union a dataframe with itself <em>n</em> times?</p>