<?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: Convert columns to rows in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Convert-columns-to-rows/m-p/79168#M82669</link>
    <description>You can materialize this metric table with 60 rows, and then Impala will broadcast it to every node (or Hive will run a map-side join) so it will not affect the shuffling over network.&lt;BR /&gt;However the result set will be N times larger, but that's the point of the query right? (produce from 100k with 10 metrics a 1M table)&lt;BR /&gt;</description>
    <pubDate>Wed, 29 Aug 2018 10:57:00 GMT</pubDate>
    <dc:creator>Tomas79</dc:creator>
    <dc:date>2018-08-29T10:57:00Z</dc:date>
    <item>
      <title>Convert columns to rows</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Convert-columns-to-rows/m-p/79031#M82666</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to convert columns as rows as per user requirement. I know that this can be done using UNION ALL but I have 60 columns need to be converted. If I go with UNION ALL then I would need to write 60 UNION ALLs which will impact the performance.&lt;/P&gt;&lt;P&gt;Is there any direct way of converting columns to rows like using any functions etc.,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 600px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/4799i0B92F984DE10A1E0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 13:37:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Convert-columns-to-rows/m-p/79031#M82666</guid>
      <dc:creator>Srikar</dc:creator>
      <dc:date>2022-09-16T13:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns to rows</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Convert-columns-to-rows/m-p/79054#M82667</link>
      <description>&lt;P&gt;Hi, you dont have to union 60 times,&amp;nbsp;&amp;nbsp;you can do this:&lt;/P&gt;&lt;PRE&gt;select &lt;BR /&gt; t.rowid,&lt;BR /&gt; t.orderdate,&lt;BR /&gt; t.shipmode,&lt;BR /&gt; t.customername,&lt;BR /&gt; t.state,&lt;BR /&gt; m.metric,&lt;BR /&gt; case m.metric&lt;BR /&gt;  when 'sales' then t.sales&lt;BR /&gt;  when 'quantity' then t.quantity&lt;BR /&gt; end value

from mytable t&lt;BR /&gt;cross join ( &lt;BR /&gt;  select 'sales' metric union all&lt;BR /&gt;  select 'quantity' metric &lt;BR /&gt;) m &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 04:33:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Convert-columns-to-rows/m-p/79054#M82667</guid>
      <dc:creator>Tomas79</dc:creator>
      <dc:date>2018-08-27T04:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns to rows</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Convert-columns-to-rows/m-p/79064#M82668</link>
      <description>&lt;P&gt;Hello Tomas79,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, it looks good.&lt;/P&gt;&lt;P&gt;Since we go with cross join doesn't it effect the performance?&lt;/P&gt;&lt;P&gt;If I have 100000 records then if I go with 10 UNION ALL then the count of records will go to 1million.&lt;/P&gt;&lt;P&gt;Is there any suggestion please to improve the performance with this approach?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 11:47:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Convert-columns-to-rows/m-p/79064#M82668</guid>
      <dc:creator>Srikar</dc:creator>
      <dc:date>2018-08-27T11:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert columns to rows</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Convert-columns-to-rows/m-p/79168#M82669</link>
      <description>You can materialize this metric table with 60 rows, and then Impala will broadcast it to every node (or Hive will run a map-side join) so it will not affect the shuffling over network.&lt;BR /&gt;However the result set will be N times larger, but that's the point of the query right? (produce from 100k with 10 metrics a 1M table)&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Aug 2018 10:57:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Convert-columns-to-rows/m-p/79168#M82669</guid>
      <dc:creator>Tomas79</dc:creator>
      <dc:date>2018-08-29T10:57:00Z</dc:date>
    </item>
  </channel>
</rss>

