title: Spark SQL Ranking for nullable unicode strings
body: <p>We are working on Spark SQL. We are doing ranking using some nullable string fields. </p>
  
  <p>The problem is:  In Spark SQL, <code>null</code> values come first in the ranking. But, We want <code>null</code> value to come in the end. So, we have applied a CASE WHEN logic. As we are having Unicode data, "ZZZZZZZZ" will not be coming in the end. It will be ahead of Japanese, Chinese address lines.</p>
  
  <p>Please let us know, which string constant literal to use for null string values, so that they come in the end in case of ORDER BY.  </p>
  
  <p>I have put sample code below. </p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT CompanyName, 
  ROW_NUMBER() OVER
                      (
                          PARTITION BY O.CompanyName
                          ORDER BY  
                                   CASE WHEN AddressLine1 IS NOT NULL THEN AddressLine1 ELSE "ZZZZZZZZ" END ASC                                 
                      ) AS BestDataForCompany
  FROM CompanyData
  </code></pre>