<?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: Hive in built  function greatest is not working in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206508#M74010</link>
    <description>&lt;A rel="user" href="https://community.cloudera.com/users/12234/2hanuvalluri.html" nodeid="12234"&gt;@Hanu V&lt;/A&gt;&lt;P&gt;To work around your issue, you can explicitly cast to string or int (or whatever your data type should be).&lt;/P&gt;&lt;P&gt;I could reproduce your case:&lt;/P&gt;&lt;PRE&gt;select greatest(month, billed) from sales limit 5;
Error: java.io.IOException: org.apache.hadoop.hive.ql.metadata.HiveException: Error evaluating greatest(month,billed) (state=,code=0)&lt;/PRE&gt;&lt;P&gt;with workaround:&lt;/P&gt;&lt;PRE&gt;select greatest(int(month), int(billed)) from sales limit 5;
+------+--+
| _c0  |
+------+--+
| 8    |
| 8    |
| 8    |
| 8    |
| 2    |
+------+--+&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE&gt;select greatest(string(month), string(billed)) from sales limit 5;
+------+--+
| _c0  |
+------+--+
| 8    |
| 8    |
| 8    |
| 8    |
| 2    |
+------+--+&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Jan 2018 23:41:31 GMT</pubDate>
    <dc:creator>eberezitsky</dc:creator>
    <dc:date>2018-01-30T23:41:31Z</dc:date>
    <item>
      <title>Hive in built  function greatest is not working</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206505#M74007</link>
      <description>&lt;P&gt;I have a requirement to calculate greatest value in multiple columns.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Input:&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;name&lt;/TD&gt;&lt;TD&gt;sub1&lt;/TD&gt;&lt;TD&gt;sub2&lt;/TD&gt;&lt;TD&gt;sub3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;st1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;st2&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;st3&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;18&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;STRONG&gt;expected output:&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;name&lt;/TD&gt;&lt;TD&gt;max_sub&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;st1&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;st2&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;st3&lt;/TD&gt;&lt;TD&gt;18&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;When I try to use greatest function as below, I'm getting&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Failed with exception java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException: &lt;/STRONG&gt;Error evaluating greatest(sub1,sub2,sub3)&lt;/P&gt;&lt;P&gt;select name,greatest(sub1,sub2,sub3) from students;&lt;/P&gt;&lt;P&gt;any other functions or simple udf available?&lt;/P&gt;&lt;P&gt;Note: I cant' use CASE statement as I have to consider around 15 columns.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 07:21:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206505#M74007</guid>
      <dc:creator>2hanu_valluri</dc:creator>
      <dc:date>2018-01-30T07:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Hive in built  function greatest is not working</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206506#M74008</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/12234/2hanuvalluri.html" nodeid="12234"&gt;@Hanu V&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Can you attach a desc extended for your table. Greatest should work provided all the columns have the same datatype and are only primitive types.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 15:43:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206506#M74008</guid>
      <dc:creator>rtrivedi</dc:creator>
      <dc:date>2018-01-30T15:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Hive in built  function greatest is not working</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206507#M74009</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/48175/rtrivedi.html" nodeid="48175"&gt;@rtrivedi&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Attached the screenshot FYR.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/59403-greatest.jpg"&gt;greatest.jpg&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 23:22:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206507#M74009</guid>
      <dc:creator>2hanu_valluri</dc:creator>
      <dc:date>2018-01-30T23:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Hive in built  function greatest is not working</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206508#M74010</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/12234/2hanuvalluri.html" nodeid="12234"&gt;@Hanu V&lt;/A&gt;&lt;P&gt;To work around your issue, you can explicitly cast to string or int (or whatever your data type should be).&lt;/P&gt;&lt;P&gt;I could reproduce your case:&lt;/P&gt;&lt;PRE&gt;select greatest(month, billed) from sales limit 5;
Error: java.io.IOException: org.apache.hadoop.hive.ql.metadata.HiveException: Error evaluating greatest(month,billed) (state=,code=0)&lt;/PRE&gt;&lt;P&gt;with workaround:&lt;/P&gt;&lt;PRE&gt;select greatest(int(month), int(billed)) from sales limit 5;
+------+--+
| _c0  |
+------+--+
| 8    |
| 8    |
| 8    |
| 8    |
| 2    |
+------+--+&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE&gt;select greatest(string(month), string(billed)) from sales limit 5;
+------+--+
| _c0  |
+------+--+
| 8    |
| 8    |
| 8    |
| 8    |
| 2    |
+------+--+&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jan 2018 23:41:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206508#M74010</guid>
      <dc:creator>eberezitsky</dc:creator>
      <dc:date>2018-01-30T23:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Hive in built  function greatest is not working</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206509#M74011</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/12234/2hanuvalluri.html" nodeid="12234"&gt;@Hanu V&lt;/A&gt;&lt;P&gt;This is related to HIVE-12082. This issue exist in Hive1&lt;/P&gt;&lt;P&gt;1) You can either use Hive2 (Interactive HS2)&lt;/P&gt;&lt;P&gt;2) Workaround using explicitly cast to int.&lt;/P&gt;&lt;P&gt;select name, greatest(int(sub1),int(sub2),int(sub3)) from students;&lt;/P&gt;&lt;P&gt;3) Use orc format&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 15:25:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206509#M74011</guid>
      <dc:creator>nramanaiah</dc:creator>
      <dc:date>2018-01-31T15:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Hive in built  function greatest is not working</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206510#M74012</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/37152/nramanaiah.html" nodeid="37152"&gt;@Naresh P R&lt;/A&gt;. Can you please let me know where can I track all the issues like this?&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 03:14:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206510#M74012</guid>
      <dc:creator>2hanu_valluri</dc:creator>
      <dc:date>2018-02-01T03:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Hive in built  function greatest is not working</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206511#M74013</link>
      <description>&lt;P&gt;You can check for the relevant issue in &lt;A href="https://issues.apache.org/jira/browse/HIVE"&gt;&lt;/A&gt;&lt;A href="https://issues.apache.org/jira/browse/HIVE"&gt;HIVE Jira&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 13:19:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-in-built-function-greatest-is-not-working/m-p/206511#M74013</guid>
      <dc:creator>nramanaiah</dc:creator>
      <dc:date>2018-02-01T13:19:50Z</dc:date>
    </item>
  </channel>
</rss>

