Github user xuchuanyin commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1258#discussion_r133645214
  
    --- Diff: docs/partition-guide.md ---
    @@ -0,0 +1,124 @@
    +<!--
    +    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.
    +-->
    +
    +### CarbonData Partition Table Guidance
    +This guidance illustrates how to create & use partition table in 
CarbonData.
    +
    +* [Create Partition Table](#create-partition-table)
    +  - [Create Hash Partition Table](#create-hash-partition-table)
    +  - [Create Range Partition Table](#create-range-partition-table)
    +  - [Create List Partition Table](#create-list-partition-table)
    +* [Show Partitions](#show-partitions)
    +* [Maintain the Partitions](#maintain-the-partitions)
    +* [Partition Id](#partition-id)
    +* [Tips](#tips)
    +
    +### Create Partition Table
    +
    +##### Create Hash Partition Table
    +```
    +   CREATE TABLE [IF NOT EXISTS] [db_name.]table_name
    +                    [(col_name data_type , ...)]
    +   STORED BY 'carbondata'
    +   PARTITIONED BY (partition_col_name data_type)
    +   [TBLPROPERTIES ('PARTITION_TYPE'='HASH', 
    +                   'PARTITION_NUM'='N' ...)]  
    +   //N is the number of hash partitions
    +```
    +
    +##### Create Range Partition Table
    +```
    +   CREATE TABLE [IF NOT EXISTS] [db_name.]table_name
    +                    [(col_name data_type , ...)]
    +   STORED BY 'carbondata'
    +   PARTITIONED BY (partition_col_name data_type)
    +   [TBLPROPERTIES ('PARTITION_TYPE'='RANGE', 
    +                   'RANGE_INFO'='2014-01-01, 2015-01-01, 2016-01-01' ...)]
    +```
    +Notes: 
    +1. The 'RANGE_INFO' defined in table properties must be in ascending order.
    +2. If the partition column is Date/Timestamp type, the format could be 
defined in CarbonProperties. By default it's yyyy-MM-dd.
    +
    +##### Create List Partition Table
    +```
    +   CREATE TABLE [IF NOT EXISTS] [db_name.]table_name
    +                    [(col_name data_type , ...)]
    +   STORED BY 'carbondata'
    +   PARTITIONED BY (partition_col_name data_type)
    +   [TBLPROPERTIES ('PARTITION_TYPE'='LIST', 
    +                   'LIST_INFO'='A, B, C' ...)]
    +```
    +Notes:
    +1. List partition support list info in one level group. For example, 
    +```
    +   ...
    +   'LIST_INFO' = 'A, B, (C, D), (E, F, G), H'
    +   ...
    +```
    +
    +
    +### Show Partitions
    +Execute following command to get the partition information
    +```
    +   SHOW PARTITIONS [db_name.]table_name
    +
    +```
    +
    +### Maintain the Partitions
    +##### Add a new partition
    +```
    +   ALTER TABLE [db_name].table_name ADD PARTITION('new_partition')
    +```
    +##### Split a partition
    +```
    +   ALTER TABLE [db_name].table_name SPLIT PARTITION(partition_id) 
INTO('new_partition1', 'new_partition2'...)
    +```
    +##### Drop a partition
    +```
    +   //Drop partition definition only and keep data
    +   ALTER TABLE [db_name].table_name DROP PARTITION(partition_id)
    +   
    +   //Drop both partition definition and data
    +   ALTER TABLE [db_name].table_name DROP PARTITION(partition_id) WITH DATA
    +```
    +Notes:
    +1. For the 1st case(keep data), 
    +   * if the table is a range partition table, data will be merged into the 
later partition, and if the dropped partition is the last one, then data will 
be merged into default partition.
    +   * if the table is a list partition table, data will be merged into 
default partition.
    +2. Drop default partition is not allowed, but you can use DELETE statement 
to delete data in default partition.
    +3. partition_id could be got from SHOW PARTITIONS command.
    +4. Hash partition table is not supported for the ADD, SPLIT, DROP command.
    +
    +### Partition Id
    +In carbon partition table, we use partition id to replace the task id
    --- End diff --
    
    @lionelcao Can you add a document to explain the partition feature, such as 
implementation and why implement in this way?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to