Overview
Concepts
Cluster Architecture
Strengths
Scenarios
ALTER TABLE ADD TEMPORARY PARTITION statement:ALTER TABLE tbl1 ADD TEMPORARY PARTITION tp1 VALUES LESS THAN("2020-02-01");ALTER TABLE tbl2 ADD TEMPORARY PARTITION tp1 VALUES [("2020-01-01"), ("2020-02-01"));ALTER TABLE tbl1 ADD TEMPORARY PARTITION tp1 VALUES LESS THAN("2020-02-01")("in_memory" = "true", "replication_num" = "1")DISTRIBUTED BY HASH(k1) BUCKETS 5;ALTER TABLE tbl3 ADD TEMPORARY PARTITION tp1 VALUES IN ("Beijing", "Shanghai");ALTER TABLE tbl4 ADD TEMPORARY PARTITION tp1 VALUES IN ((1, "Beijing"), (1, "Shanghai"));ALTER TABLE tbl3 ADD TEMPORARY PARTITION tp1 VALUES IN ("Beijing", "Shanghai")("in_memory" = "true", "replication_num" = "1")DISTRIBUTED BY HASH(k1) BUCKETS 5;
HELP ALTER TABLE; for more help and examples.ALTER TABLE DROP TEMPORARY PARTITION statementALTER TABLE tbl1 DROP TEMPORARY PARTITION tp1;
HELP ALTER TABLE; for more help and examples.ALTER TABLE REPLACE PARTITION statement.ALTER TABLE tbl1 REPLACE PARTITION (p1) WITH TEMPORARY PARTITION (tp1);ALTER TABLE tbl1 REPLACE PARTITION (p1, p2) WITH TEMPORARY PARTITION (tp1, tp2, tp3);ALTER TABLE tbl1 REPLACE PARTITION (p1, p2) WITH TEMPORARY PARTITION (tp1, tp2)PROPERTIES ("strict_range" = "false","use_temp_partition_name" = "true");
HELP ALTER TABLE; for more help and examples.strict_range
It is set to true by default. For Range partition, when this parameter is set to true, it means the total range of all official partitions to be replaced must be exactly the same as the total range of the temporary partition to replace. When it is set to false, it only needs to ensure that after replacement, the ranges between the new official partitions do not overlap.
For List partition, this parameter is always true. The enumeration values of all official partitions to be replaced must be exactly the same as the enumeration values of the temporary partition to replace. Here are some examples:[10, 20), [20, 30), [40, 50) => [10, 30), [40, 50)
[10, 30), [40, 45), [45, 50) => [10, 30), [40, 50)
[10, 50) => [10, 50)
[10, 30), [40, 50) => [10, 30), [40, 50)
strict_range is true, tp1 and tp2 cannot replace p1. If it is set to false and the range of the two partitions after replacement [10, 30), [40, 50) does not overlap with other official partitions, replacement is possible.(1, 2, 3), (4, 5, 6) => (1, 2, 3, 4, 5, 6)
(1, 2, 3), (4), (5, 6) => (1, 2, 3, 4, 5, 6)
(("1","beijing"), ("1", "shanghai")), (("2","beijing"), ("2", "shanghai")), (("3","beijing"), ("3", "shanghai")) => (("1","beijing"), ("1", "shanghai"), ("2","beijing"), ("2", "shanghai"), ("3","beijing"), ("3", "shanghai"))
(("1","beijing"), ("1", "shanghai")), (("2","beijing"), ("2", "shanghai"), ("3","beijing"), ("3", "shanghai")) => (("1","beijing"), ("1", "shanghai"), ("2","beijing"), ("2", "shanghai"), ("3","beijing"), ("3", "shanghai"))
use_temp_partition_name
It defaults to false. When this parameter is false, and the number of partitions to be replaced and the number of partitions to replace are the same, the name of the official partition remains the same after replacement. If it is true, after the replacement, the name of the official partition is the name of the replacement partition. The following are examples:ALTER TABLE tbl1 REPLACE PARTITION (p1) WITH TEMPORARY PARTITION (tp1);
use_temp_partition_name defaults to false, after the replacement, the name of the partition remains p1, but the related data and properties are replaced with tp1.
If use_temp_partition_name defaults to true, after the replacement, the name of the partition is tp1. The p1 partition no longer exists.ALTER TABLE tbl1 REPLACE PARTITION (p1, p2) WITH TEMPORARY PARTITION (tp1);
use_temp_partition_name defaults to false, but because the number of partitions to be replaced and the number of replace partitions are different, this parameter is invalid. After the replacement, the partition names are tp1, and p1 and p2 no longer exist.INSERT INTO tbl TEMPORARY PARTITION(tp1, tp2, ...) SELECT ....
curl --location-trusted -u root: -H "label:123" -H "temporary_partitions: tp1, tp2, ..." -T testData http://host:port/api/testDb/testTbl/_stream_load
LOAD LABEL example_db.label1(DATA INFILE("hdfs://hdfs_host:hdfs_port/user/palo/data/input/file")INTO TABLEmy_tableTEMPORARY PARTITION (tp1, tp2, ...)...)WITH BROKER hdfs ("username"="hdfs_user", "password"="hdfs_password");
CREATE ROUTINE LOAD example_db.test1 ON example_tblCOLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100),TEMPORARY PARTITIONS(tp1, tp2, ...),WHERE k1 > 100PROPERTIES(...)FROM KAFKA(...);
SELECT ... FROMtbl1 TEMPORARY PARTITION(tp1, tp2, ...)JOINtbl2 TEMPORARY PARTITION(tp1, tp2, ...)ON ...WHERE ...;
INSERT INTO command to import data from the formal partition into the temporary partition. Through the replace operation, the original partition is replaced atomically, achieving the desired goal.INSERT INTO command to import data from the formal partition into the temporary partition. Through the replace operation, the original partition is replaced atomically, achieving the desired goal.Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários