newTable.o_rdonly_ = false;
newTable.schema_ = schema;
newTable.store_ = new FileStore(conf);
if(MetaStoreUtils.validateName(tableName) == false) {
throw new MetaException("Invalid table name: " + tableName + " - allowed characters are \\w and _") ;
}
String location = schema.getProperty(Constants.META_TABLE_LOCATION);
if(location == null) {
newTable.whPath_ = parent.getDefaultTablePath(tableName, (String)null);
newTable.schema_.setProperty(Constants.META_TABLE_LOCATION, newTable.whPath_.toUri().toASCIIString());
} else {
newTable.whPath_ = new Path(location);
}
try {
if (newTable.whPath_.getFileSystem(conf).exists(newTable.whPath_)) {
// current unit tests will fail
// throw new MetaException("for new table: " + tableName + " " + newTable.whPath_ + " already exists cannot create??");
} else {
newTable.whPath_.getFileSystem(conf).mkdirs(newTable.whPath_);
}
} catch(IOException e) {
LOG.error(StringUtils.stringifyException(e));
throw new MetaException(e.getMessage());
}
newTable.save(false);
return newTable;
}