tencent cloud

Feedback

ALTER TABLE ADD PARTITION FIELD

Last updated: 2024-08-07 17:16:40

    Description

    Supported engines: Presto and SparkSQL
    Applicable table: Native Iceberg tables and external tables
    Purpose: Add a single partition field to a data table.

    Standard Statement

    ALTER TABLE table_name ADD PARTITION partition_column | hidden_partition_spec [AS alias]
    
    hidden_partition_spec:
    Supported transformations are:
    years(ts): partition by year
    months(ts): partition by month
    days(ts) or date(ts): equivalent to dateint partitioning
    hours(ts) or date_hour(ts): equivalent to dateint and hour partitioning
    bucket(N, col): partition by hashed value mod N buckets
    truncate(L, col): partition by value truncated to L
    Strings are truncated to the given length
    Integers and longs truncate to bins: truncate(10, i) produces partitions 0, 10, 20, 30, …

    Parameter Description

    table_name: Name of the target table
    partition_column: Partitioning column
    alias: Alias of the partitioning column to be added.

    Example

    ALTER TABLE prod.db.sample ADD PARTITION FIELD bucket(16, id)
    ALTER TABLE prod.db.sample ADD PARTITION FIELD truncate(data, 4)
    ALTER TABLE prod.db.sample ADD PARTITION FIELD years(ts)
    -- use optional AS keyword to specify a custom name for the partition field
    ALTER TABLE prod.db.sample ADD PARTITION FIELD bucket(16, id) AS shard
    
    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support