title: Hive Query with UDF
body: <p>I have some encrypted data in an HDFS csv, that I've created a Hive table for, and I want to run a Hive query that first encrypts the query param, then does the lookup.  I have a UDF that does encryption as follows:</p>
  
  <pre><code>public class ParamEncrypt extends UDF {
  
  public Text evaluate(String name) throws Exception {
  
      String result = new String();
  
      if (name == null) { return null; }
  
      result = ParamData.encrypt(name);
  
      return new Text(result);
  }
  }
  </code></pre>
  
  <p>Then I run the Hive query as:</p>
  
  <pre><code>select * from cc_details where first_name = encrypt('Ann');
  </code></pre>
  
  <p>The problem is, it's running encrypt('Ann') across every single record in the table.  I want it do the encryption once, then do the matchup.  I've tried:</p>
  
  <pre><code>select * from cc_details where first_name in (select encrypt('Ann') from cc_details limit 1);
  </code></pre>
  
  <p>But Hive doesn't support <strong>IN</strong> or select queries in the where clause.</p>
  
  <p>What can I do?</p>
  
  <p>Can I do something like:</p>
  
  <pre><code>select encrypt('Ann') as ann from cc_details where first_name = ann;
  </code></pre>
  
  <p>That also doesn't work because the query parser throws an error saying <strong>ann</strong> is not a known column</p>