<?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: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing' in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49705#M51975</link>
    <description>&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/13587"&gt;@venkatsambath&lt;/a&gt;&lt;BR /&gt;I did not do those actions! Must have missed that, thank you for pointing it out. Everything is working as expected now.</description>
    <pubDate>Thu, 19 Jan 2017 17:14:02 GMT</pubDate>
    <dc:creator>ski309</dc:creator>
    <dc:date>2017-01-19T17:14:02Z</dc:date>
    <item>
      <title>CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49675#M51965</link>
      <description>&lt;P&gt;I created a Cloudera cluster for Impala.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Cloudera version: Cloudera Express 5.8.1&lt;/LI&gt;&lt;LI&gt;Impala version: 2.6.0-cdh5.8.0 RELEASE&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If I run the following command via impala-shell:&lt;/P&gt;&lt;PRE&gt;create table test as select 1;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;The following error is returned:&lt;/P&gt;&lt;PRE&gt;WARNINGS: Failed to open HDFS file for writing: hdfs://[DNhostname]:8020/user/hive/warehouse/test/_impala_insert_staging/[...]/[...].0.
Error(255): Unknown error 255&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I run:&lt;/P&gt;&lt;PRE&gt;create table test (testcol int);
insert into test select 1;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;...The table is created and data is inserted without a hitch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any ideas on why the first statement might fail while the second set of commands would succeed, and what I could do to fix it? I might have messed something up with directory permissions, either locally or on HDFS, however I've set 'dfs.permissions' to false to turn off HDFS permissions. I don't know what to check on the local folders to ensure the correct user(s) have the right permissions. In either case, I don't know why the permissions would cause the 'CREATE TABLE AS SELECT' statement to fail but not the 'CREATE... INSERT'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I should also mention that 'DNhostname' is the hostname of the HDFS datanode/impala daemon that I'm SSHed into, not the hostname of the namenode. This worries me because 'DNhostname' was originally where my namenode was located; I moved it to a different host for reasons outside the scope of this question. Is it possible that 'CREATE TABLE AS SELECT' is still expecting the namenode to be 'DNhostname' for some reason?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 10:55:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49675#M51965</guid>
      <dc:creator>ski309</dc:creator>
      <dc:date>2022-09-16T10:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49677#M51966</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/20291"&gt;@ski309&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is nothing to do with Impala,&amp;nbsp;If I am correct, The&amp;nbsp;query "create table test as select 1" will not work in any DB (at least 95% of DB), because the query "select 1" &amp;nbsp;will return the data &amp;amp; column name as '1'. But this is not valid column name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;create table test (1 int); --This is invalid&amp;nbsp;column name&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also I put the data type 'int' on my own, but "select 1" will not return any datatype. As everyone know,&amp;nbsp;"Column name" and "data type" are mandatory to create any table. But "Select 1" will neither return valid ColumnName nor datatype&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the below query will work, because it will get the column name and datatype from the base table&lt;/P&gt;&lt;PRE&gt;create table db.table2 as select * from db.table1&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this will help you!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Kumar&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 15:19:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49677#M51966</guid>
      <dc:creator>saranvisa</dc:creator>
      <dc:date>2017-01-19T15:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49687#M51967</link>
      <description>Thanks for the quick reply. The query 'create table test as select 1' works in a second Impala cluster I have in place, which uses the same Cloudera and Impala versions. It appears the unnamed column in the create statement is automatically named '_c0'. The query 'create table db.table2 as select * from db.table1' fails in the same way in my problem cluster but works correctly in my second, working cluster.</description>
      <pubDate>Thu, 19 Jan 2017 16:20:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49687#M51967</guid>
      <dc:creator>ski309</dc:creator>
      <dc:date>2017-01-19T16:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49689#M51968</link>
      <description>&lt;P&gt;After messing around a little more, I found something strange.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I switch to a different database before running the 'create table as select' statement, the table is created and populated without error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;create database testdb;&lt;BR /&gt;use testdb;
create table test as select 1;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:28:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49689#M51968</guid>
      <dc:creator>ski309</dc:creator>
      <dc:date>2017-01-19T16:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49693#M51969</link>
      <description>This may be a silly question, but does the test table exist prior to running the CTAS statement?</description>
      <pubDate>Thu, 19 Jan 2017 16:42:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49693#M51969</guid>
      <dc:creator>mbigelow</dc:creator>
      <dc:date>2017-01-19T16:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49697#M51970</link>
      <description>&lt;P&gt;1. Can you check the value of "&lt;SPAN class="s1"&gt;fs.defaultFS" in core-site.xml file in impalad process directory&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s1"&gt;a.&amp;nbsp;&lt;SPAN&gt;impalad process directory --&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;/var/run/cloudera-scm-agent/process/&amp;lt;num&amp;gt;-impala-IMPALAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Replace &amp;lt;num&amp;gt; with the latest number under process directory&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Then you can run&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;grep -Rn 8020 * -b1&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Please let me know if the hostname in the value tag matches the current namenode&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:57:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49697#M51970</guid>
      <dc:creator>venkatsambath</dc:creator>
      <dc:date>2017-01-19T16:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49698#M51971</link>
      <description>&lt;P&gt;I think I've found the problem but I'm unsure how to best fix it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I run:&lt;/P&gt;&lt;PRE&gt;desc database default;&lt;/PRE&gt;&lt;P&gt;The 'location' property shows the hdfs: url to the datanode and not the namenode.&amp;nbsp; My second, working cluster's "location" property shows the url to the namenode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is there doesn't appear to be an ALTER DATABASE statement.&amp;nbsp; How can I easily change the location property of the default database? The database already has many internal and external tables; I can try to back them up and recreate the default database from scratch, but if there's a way to modify the location property that would be great.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 17:03:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49698#M51971</guid>
      <dc:creator>ski309</dc:creator>
      <dc:date>2017-01-19T17:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49701#M51972</link>
      <description>&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/18127"&gt;@mbigelow&lt;/a&gt;&lt;BR /&gt;If the test table exists before I run the CTAS statement, I receive an error that the test table already exists.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/13587"&gt;@venkatsambath&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;The hostname in the value tag *does* match the current namenode.</description>
      <pubDate>Thu, 19 Jan 2017 17:02:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49701#M51972</guid>
      <dc:creator>ski309</dc:creator>
      <dc:date>2017-01-19T17:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49702#M51973</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/20291"&gt;@ski309&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Was the below action performed after moving the namenode?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.cloudera.com/documentation/enterprise/5-7-x/topics/admin_nn_migrate_roles.html#concept_ff5_tdg_ts" target="_blank"&gt;https://www.cloudera.com/documentation/enterprise/5-7-x/topics/admin_nn_migrate_roles.html#concept_ff5_tdg_ts&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The HiveMetastoreDatabase maintains the location of tables and databases. So once after moving the namenode, it is necessary to perform the above step to update the locations in HMS.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 17:05:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49702#M51973</guid>
      <dc:creator>venkatsambath</dc:creator>
      <dc:date>2017-01-19T17:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49704#M51974</link>
      <description>Ah that will do it as all new tables inherent the DB path unless specified in the Create table statement. There is no way to alter it through HIve/Impala. You will need to log into the metastore DB and change it there.&lt;BR /&gt;&lt;BR /&gt;You can find it in the &amp;lt;metastore_db_name&amp;gt;.DBS and I believe the column is just called LOCATION. Find the id for the default DB and run something like 'update DBS set LOCATION = 'hdfs://NN_URI:8020/user/hive/warehouse' where id = &amp;lt;default_db_id&amp;gt;;'</description>
      <pubDate>Thu, 19 Jan 2017 17:12:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49704#M51974</guid>
      <dc:creator>mbigelow</dc:creator>
      <dc:date>2017-01-19T17:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49705#M51975</link>
      <description>&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/13587"&gt;@venkatsambath&lt;/a&gt;&lt;BR /&gt;I did not do those actions! Must have missed that, thank you for pointing it out. Everything is working as expected now.</description>
      <pubDate>Thu, 19 Jan 2017 17:14:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49705#M51975</guid>
      <dc:creator>ski309</dc:creator>
      <dc:date>2017-01-19T17:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49708#M51976</link>
      <description>&lt;P&gt;You're welcome!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 17:19:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49708#M51976</guid>
      <dc:creator>venkatsambath</dc:creator>
      <dc:date>2017-01-19T17:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49738#M51977</link>
      <description>&lt;P&gt;Are you running with HDFS HA (i.e. a setup with an active and a standby NN)? It is a known issue that Impala CTAS may not work with HDFS HA. As a workaround, CREATE+INSERT should work.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 22:50:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49738#M51977</guid>
      <dc:creator>alex.behm</dc:creator>
      <dc:date>2017-01-19T22:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49750#M51978</link>
      <description>&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/1125"&gt;@alex.behm&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;No, I'm not. I just missed a final step when I moved our primary NN, which &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/13587"&gt;@venkatsambath&lt;/a&gt; pointed out.</description>
      <pubDate>Fri, 20 Jan 2017 14:53:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49750#M51978</guid>
      <dc:creator>ski309</dc:creator>
      <dc:date>2017-01-20T14:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE AS SELECT returns error 'Failed to open HDFS file for writing'</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49760#M51979</link>
      <description>Thanks!&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Jan 2017 19:52:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/CREATE-TABLE-AS-SELECT-returns-error-Failed-to-open-HDFS/m-p/49760#M51979</guid>
      <dc:creator>alex.behm</dc:creator>
      <dc:date>2017-01-20T19:52:13Z</dc:date>
    </item>
  </channel>
</rss>

