Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (revision 1573040) +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (working copy) @@ -1175,21 +1175,26 @@ + " already exists"); } - if (!TableType.VIRTUAL_VIEW.toString().equals(tbl.getTableType())) { - if (tbl.getSd().getLocation() == null - || tbl.getSd().getLocation().isEmpty()) { - tblPath = wh.getTablePath( - ms.getDatabase(tbl.getDbName()), tbl.getTableName()); - } else { - if (!isExternal(tbl) && !MetaStoreUtils.isNonNativeTable(tbl)) { - LOG.warn("Location: " + tbl.getSd().getLocation() - + " specified for non-external table:" + tbl.getTableName()); - } - tblPath = wh.getDnsPath(new Path(tbl.getSd().getLocation())); - } - tbl.getSd().setLocation(tblPath.toString()); + try { + if (!TableType.VIRTUAL_VIEW.toString().equals(tbl.getTableType())) { + if (tbl.getSd().getLocation() == null + || tbl.getSd().getLocation().isEmpty()) { + tblPath = wh.getTablePath( + ms.getDatabase(tbl.getDbName()), tbl.getTableName()); + } else { + if (!isExternal(tbl) && !MetaStoreUtils.isNonNativeTable(tbl)) { + LOG.warn("Location: " + tbl.getSd().getLocation() + + " specified for non-external table:" + tbl.getTableName()); + } + tblPath = wh.getDnsPath(new Path(tbl.getSd().getLocation())); + } + tbl.getSd().setLocation(tblPath.toString()); + } + } catch(Exception e) { + throw new MetaException("Error while trying to locate the table " + tbl.getTableName() + + " at location " + (tbl.getSd().getLocation()==null ? "NULL" : tbl.getSd().getLocation()) + + " : " + e.getMessage()); } - if (tblPath != null) { if (!wh.isDir(tblPath)) { if (!wh.mkdirs(tblPath)) { Index: ql/src/test/results/clientnegative/external1.q.out =================================================================== --- ql/src/test/results/clientnegative/external1.q.out (revision 1573040) +++ ql/src/test/results/clientnegative/external1.q.out (working copy) @@ -1,5 +1,5 @@ -#### A masked pattern was here #### +PREHOOK: query: create external table external1(a int, b int) location 'invalidScheme://data.s3ndemo.hive/kv' PREHOOK: type: CREATETABLE -#### A masked pattern was here #### +PREHOOK: Input: invalidScheme://data.s3ndemo.hive/kv PREHOOK: Output: database:default -FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:Got exception: java.io.IOException No FileSystem for scheme: invalidscheme) +FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:Error while trying to locate the table external1 at location invalidScheme://data.s3ndemo.hive/kv : Got exception: java.io.IOException No FileSystem for scheme: invalidScheme) Index: ql/src/test/queries/clientnegative/external1.q =================================================================== --- ql/src/test/queries/clientnegative/external1.q (revision 1573040) +++ ql/src/test/queries/clientnegative/external1.q (working copy) @@ -1,3 +1,3 @@ -create external table external1(a int, b int) location 'invalidscheme://data.s3ndemo.hive/kv'; +create external table external1(a int, b int) location 'invalidScheme://data.s3ndemo.hive/kv'; describe external1;