public void analyze() throws AnalysisException { // Check whether the column name meets the Metastore's requirements. if (!MetaStoreUtils.validateName(colName_)) { throw new AnalysisException("Invalid column name: " + colName_); } colType_.analyze(); }
/** * create * * @exception MetaException if any problems encountered during the creation */ public static Table create(DB parent, String tableName, Properties schema, Configuration conf) throws MetaException { Table newTable = new Table(); newTable.parent_ = parent; newTable.tableName_ = tableName; newTable.conf_ = conf; 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; }