<?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: Some mathematical (e.g. atan2) and analytical functions (e.g. WIDTH_BUCKET) are not available in hive , which is availabe in other databases . Could you recommend some open source libraries that I can leverage? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Some-mathematical-e-g-atan2-and-analytical-functions-e-g/m-p/167857#M37135</link>
    <description>&lt;A rel="user" href="https://community.cloudera.com/users/12061/mahipalramidi.html" nodeid="12061"&gt;@Mahipal Ramidi&lt;/A&gt;&lt;P&gt;You can have a Hive UDF to achieve the functions. You can alternatively use NTILE which is supported in Hive.&lt;/P&gt;&lt;P&gt;Please refer to below link for current list of Analytical functions:&lt;/P&gt;&lt;P&gt;&lt;A href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics" target="_blank"&gt;https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Aug 2016 13:08:58 GMT</pubDate>
    <dc:creator>ssubhas</dc:creator>
    <dc:date>2016-08-08T13:08:58Z</dc:date>
    <item>
      <title>Some mathematical (e.g. atan2) and analytical functions (e.g. WIDTH_BUCKET) are not available in hive , which is availabe in other databases . Could you recommend some open source libraries that I can leverage?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Some-mathematical-e-g-atan2-and-analytical-functions-e-g/m-p/167856#M37134</link>
      <description>&lt;P&gt;Some mathematical (e.g. atan2) and analytical functions (e.g. WIDTH_BUCKET) are not available in hive , which is availabe in other databases . Could you recommend some open source libraries that I can leverage?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 02:56:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Some-mathematical-e-g-atan2-and-analytical-functions-e-g/m-p/167856#M37134</guid>
      <dc:creator>mahipal_ramidi</dc:creator>
      <dc:date>2016-08-08T02:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Some mathematical (e.g. atan2) and analytical functions (e.g. WIDTH_BUCKET) are not available in hive , which is availabe in other databases . Could you recommend some open source libraries that I can leverage?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Some-mathematical-e-g-atan2-and-analytical-functions-e-g/m-p/167857#M37135</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/12061/mahipalramidi.html" nodeid="12061"&gt;@Mahipal Ramidi&lt;/A&gt;&lt;P&gt;You can have a Hive UDF to achieve the functions. You can alternatively use NTILE which is supported in Hive.&lt;/P&gt;&lt;P&gt;Please refer to below link for current list of Analytical functions:&lt;/P&gt;&lt;P&gt;&lt;A href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics" target="_blank"&gt;https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 13:08:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Some-mathematical-e-g-atan2-and-analytical-functions-e-g/m-p/167857#M37135</guid>
      <dc:creator>ssubhas</dc:creator>
      <dc:date>2016-08-08T13:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Some mathematical (e.g. atan2) and analytical functions (e.g. WIDTH_BUCKET) are not available in hive , which is availabe in other databases . Could you recommend some open source libraries that I can leverage?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Some-mathematical-e-g-atan2-and-analytical-functions-e-g/m-p/167858#M37136</link>
      <description>&lt;P&gt;&lt;A href="https://community.hortonworks.com/users/12061/mahipalramidi.html"&gt;@Mahipal Ramidi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;As Sindhu suggested, you can write your UDF, specifically leveraging Java math library. NTILE divides ordered data set into number of buckets and assigns appropriate bucket number to each row. It can be used to divide rows into equal sets and assign a number to each row. WIDTH_BUCKET, while not far off from NTILE, here we can actually supply the range of values (start and end values), it takes the ranges and splits it into N groups. &lt;/P&gt;&lt;P&gt;You can actually write WIDTH_BUCKET in SQL if you know your number of buckets and assume that is static for your histogram. Her is an example:&lt;/P&gt;&lt;P&gt;SELECT whatever, CASE WHEN(whatever)&amp;gt;=${hiveconf:mymin} AND (t.tiv)&amp;lt;=${hiveconf:mymax}&lt;/P&gt;&lt;P&gt;  THEN CASEWHENfloor((whatever)/((${hiveconf:mymax}– &lt;/P&gt;&lt;P&gt;${hiveconf:mymin})/${ hiveconf:mybuckets}  )+ 1)&amp;gt;${ hiveconf:mybuckets} &lt;/P&gt;&lt;P&gt;THEN floor((t.tiv)/((${hiveconf:mymax}-${ hiveconf:mymin})/${ hiveconf:mybuckets})) ELSE floor((whatever)/((${hiveconf:mymax}-&lt;/P&gt;&lt;P&gt;  ${hiveconf:mymin})/${hiveconf:mybuckets})+1) END ELSE(${hiveconf:mybuckets})+1 END AS whateverlabel FROM(whatever table or sql)&lt;/P&gt;&lt;P&gt;Even is not exactly WIDTH_BUCKET, &lt;A href="https://developers.google.com/chart/interactive/docs/gallery/histogram" target="_blank"&gt;https://developers.google.com/chart/interactive/docs/gallery/histogram&lt;/A&gt; provides a bucketing javascript function useful for histograms. Check the histograms section.&lt;/P&gt;&lt;P&gt;Another good resource: &lt;A href="https://developers.google.com/api-client-library/java/apis/analytics/v3" target="_blank"&gt;https://developers.google.com/api-client-library/java/apis/analytics/v3&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I believe that I knew a good Java library that had WIDTH_BUCKET among other analytical functions, but look at Google resources mentioned above. Most likely, you could leverage those and add yours, custom UDFs.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 03:59:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Some-mathematical-e-g-atan2-and-analytical-functions-e-g/m-p/167858#M37136</guid>
      <dc:creator>cstanca</dc:creator>
      <dc:date>2016-08-09T03:59:15Z</dc:date>
    </item>
  </channel>
</rss>

