tencent cloud

Data Lake Compute

ALTER TABLE ADD PARTITION FIELD

Download
フォーカスモード
フォントサイズ
最終更新日: 2025-12-25 11:51:49

説明

サポートカーネル:Presto、SparkSQL。
適用テーブル範囲:ネイティブIcebergテーブル、外部テーブル。
用途:データテーブルに単一のパーティションフィールドを追加します。

標準構文

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, …

パラメータ説明

table_name:必要なテーブル名。
partition_column: パーティション列。
alias: パーティション列に追加する別名。

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

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック