[
https://issues.apache.org/jira/browse/TAJO-1345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14612004#comment-14612004
]
ASF GitHub Bot commented on TAJO-1345:
--------------------------------------
Github user jihoonson commented on a diff in the pull request:
https://github.com/apache/tajo/pull/618#discussion_r33782109
--- Diff:
tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java ---
@@ -446,11 +447,35 @@ public void alterTable(TajoMaster.MasterContext
context, final QueryContext quer
case SET_PROPERTY:
catalog.alterTable(CatalogUtil.setProperty(qualifiedName,
alterTable.getProperties(), AlterTableType.SET_PROPERTY));
break;
+ case ADD_PARTITION:
+ existColumnNames(qualifiedName, alterTable.getColumnNames());
+
catalog.alterTable(CatalogUtil.addPartitionAndDropPartition(qualifiedName,
alterTable.getColumnNames(),
+ alterTable.getPartitionValues(), alterTable.getLocation(),
AlterTableType.ADD_PARTITION));
+ break;
+ case DROP_PARTITION:
+ existColumnNames(qualifiedName, alterTable.getColumnNames());
+
catalog.alterTable(CatalogUtil.addPartitionAndDropPartition(qualifiedName,
alterTable.getColumnNames(),
+ alterTable.getPartitionValues(), alterTable.getLocation(),
AlterTableType.DROP_PARTITION));
+ break;
default:
//TODO
}
}
+ private boolean existColumnNames(String tableName, String[] columnNames)
{
+ for(String columnName : columnNames) {
+ if (!existPartitionColumnName(tableName, columnName)) {
+ throw new NoSuchColumnException(columnName);
+ }
+ }
+ return true;
+ }
+
+ private boolean existPartitionColumnName(String tableName, String
columnName) {
+ final TableDesc tableDesc = catalog.getTableDesc(tableName);
+ return
tableDesc.getPartitionMethod().getExpressionSchema().contains(columnName) ?
true : false;
--- End diff --
The ```?``` conditional operator seems unnecessary.
It's also trivial, but makes an Intellij warning.
> Implement logical plan part and DDL executor for alter partition.
> -----------------------------------------------------------------
>
> Key: TAJO-1345
> URL: https://issues.apache.org/jira/browse/TAJO-1345
> Project: Tajo
> Issue Type: Sub-task
> Components: planner/optimizer
> Reporter: Jaehwa Jung
> Assignee: Jaehwa Jung
> Fix For: 0.11.0
>
> Attachments: TAJO-1345.patch
>
>
> See the title. The main objective of this issue is to implement the logical
> planning part and the DDL executor part for alter table partition support.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)