[
https://issues.apache.org/jira/browse/TAJO-1345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14626075#comment-14626075
]
ASF GitHub Bot commented on TAJO-1345:
--------------------------------------
Github user hyunsik commented on a diff in the pull request:
https://github.com/apache/tajo/pull/618#discussion_r34549680
--- Diff:
tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
---
@@ -792,6 +791,69 @@ public static AlterTableDesc setProperty(String
tableName, KeyValueSet params, A
return alterTableDesc;
}
+ /**
+ * Add partition or Drop partition
+ *
+ * @param tableName table name
+ * @param columns partition column names
+ * @param values partition values
+ * @param location partition location
+ * @param alterTableType ADD_PARTITION or DROP_PARTITION
+ * @return
+ */
+ public static AlterTableDesc addOrDropPartition(String tableName,
String[] columns,
+ String[] values, String
location, AlterTableType alterTableType) {
+ final AlterTableDesc alterTableDesc = new AlterTableDesc();
+ alterTableDesc.setTableName(tableName);
+
+ PartitionDesc partitionDesc = new PartitionDesc();
+ Pair<List<PartitionKey>, String> pair =
getPartitionKeyNamePair(columns, values);
+
+ partitionDesc.setPartitionKeys(pair.getFirst());
+ partitionDesc.setPartitionName(pair.getSecond());
+
+ if (alterTableType.equals(AlterTableType.ADD_PARTITION) && location !=
null) {
+ partitionDesc.setPath(location);
+ }
+
+ alterTableDesc.setPartitionDesc(partitionDesc);
+ alterTableDesc.setAlterTableType(alterTableType);
+ return alterTableDesc;
+ }
+
+ /**
+ * Get partition key/value list and partition name
+ *
+ * ex) partition key/value list :
+ * - col1, 2015-07-01
+ * - col2, tajo
+ * partition name : col1=2015-07-01/col2=tajo
+ *
+ * @param columns partition column names
+ * @param values partition values
+ * @return partition key/value list and partition name
+ */
+ public static Pair<List<PartitionKey>, String>
getPartitionKeyNamePair(String[] columns, String[] values) {
+ Pair<List<PartitionKey>, String> pair = null;
+ List<PartitionKey> partitionKeyList = TUtil.newList();
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < columns.length; i++) {
+ PartitionKey partitionKey = new PartitionKey();
--- End diff --
PartitionKey is used as transient intermediate data for PartitionDesc. I
think that PartitionKey is unnecessary. You may use directly PartitionKeyProto
without PartitionKey.
> 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, TAJO-1345_2.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)