ALTER TABLE table_name ADD PARTITION partition_column | hidden_partition_spec [AS alias]hidden_partition_spec:Supported transformations are:years(ts): partition by yearmonths(ts): partition by monthdays(ts) or date(ts): equivalent to dateint partitioninghours(ts) or date_hour(ts): equivalent to dateint and hour partitioningbucket(N, col): partition by hashed value mod N bucketstruncate(L, col): partition by value truncated to LStrings are truncated to the given lengthIntegers and longs truncate to bins: truncate(10, i) produces partitions 0, 10, 20, 30, …
table_name: Name of the target tablepartition_column: Partitioning columnalias: Alias of the partitioning column to be added.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 fieldALTER TABLE prod.db.sample ADD PARTITION FIELD bucket(16, id) AS shard
Feedback