<?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 Add filename to import in Hive in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Add-filename-to-import-in-Hive/m-p/41944#M31632</link>
    <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to Cloudera and have only used Impala and Hive through Hue thus far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a folder of CSVs that I imported, but would like to add the filename as a column to each row that I import.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I came across the function&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;INPUT__FILE__NAME&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but I don't see it actually doing anything.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My import is very easy - hoping you can help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create external table hive_magnum&lt;BR /&gt;(&lt;BR /&gt;col1 string,&lt;BR /&gt;col2 string,&lt;BR /&gt;col3 string&lt;BR /&gt;)&lt;BR /&gt;row format delimited fields terminated by ","&amp;nbsp;&lt;BR /&gt;location '/user/xxxxxx/magnum';&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2026 13:51:26 GMT</pubDate>
    <dc:creator>Lucille</dc:creator>
    <dc:date>2026-04-21T13:51:26Z</dc:date>
    <item>
      <title>Add filename to import in Hive</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Add-filename-to-import-in-Hive/m-p/41944#M31632</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to Cloudera and have only used Impala and Hive through Hue thus far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a folder of CSVs that I imported, but would like to add the filename as a column to each row that I import.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I came across the function&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;INPUT__FILE__NAME&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but I don't see it actually doing anything.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My import is very easy - hoping you can help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create external table hive_magnum&lt;BR /&gt;(&lt;BR /&gt;col1 string,&lt;BR /&gt;col2 string,&lt;BR /&gt;col3 string&lt;BR /&gt;)&lt;BR /&gt;row format delimited fields terminated by ","&amp;nbsp;&lt;BR /&gt;location '/user/xxxxxx/magnum';&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 13:51:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Add-filename-to-import-in-Hive/m-p/41944#M31632</guid>
      <dc:creator>Lucille</dc:creator>
      <dc:date>2026-04-21T13:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Add filename to import in Hive</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Add-filename-to-import-in-Hive/m-p/42084#M31633</link>
      <description>&lt;P&gt;Hi Lucille,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the example you provided, you could get the file names with a query like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SELECT&amp;nbsp;hive_magnum.col1,&amp;nbsp;hive_magnum.col2, hive_magnum.col3,&amp;nbsp;hive_magnum.INPUT__FILE__NAME
FROM
hive_magnum;&lt;/PRE&gt;&lt;P&gt;It will actually provide the full HDFS location, which includes the file name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this is helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 21:57:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Add-filename-to-import-in-Hive/m-p/42084#M31633</guid>
      <dc:creator>bbreak</dc:creator>
      <dc:date>2016-06-17T21:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Add filename to import in Hive</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Add-filename-to-import-in-Hive/m-p/42117#M31634</link>
      <description>&lt;P&gt;thank you so much - this worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just have one more questions.. to get this into the another table - it doesn't seem to accept this.. what is wrong with it?&lt;/P&gt;&lt;P&gt;It also did not like the &amp;lt;pre&amp;gt; bit... If I take it out, it runs..&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;create table tester&lt;BR /&gt;(&lt;BR /&gt;SELECT hive_magnum.col1, hive_magnum.col2, hive_magnum.col3, hive_magnum.INPUT__FILE__NAME as file_name FROM hive_magnum)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2016 08:58:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Add-filename-to-import-in-Hive/m-p/42117#M31634</guid>
      <dc:creator>Lucille</dc:creator>
      <dc:date>2016-06-20T08:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Add filename to import in Hive</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Add-filename-to-import-in-Hive/m-p/42150#M31635</link>
      <description>The&lt;PRE&gt; bit was an attempt to format the post. It wasn't supposed to be&lt;BR /&gt;part of the query, sorry about that.&lt;BR /&gt;&lt;BR /&gt;Try adding "as" after "create table tester" and before the nested select&lt;BR /&gt;query.&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jun 2016 13:59:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Add-filename-to-import-in-Hive/m-p/42150#M31635</guid>
      <dc:creator>bbreak</dc:creator>
      <dc:date>2016-06-20T13:59:55Z</dc:date>
    </item>
  </channel>
</rss>

