title: Optimizing a Cross Join in Spark SQL
body: <p>Is it possible to optimize Cross Joins in Spark SQL ? The requirement is to populate a column <code>band_id</code> based on age-ranges defined in another table. So far I have been able to implement the same thru a <code>Cross Join</code> and <code>WHERE</code> clause. But, I was hoping if there is a <strong>better</strong> way to code this and alleviate performance issues. Can I use a broadcast hint ? (sql provided below)</p>
  <p>Customer: (10 M records)</p>
  <pre><code>id | name | age
  X1 | John | 22
  V2 | Mark | 29
  F4 | Peter| 42
  </code></pre>
  <p>Age_band table: (10 records)</p>
  <pre><code>band_id | low_age | high_age
  B123    |  10     | 19
  X745    |  20     | 29
  P134    |  30     | 39
  Q245    |  40     | 50
  </code></pre>
  <p>Expected Output:</p>
  <pre><code>id | name | age | band_id
  X1 | John | 22  | X745
  V2 | Mark | 29  | X745
  F4 | Peter| 42  | Q245
  </code></pre>
  <p>Query:</p>
  <pre><code>select
  from cust a
  cross join age_band b
  where a.age between b.low_age and b.high_age;
  </code></pre>
  <p>Please advise.</p>