<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: status of groovy custom udfs in beeline in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/status-of-groovy-custom-udfs-in-beeline/m-p/101443#M14142</link>
    <description>&lt;P&gt;This is definitely a beeline bug of quoting in the hive-1.2.x branch - &lt;A href="https://github.com/apache/hive/commit/36f7ed781271550f3a18c5995effbd53a51a2402"&gt;https://github.com/apache/hive/commit/36f7ed781271...&lt;/A&gt;

I tried this in the latest builds and it worked (though needs to collapse code into a 1 line compile command), but does not work with old beeline + new HS2.
&lt;/P&gt;&lt;PRE&gt;Beeline version 2.1.0-SNAPSHOT by Apache Hive
0: jdbc:hive2://localhost:10003&amp;gt; compile `import org.apache.hadoop.hive.ql.exec.UDF \; import groovy.json.JsonSlurper \; import org.apache.hadoop.io.Text \; public class JsonExtract extends UDF { public int evaluate(Text a){ def jsonSlurper = new JsonSlurper() \; def obj = jsonSlurper.parseText(a.toString())\; return obj.val1\; } } ` AS GROOVY NAMED json_extract.groovy;&lt;/PRE&gt;&lt;PRE&gt;No rows affected (1.092 seconds)&lt;/PRE&gt;&lt;PRE&gt;0: jdbc:hive2://localhost:10003&amp;gt; CREATE TEMPORARY FUNCTION json_extract as 'JsonExtract';&lt;/PRE&gt;&lt;PRE&gt;No rows affected (1.421 seconds)&lt;/PRE&gt;&lt;PRE&gt;0: jdbc:hive2://localhost:10003&amp;gt; 0: jdbc:hive2://localhost:10003&amp;gt; &lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Jan 2016 08:30:21 GMT</pubDate>
    <dc:creator>gopalv</dc:creator>
    <dc:date>2016-01-06T08:30:21Z</dc:date>
    <item>
      <title>status of groovy custom udfs in beeline</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/status-of-groovy-custom-udfs-in-beeline/m-p/101442#M14141</link>
      <description>&lt;P&gt;I'm experimenting with Groovy scripts as custom UDFs in Hive and I noticed that I can't use the same syntax in beeline as in hive shell for executing custom UDFs. Is it a supported feature and syntax is different or is it not supported altogether?&lt;/P&gt;&lt;P&gt;The following works as is in hive shell, in beeline it throws error&lt;/P&gt;&lt;P&gt;compile `import &lt;A href="http://org.apache.hadoop.hive.ql.exec.udf"&gt;org.apache.hadoop.hive.ql.exec.UDF&lt;/A&gt; \;&lt;/P&gt;&lt;P&gt;import &lt;A href="http://groovy.json.jsonslurper"&gt;groovy.json.JsonSlurper&lt;/A&gt; \;&lt;/P&gt;&lt;P&gt;import &lt;A href="http://org.apache.hadoop.io.text"&gt;org.apache.hadoop.io.Text&lt;/A&gt; \;&lt;/P&gt;&lt;P&gt;public class JsonExtract extends UDF {&lt;/P&gt;&lt;P&gt;  public int evaluate(Text a){&lt;/P&gt;&lt;P&gt;    def jsonSlurper = new JsonSlurper() \;&lt;/P&gt;&lt;P&gt;    def obj = &lt;A href="http://jsonslurper.parsetext"&gt;jsonSlurper.parseText&lt;/A&gt;(&lt;A href="http://a.tostring"&gt;a.toString&lt;/A&gt;())\;&lt;/P&gt;&lt;P&gt;    return  obj.val1\;&lt;/P&gt;&lt;P&gt;  }&lt;/P&gt;&lt;P&gt;} ` AS GROOVY NAMED json_&lt;A href="http://extract.groovy"&gt;extract.groovy&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;hive&amp;gt; CREATE TEMPORARY FUNCTION json_extract as 'JsonExtract';&lt;/P&gt;&lt;P&gt;hive&amp;gt; select json_extract('{"val1": 2}') from date_dim limit 1;&lt;/P&gt;&lt;P&gt;select json_extract('{"val1": 2}') from date_dim limit 1&lt;/P&gt;&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 23:29:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/status-of-groovy-custom-udfs-in-beeline/m-p/101442#M14141</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2016-01-05T23:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: status of groovy custom udfs in beeline</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/status-of-groovy-custom-udfs-in-beeline/m-p/101443#M14142</link>
      <description>&lt;P&gt;This is definitely a beeline bug of quoting in the hive-1.2.x branch - &lt;A href="https://github.com/apache/hive/commit/36f7ed781271550f3a18c5995effbd53a51a2402"&gt;https://github.com/apache/hive/commit/36f7ed781271...&lt;/A&gt;

I tried this in the latest builds and it worked (though needs to collapse code into a 1 line compile command), but does not work with old beeline + new HS2.
&lt;/P&gt;&lt;PRE&gt;Beeline version 2.1.0-SNAPSHOT by Apache Hive
0: jdbc:hive2://localhost:10003&amp;gt; compile `import org.apache.hadoop.hive.ql.exec.UDF \; import groovy.json.JsonSlurper \; import org.apache.hadoop.io.Text \; public class JsonExtract extends UDF { public int evaluate(Text a){ def jsonSlurper = new JsonSlurper() \; def obj = jsonSlurper.parseText(a.toString())\; return obj.val1\; } } ` AS GROOVY NAMED json_extract.groovy;&lt;/PRE&gt;&lt;PRE&gt;No rows affected (1.092 seconds)&lt;/PRE&gt;&lt;PRE&gt;0: jdbc:hive2://localhost:10003&amp;gt; CREATE TEMPORARY FUNCTION json_extract as 'JsonExtract';&lt;/PRE&gt;&lt;PRE&gt;No rows affected (1.421 seconds)&lt;/PRE&gt;&lt;PRE&gt;0: jdbc:hive2://localhost:10003&amp;gt; 0: jdbc:hive2://localhost:10003&amp;gt; &lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jan 2016 08:30:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/status-of-groovy-custom-udfs-in-beeline/m-p/101443#M14142</guid>
      <dc:creator>gopalv</dc:creator>
      <dc:date>2016-01-06T08:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: status of groovy custom udfs in beeline</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/status-of-groovy-custom-udfs-in-beeline/m-p/101444#M14143</link>
      <description>&lt;P&gt;Glad that's its not an abandoned feature. Are there more examples and/or docs available? I created a few of my own but I think we need better examples. Thank you &lt;A rel="user" href="https://community.cloudera.com/users/301/gopal.html" nodeid="301"&gt;@gopal&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 08:40:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/status-of-groovy-custom-udfs-in-beeline/m-p/101444#M14143</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2016-01-06T08:40:40Z</dc:date>
    </item>
  </channel>
</rss>

