<?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: Impala Use Hive UDF With Group By Gives Wrong Result. in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-Use-Hive-UDF-With-Group-By-Gives-Wrong-Result/m-p/46115#M42084</link>
    <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This looks like a bug and can be reproduced&amp;nbsp;even on the latest versions of Impala. Thanks for sharing the repro steps with us. I created a jira&amp;nbsp;&lt;A href="https://issues.cloudera.org/browse/IMPALA-4266" target="_blank"&gt;https://issues.cloudera.org/browse/IMPALA-4266&lt;/A&gt; with a simpler UDF so its easy to follow. Your UDF implementation looks fine and is likely not causing this issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Bharath&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Oct 2016 16:55:26 GMT</pubDate>
    <dc:creator>Bharathv</dc:creator>
    <dc:date>2016-10-10T16:55:26Z</dc:date>
    <item>
      <title>Impala Use Hive UDF With Group By Gives Wrong Result.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-Use-Hive-UDF-With-Group-By-Gives-Wrong-Result/m-p/45679#M42083</link>
      <description>I find impala will give wrong answer if the result of Hive UDF is used in group by statement. The impala version is: 2.7.0-cdh5-IMPALA_KUDU-cdh5 RELEASE. Here is the procedure to reproduce the error:&lt;PRE&gt;impala&amp;gt; create table test_escape_group_by (s string);
impala&amp;gt; insert into table test_escape_group_by values("longstring"), ("short");
impala&amp;gt; select my_escape_string(s) as es from test_escape_group_by;
longstring
short
impala&amp;gt; select my_escape_string(s) as es from test_escape_group_by group by es;
shorttring
short&lt;/PRE&gt;We can see that the beginning part of 'longstring' is replaced by 'short'. Here is the definition of my_escape_string:&lt;PRE&gt;public class MyEscapeString extends UDF
{
  public Text evaluate(Text para) throws ParseException {
    if ((null == para) || ("".equals(para.toString()))) {
      return new Text("");
    }
    return new Text(para.toString().replace("\\", "\\\\").replace("\"", "\\\""));
  }
}&lt;/PRE&gt;My Question: Is this a bug of impala, or how can I rewritten the Java UDF to avoid such errors.</description>
      <pubDate>Fri, 16 Sep 2022 10:42:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-Use-Hive-UDF-With-Group-By-Gives-Wrong-Result/m-p/45679#M42083</guid>
      <dc:creator>linhao</dc:creator>
      <dc:date>2022-09-16T10:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Impala Use Hive UDF With Group By Gives Wrong Result.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-Use-Hive-UDF-With-Group-By-Gives-Wrong-Result/m-p/46115#M42084</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This looks like a bug and can be reproduced&amp;nbsp;even on the latest versions of Impala. Thanks for sharing the repro steps with us. I created a jira&amp;nbsp;&lt;A href="https://issues.cloudera.org/browse/IMPALA-4266" target="_blank"&gt;https://issues.cloudera.org/browse/IMPALA-4266&lt;/A&gt; with a simpler UDF so its easy to follow. Your UDF implementation looks fine and is likely not causing this issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Bharath&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 16:55:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Impala-Use-Hive-UDF-With-Group-By-Gives-Wrong-Result/m-p/46115#M42084</guid>
      <dc:creator>Bharathv</dc:creator>
      <dc:date>2016-10-10T16:55:26Z</dc:date>
    </item>
  </channel>
</rss>

