e.printStackTrace();
}
}
// Handle different types of CREATE TABLE command
createTableDesc crtTblDesc = null;
switch ( command_type ) {
case CREATE_TABLE: // REGULAR CREATE TABLE DDL
crtTblDesc =
new createTableDesc(tableName, isExt, cols, partCols, bucketCols,
sortCols, numBuckets,
fieldDelim, fieldEscape,
collItemDelim, mapKeyDelim, lineDelim,
comment, inputFormat, outputFormat, location, serde,
mapProp, ifNotExists);
validateCreateTable(crtTblDesc);
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), crtTblDesc), conf));
break;
case CTLT: // create table like <tbl_name>
createTableLikeDesc crtTblLikeDesc =
new createTableLikeDesc(tableName, isExt, location, ifNotExists, likeTableName);
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), crtTblLikeDesc), conf));
break;
case CTAS: // create table as select
// check for existence of table. Throw an exception if it exists.
try {
Table tab = this.db.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tableName,
false); // do not throw exception if table does not exist
if ( tab != null ) {
throw new SemanticException(ErrorMsg.TABLE_ALREADY_EXISTS.getMsg(tableName));
}
} catch (HiveException e) { // may be unable to get meta data
throw new SemanticException(e);
}
crtTblDesc =
new createTableDesc(tableName, isExt, cols, partCols, bucketCols,
sortCols, numBuckets,
fieldDelim, fieldEscape,
collItemDelim, mapKeyDelim, lineDelim,
comment, inputFormat, outputFormat, location, serde,
mapProp, ifNotExists);