diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 7c74e79..22bea58 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -1175,21 +1175,28 @@ private void create_table_core(final RawStore ms, final Table tbl, + " 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()); + 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())); } - tblPath = wh.getDnsPath(new Path(tbl.getSd().getLocation())); + tbl.getSd().setLocation(tblPath.toString()); } - tbl.getSd().setLocation(tblPath.toString()); + } catch (MetaException e) { + if (e.getMessage().contains("java.io.IOException")) { + 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)) { diff --git ql/src/test/queries/clientnegative/external1.q ql/src/test/queries/clientnegative/external1.q index d56c955..a3a2e1c 100644 --- ql/src/test/queries/clientnegative/external1.q +++ ql/src/test/queries/clientnegative/external1.q @@ -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; diff --git ql/src/test/results/clientnegative/external1.q.out ql/src/test/results/clientnegative/external1.q.out index 696beaa..c001235 100644 --- ql/src/test/results/clientnegative/external1.q.out +++ ql/src/test/results/clientnegative/external1.q.out @@ -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)