title: How to swap minus sign from last position in a string to first position in hive?
body: <p>How to swap negative sign from last position to first in a string  or integer to first position in hive and/ spark?</p>
  
  <p>example:  22-</p>
  
  <p>required:  -22</p>
  
  <p>My code is:</p>
  
  <pre><code>val Validation1 = spark.sql("Select case when substr(YTTLSVAL-,-1,1)='-' then cast(concat('-',substr(YTTLSVAL-,1,length(YTTLSVAL-)-1)) as int) else cast(YTTLSVAL- as int) end as column_name") 
  </code></pre>