Spark SQL broadcast hash join
<p>I'm trying to perform a broadcast hash join on dataframes using SparkSQL as documented here: <a href="https://docs.cloud.databricks.com/docs/latest/databricks_guide/06%20Spark%20SQL%20%26%20DataFrames/05%20BroadcastHashJoin%20-%20scala.html" rel="noreferrer">https://docs.cloud.databricks.com/docs/latest/databricks_guide/06%20Spark%20SQL%20%26%20DataFrames/05%20BroadcastHashJoin%20-%20scala.html</a></p>

<p>In that example, the (small) <code>DataFrame</code> is persisted via saveAsTable and then there's a join via spark SQL (i.e. via <code>sqlContext.sql("..."))</code></p>

<p>The problem I have is that I need to use the sparkSQL API to construct my SQL (I am left joining ~50 tables with an ID list, and don't want to write the SQL by hand).  </p>

<pre><code>How do I tell spark to use the broadcast hash join via the API?  The issue is that if I load the ID list (from the table persisted via `saveAsTable`) into a `DataFrame` to use in the join, it isn't clear to me if Spark can apply the broadcast hash join.
</code></pre>