You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2015/08/03 10:07:34 UTC
tajo git commit: TAJO-1721: Separate routine for CREATE TABLE from
DDLExecutor.
Repository: tajo
Updated Branches:
refs/heads/master e44bca79d -> 1be0e66b2
TAJO-1721: Separate routine for CREATE TABLE from DDLExecutor.
Closes #666
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/1be0e66b
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/1be0e66b
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/1be0e66b
Branch: refs/heads/master
Commit: 1be0e66b298bd969f331719d71785655839810f7
Parents: e44bca7
Author: Hyunsik Choi <hy...@apache.org>
Authored: Mon Aug 3 17:05:10 2015 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Mon Aug 3 17:06:02 2015 +0900
----------------------------------------------------------------------
CHANGES | 2 +
.../tajo/master/TajoMasterClientService.java | 5 +-
.../tajo/master/exec/CreateTableExecutor.java | 159 ++++++++++++++
.../apache/tajo/master/exec/DDLExecutor.java | 220 ++++++-------------
4 files changed, 226 insertions(+), 160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/1be0e66b/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 25eec0f..19dd980 100644
--- a/CHANGES
+++ b/CHANGES
@@ -33,6 +33,8 @@ Release 0.11.0 - unreleased
IMPROVEMENT
+ TAJO-1721: Separate routine for CREATE TABLE from DDLExecutor. (hyunsik)
+
TAJO-1736: Remove unnecessary getMountPath().
(Contributed by YeonSu Han, Committed by jinho)
http://git-wip-us.apache.org/repos/asf/tajo/blob/1be0e66b/tajo-core/src/main/java/org/apache/tajo/master/TajoMasterClientService.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/TajoMasterClientService.java b/tajo-core/src/main/java/org/apache/tajo/master/TajoMasterClientService.java
index a597d32..72e52b2 100644
--- a/tajo-core/src/main/java/org/apache/tajo/master/TajoMasterClientService.java
+++ b/tajo-core/src/main/java/org/apache/tajo/master/TajoMasterClientService.java
@@ -40,8 +40,6 @@ import org.apache.tajo.catalog.proto.CatalogProtos.*;
import org.apache.tajo.conf.TajoConf;
import org.apache.tajo.conf.TajoConf.ConfVars;
import org.apache.tajo.engine.query.QueryContext;
-import org.apache.tajo.exception.ErrorUtil;
-import org.apache.tajo.exception.ExceptionUtil;
import org.apache.tajo.exception.ReturnStateUtil;
import org.apache.tajo.ipc.ClientProtos;
import org.apache.tajo.ipc.ClientProtos.*;
@@ -885,11 +883,10 @@ public class TajoMasterClientService extends AbstractService {
partitionDesc = new PartitionMethodDesc(request.getPartition());
}
- TableDesc desc = context.getGlobalEngine().getDDLExecutor().createTable(
+ TableDesc desc = context.getGlobalEngine().getDDLExecutor().getCreateTableExecutor().create(
queryContext,
request.getName(),
null,
- meta.getStoreType(),
schema,
meta,
path.toUri(),
http://git-wip-us.apache.org/repos/asf/tajo/blob/1be0e66b/tajo-core/src/main/java/org/apache/tajo/master/exec/CreateTableExecutor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/exec/CreateTableExecutor.java b/tajo-core/src/main/java/org/apache/tajo/master/exec/CreateTableExecutor.java
new file mode 100644
index 0000000..40ebf4e
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/master/exec/CreateTableExecutor.java
@@ -0,0 +1,159 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.master.exec;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tajo.annotation.Nullable;
+import org.apache.tajo.catalog.*;
+import org.apache.tajo.catalog.exception.DuplicateTableException;
+import org.apache.tajo.catalog.exception.UndefinedTablespaceException;
+import org.apache.tajo.catalog.partition.PartitionMethodDesc;
+import org.apache.tajo.engine.query.QueryContext;
+import org.apache.tajo.exception.TajoInternalError;
+import org.apache.tajo.master.TajoMaster;
+import org.apache.tajo.plan.logical.CreateTableNode;
+import org.apache.tajo.plan.util.PlannerUtil;
+import org.apache.tajo.storage.Tablespace;
+import org.apache.tajo.storage.TablespaceManager;
+import org.apache.tajo.util.Pair;
+
+import java.io.IOException;
+import java.net.URI;
+
+/**
+ * An executor for Create Table command in QueryCoordinator
+ */
+public class CreateTableExecutor {
+ private static final Log LOG = LogFactory.getLog(DDLExecutor.class);
+
+ private final CatalogService catalog;
+
+ public CreateTableExecutor(TajoMaster.MasterContext context) {
+ this.catalog = context.getCatalog();
+ }
+
+ public TableDesc create(QueryContext queryContext, CreateTableNode createTable, boolean ifNotExists)
+ throws IOException {
+
+ TableMeta meta;
+ if (createTable.hasOptions()) {
+ meta = CatalogUtil.newTableMeta(createTable.getStorageType(), createTable.getOptions());
+ } else {
+ meta = CatalogUtil.newTableMeta(createTable.getStorageType());
+ }
+
+ if(PlannerUtil.isFileStorageType(createTable.getStorageType()) && createTable.isExternal()){
+ Preconditions.checkState(createTable.hasUri(), "ERROR: LOCATION must be given.");
+ }
+
+ return create(
+ queryContext,
+ createTable.getTableName(),
+ createTable.getTableSpaceName(),
+ createTable.getTableSchema(),
+ meta,
+ createTable.getUri(),
+ createTable.isExternal(),
+ createTable.getPartitionMethod(),
+ ifNotExists);
+ }
+
+ public TableDesc create(QueryContext queryContext,
+ String tableName,
+ @Nullable String tableSpaceName,
+ Schema schema,
+ TableMeta meta,
+ @Nullable URI uri,
+ boolean isExternal,
+ @Nullable PartitionMethodDesc partitionDesc,
+ boolean ifNotExists) throws IOException {
+
+ Pair<String, String> separatedNames = getQualifiedName(queryContext.getCurrentDatabase(), tableName);
+ String databaseName = separatedNames.getFirst();
+ String simpleTableName = separatedNames.getSecond();
+ String qualifiedName = CatalogUtil.buildFQName(databaseName, simpleTableName);
+
+ // Check if the table to be created already exists
+ boolean exists = catalog.existsTable(databaseName, simpleTableName);
+ if (exists) {
+ return handlExistence(ifNotExists, qualifiedName);
+ }
+
+ Tablespace tableSpace = getTablespaceHandler(tableSpaceName, uri);
+
+ TableDesc desc;
+ URI tableUri = isExternal ? uri : tableSpace.getTableUri(databaseName, simpleTableName);
+ desc = new TableDesc(qualifiedName, schema, meta, tableUri, isExternal);
+
+ if (partitionDesc != null) {
+ desc.setPartitionMethod(partitionDesc);
+ }
+
+ tableSpace.createTable(desc, ifNotExists);
+
+ if (catalog.createTable(desc)) {
+ LOG.info("Table " + desc.getName() + " is created (" + desc.getStats().getNumBytes() + ")");
+ return desc;
+ } else {
+ LOG.info("Table creation " + tableName + " is failed.");
+ throw new TajoInternalError("Cannot create table \"" + tableName + "\"");
+ }
+ }
+
+ private TableDesc handlExistence(boolean ifNotExists, String qualifiedName) {
+ if (ifNotExists) {
+ LOG.info("relation \"" + qualifiedName + "\" is already exists.");
+ return catalog.getTableDesc(qualifiedName);
+ } else {
+ throw new DuplicateTableException(qualifiedName);
+ }
+ }
+
+ private Pair<String, String> getQualifiedName(String currentDatabase, String tableName) {
+ if (CatalogUtil.isFQTableName(tableName)) {
+ String [] splitted = CatalogUtil.splitFQTableName(tableName);
+ return new Pair<String, String>(splitted[0], splitted[1]);
+ } else {
+ return new Pair<String, String>(currentDatabase, tableName);
+ }
+ }
+
+ private Tablespace getTablespaceHandler(@Nullable String tableSpaceName, @Nullable URI tableUri) {
+ if (tableSpaceName != null) {
+ Optional<Tablespace> ts = (Optional<Tablespace>) TablespaceManager.getByName(tableSpaceName);
+ if (ts.isPresent()) {
+ return ts.get();
+ } else {
+ throw new UndefinedTablespaceException(tableSpaceName);
+ }
+ } else if (tableUri != null) {
+ Optional<Tablespace> ts = TablespaceManager.get(tableUri);
+ if (ts.isPresent()) {
+ return ts.get();
+ } else {
+ throw new UndefinedTablespaceException(tableUri.toString());
+ }
+ } else {
+ return TablespaceManager.getDefault();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/1be0e66b/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java b/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java
index 048bab2..89e0a66 100644
--- a/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java
+++ b/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java
@@ -18,8 +18,6 @@
package org.apache.tajo.master.exec;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileStatus;
@@ -30,7 +28,6 @@ import org.apache.tajo.algebra.AlterTablespaceSetType;
import org.apache.tajo.annotation.Nullable;
import org.apache.tajo.catalog.*;
import org.apache.tajo.catalog.exception.*;
-import org.apache.tajo.catalog.partition.PartitionMethodDesc;
import org.apache.tajo.catalog.proto.CatalogProtos;
import org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto;
import org.apache.tajo.catalog.proto.CatalogProtos.PartitionKeyProto;
@@ -42,12 +39,10 @@ import org.apache.tajo.plan.LogicalPlan;
import org.apache.tajo.plan.logical.*;
import org.apache.tajo.plan.util.PlannerUtil;
import org.apache.tajo.storage.StorageUtil;
-import org.apache.tajo.storage.Tablespace;
import org.apache.tajo.storage.TablespaceManager;
import org.apache.tajo.util.Pair;
import java.io.IOException;
-import java.net.URI;
import java.util.ArrayList;
import java.util.List;
@@ -62,9 +57,17 @@ public class DDLExecutor {
private final TajoMaster.MasterContext context;
private final CatalogService catalog;
+ private final CreateTableExecutor createTableExecutor;
+
public DDLExecutor(TajoMaster.MasterContext context) {
this.context = context;
this.catalog = context.getCatalog();
+
+ createTableExecutor = new CreateTableExecutor(this.context);
+ }
+
+ public CreateTableExecutor getCreateTableExecutor() {
+ return createTableExecutor;
}
public boolean execute(QueryContext queryContext, LogicalPlan plan) throws IOException {
@@ -72,49 +75,49 @@ public class DDLExecutor {
switch (root.getType()) {
- case ALTER_TABLESPACE:
- AlterTablespaceNode alterTablespace = (AlterTablespaceNode) root;
- alterTablespace(context, queryContext, alterTablespace);
- return true;
+ case ALTER_TABLESPACE:
+ AlterTablespaceNode alterTablespace = (AlterTablespaceNode) root;
+ alterTablespace(context, queryContext, alterTablespace);
+ return true;
- case CREATE_DATABASE:
- CreateDatabaseNode createDatabase = (CreateDatabaseNode) root;
- createDatabase(queryContext, createDatabase.getDatabaseName(), null, createDatabase.isIfNotExists());
- return true;
- case DROP_DATABASE:
- DropDatabaseNode dropDatabaseNode = (DropDatabaseNode) root;
- dropDatabase(queryContext, dropDatabaseNode.getDatabaseName(), dropDatabaseNode.isIfExists());
- return true;
+ case CREATE_DATABASE:
+ CreateDatabaseNode createDatabase = (CreateDatabaseNode) root;
+ createDatabase(queryContext, createDatabase.getDatabaseName(), null, createDatabase.isIfNotExists());
+ return true;
+ case DROP_DATABASE:
+ DropDatabaseNode dropDatabaseNode = (DropDatabaseNode) root;
+ dropDatabase(queryContext, dropDatabaseNode.getDatabaseName(), dropDatabaseNode.isIfExists());
+ return true;
- case CREATE_TABLE:
- CreateTableNode createTable = (CreateTableNode) root;
- createTable(queryContext, createTable, createTable.isIfNotExists());
- return true;
- case DROP_TABLE:
- DropTableNode dropTable = (DropTableNode) root;
- dropTable(queryContext, dropTable.getTableName(), dropTable.isIfExists(), dropTable.isPurge());
- return true;
- case TRUNCATE_TABLE:
- TruncateTableNode truncateTable = (TruncateTableNode) root;
- truncateTable(queryContext, truncateTable);
- return true;
+ case CREATE_TABLE:
+ CreateTableNode createTable = (CreateTableNode) root;
+ createTableExecutor.create(queryContext, createTable, createTable.isIfNotExists());
+ return true;
+ case DROP_TABLE:
+ DropTableNode dropTable = (DropTableNode) root;
+ dropTable(queryContext, dropTable.getTableName(), dropTable.isIfExists(), dropTable.isPurge());
+ return true;
+ case TRUNCATE_TABLE:
+ TruncateTableNode truncateTable = (TruncateTableNode) root;
+ truncateTable(queryContext, truncateTable);
+ return true;
- case ALTER_TABLE:
- AlterTableNode alterTable = (AlterTableNode) root;
- alterTable(context, queryContext, alterTable);
- return true;
+ case ALTER_TABLE:
+ AlterTableNode alterTable = (AlterTableNode) root;
+ alterTable(context, queryContext, alterTable);
+ return true;
- case CREATE_INDEX:
- CreateIndexNode createIndex = (CreateIndexNode) root;
- createIndex(queryContext, createIndex);
- return true;
+ case CREATE_INDEX:
+ CreateIndexNode createIndex = (CreateIndexNode) root;
+ createIndex(queryContext, createIndex);
+ return true;
- case DROP_INDEX:
- DropIndexNode dropIndexNode = (DropIndexNode) root;
- dropIndex(queryContext, dropIndexNode);
- return true;
+ case DROP_INDEX:
+ DropIndexNode dropIndexNode = (DropIndexNode) root;
+ dropIndex(queryContext, dropIndexNode);
+ return true;
default:
throw new InternalError("updateQuery cannot handle such query: \n" + root.toJson());
@@ -124,7 +127,7 @@ public class DDLExecutor {
public void createIndex(final QueryContext queryContext, final CreateIndexNode createIndexNode) {
String databaseName, simpleIndexName, qualifiedIndexName;
if (CatalogUtil.isFQTableName(createIndexNode.getIndexName())) {
- String [] splits = CatalogUtil.splitFQTableName(createIndexNode.getIndexName());
+ String[] splits = CatalogUtil.splitFQTableName(createIndexNode.getIndexName());
databaseName = splits[0];
simpleIndexName = splits[1];
qualifiedIndexName = createIndexNode.getIndexName();
@@ -159,7 +162,7 @@ public class DDLExecutor {
public void dropIndex(final QueryContext queryContext, final DropIndexNode dropIndexNode) {
String databaseName, simpleIndexName;
if (CatalogUtil.isFQTableName(dropIndexNode.getIndexName())) {
- String [] splits = CatalogUtil.splitFQTableName(dropIndexNode.getIndexName());
+ String[] splits = CatalogUtil.splitFQTableName(dropIndexNode.getIndexName());
databaseName = splits[0];
simpleIndexName = splits[1];
} else {
@@ -233,7 +236,7 @@ public class DDLExecutor {
boolean exists = catalog.existDatabase(databaseName);
if (exists) {
if (ifNotExists) {
- LOG.info("database \"" + databaseName + "\" is already exists." );
+ LOG.info("database \"" + databaseName + "\" is already exists.");
return true;
} else {
throw new DuplicateDatabaseException(databaseName);
@@ -252,9 +255,9 @@ public class DDLExecutor {
public boolean dropDatabase(QueryContext queryContext, String databaseName, boolean ifExists) {
boolean exists = catalog.existDatabase(databaseName);
- if(!exists) {
+ if (!exists) {
if (ifExists) { // DROP DATABASE IF EXISTS
- LOG.info("database \"" + databaseName + "\" does not exists." );
+ LOG.info("database \"" + databaseName + "\" does not exists.");
return true;
} else { // Otherwise, it causes an exception.
throw new UndefinedDatabaseException(databaseName);
@@ -274,103 +277,6 @@ public class DDLExecutor {
// Table Section
//--------------------------------------------------------------------------
- private TableDesc createTable(QueryContext queryContext, CreateTableNode createTable, boolean ifNotExists)
- throws IOException {
-
- TableMeta meta;
- if (createTable.hasOptions()) {
- meta = CatalogUtil.newTableMeta(createTable.getStorageType(), createTable.getOptions());
- } else {
- meta = CatalogUtil.newTableMeta(createTable.getStorageType());
- }
-
- if(PlannerUtil.isFileStorageType(createTable.getStorageType()) && createTable.isExternal()){
- Preconditions.checkState(createTable.hasUri(), "ERROR: LOCATION must be given.");
- }
-
- return createTable(
- queryContext,
- createTable.getTableName(),
- createTable.getTableSpaceName(),
- createTable.getStorageType(),createTable.getTableSchema(),
- meta,
- createTable.getUri(),
- createTable.isExternal(),
- createTable.getPartitionMethod(),
- ifNotExists);
- }
-
- public TableDesc createTable(QueryContext queryContext,
- String tableName,
- @Nullable String tableSpaceName,
- @Nullable String storeType,
- Schema schema,
- TableMeta meta,
- @Nullable URI uri,
- boolean isExternal,
- @Nullable PartitionMethodDesc partitionDesc,
- boolean ifNotExists) throws IOException {
-
- String databaseName;
- String simpleTableName;
- if (CatalogUtil.isFQTableName(tableName)) {
- String [] splitted = CatalogUtil.splitFQTableName(tableName);
- databaseName = splitted[0];
- simpleTableName = splitted[1];
- } else {
- databaseName = queryContext.getCurrentDatabase();
- simpleTableName = tableName;
- }
- String qualifiedName = CatalogUtil.buildFQName(databaseName, simpleTableName);
-
- boolean exists = catalog.existsTable(databaseName, simpleTableName);
-
- if (exists) {
- if (ifNotExists) {
- LOG.info("relation \"" + qualifiedName + "\" is already exists." );
- return catalog.getTableDesc(databaseName, simpleTableName);
- } else {
- throw new DuplicateTableException(qualifiedName);
- }
- }
-
- Tablespace tableSpace;
- if (tableSpaceName != null) {
- Optional<Tablespace> ts = (Optional<Tablespace>) TablespaceManager.getByName(tableSpaceName);
- if (ts.isPresent()) {
- tableSpace = ts.get();
- } else {
- throw new IOException("Tablespace '" + tableSpaceName + "' does not exist");
- }
- } else if (uri != null) {
- Optional<Tablespace> ts = TablespaceManager.get(uri);
- if (ts.isPresent()) {
- tableSpace = ts.get();
- } else {
- throw new IOException("Unknown tablespace URI: " + uri);
- }
- } else {
- tableSpace = TablespaceManager.getDefault();
- }
-
- TableDesc desc;
- URI tableUri = isExternal ? uri : tableSpace.getTableUri(databaseName, simpleTableName);
- desc = new TableDesc(qualifiedName, schema, meta, tableUri, isExternal);
-
- if (partitionDesc != null) {
- desc.setPartitionMethod(partitionDesc);
- }
-
- tableSpace.createTable(desc, ifNotExists);
-
- if (catalog.createTable(desc)) {
- LOG.info("Table " + desc.getName() + " is created (" + desc.getStats().getNumBytes() + ")");
- return desc;
- } else {
- LOG.info("Table creation " + tableName + " is failed.");
- throw new TajoInternalError("Cannot create table \"" + tableName + "\"");
- }
- }
/**
* Drop a given named table
@@ -383,7 +289,7 @@ public class DDLExecutor {
String databaseName;
String simpleTableName;
if (CatalogUtil.isFQTableName(tableName)) {
- String [] splitted = CatalogUtil.splitFQTableName(tableName);
+ String[] splitted = CatalogUtil.splitFQTableName(tableName);
databaseName = splitted[0];
simpleTableName = splitted[1];
} else {
@@ -393,9 +299,9 @@ public class DDLExecutor {
String qualifiedName = CatalogUtil.buildFQName(databaseName, simpleTableName);
boolean exists = catalog.existsTable(qualifiedName);
- if(!exists) {
+ if (!exists) {
if (ifExists) { // DROP TABLE IF EXISTS
- LOG.info("relation \"" + qualifiedName + "\" is already exists." );
+ LOG.info("relation \"" + qualifiedName + "\" is already exists.");
return true;
} else { // Otherwise, it causes an exception.
throw new UndefinedTableException(qualifiedName);
@@ -429,7 +335,7 @@ public class DDLExecutor {
String simpleTableName;
List<TableDesc> tableDescList = new ArrayList<TableDesc>();
- for (String eachTableName: tableNames) {
+ for (String eachTableName : tableNames) {
if (CatalogUtil.isFQTableName(eachTableName)) {
String[] split = CatalogUtil.splitFQTableName(eachTableName);
databaseName = split[0];
@@ -455,14 +361,14 @@ public class DDLExecutor {
tableDescList.add(tableDesc);
}
- for (TableDesc eachTable: tableDescList) {
+ for (TableDesc eachTable : tableDescList) {
Path path = new Path(eachTable.getUri());
LOG.info("Truncate table: " + eachTable.getName() + ", delete all data files in " + path);
FileSystem fs = path.getFileSystem(context.getConf());
FileStatus[] files = fs.listStatus(path);
if (files != null) {
- for (FileStatus eachFile: files) {
+ for (FileStatus eachFile : files) {
fs.delete(eachFile.getPath(), true);
}
}
@@ -505,8 +411,8 @@ public class DDLExecutor {
CatalogProtos.PartitionDescProto partitionDescProto = null;
if (alterTable.getAlterTableOpType() == AlterTableOpType.RENAME_TABLE
- || alterTable.getAlterTableOpType() == AlterTableOpType.ADD_PARTITION
- || alterTable.getAlterTableOpType() == AlterTableOpType.DROP_PARTITION) {
+ || alterTable.getAlterTableOpType() == AlterTableOpType.ADD_PARTITION
+ || alterTable.getAlterTableOpType() == AlterTableOpType.DROP_PARTITION) {
desc = catalog.getTableDesc(databaseName, simpleTableName);
}
@@ -549,10 +455,12 @@ public class DDLExecutor {
if (ensureColumnExistance(qualifiedName, alterTable.getAddNewColumn().getSimpleName())) {
throw new DuplicateColumnException(alterTable.getAddNewColumn().getSimpleName());
}
- catalog.alterTable(CatalogUtil.addNewColumn(qualifiedName, alterTable.getAddNewColumn(), AlterTableType.ADD_COLUMN));
+ catalog.alterTable(CatalogUtil.addNewColumn(qualifiedName, alterTable.getAddNewColumn(), AlterTableType
+ .ADD_COLUMN));
break;
case SET_PROPERTY:
- catalog.alterTable(CatalogUtil.setProperty(qualifiedName, alterTable.getProperties(), AlterTableType.SET_PROPERTY));
+ catalog.alterTable(CatalogUtil.setProperty(qualifiedName, alterTable.getProperties(), AlterTableType
+ .SET_PROPERTY));
break;
case ADD_PARTITION:
pair = CatalogUtil.getPartitionKeyNamePair(alterTable.getPartitionColumns(), alterTable.getPartitionValues());
@@ -588,7 +496,7 @@ public class DDLExecutor {
}
catalog.alterTable(CatalogUtil.addOrDropPartition(qualifiedName, alterTable.getPartitionColumns(),
- alterTable.getPartitionValues(), alterTable.getLocation(), AlterTableType.ADD_PARTITION));
+ alterTable.getPartitionValues(), alterTable.getLocation(), AlterTableType.ADD_PARTITION));
// If the partition's path doesn't exist, this would make the directory by force.
if (!fs.exists(partitionPath)) {
@@ -612,7 +520,7 @@ public class DDLExecutor {
throw new UndefinedPartitionException(pair.getSecond());
} else if (!undefinedPartition) {
catalog.alterTable(CatalogUtil.addOrDropPartition(qualifiedName, alterTable.getPartitionColumns(),
- alterTable.getPartitionValues(), alterTable.getLocation(), AlterTableType.DROP_PARTITION));
+ alterTable.getPartitionValues(), alterTable.getLocation(), AlterTableType.DROP_PARTITION));
// When dropping partition on an managed table, the data will be delete from file system.
if (!desc.isExternal()) {
@@ -641,7 +549,7 @@ public class DDLExecutor {
}
private boolean ensureColumnPartitionKeys(String tableName, String[] columnNames) {
- for(String columnName : columnNames) {
+ for (String columnName : columnNames) {
if (!ensureColumnPartitionKeys(tableName, columnName)) {
throw new UndefinedPartitionKeyException(columnName);
}