-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor](regression) Re-arrange cases for data-partitioning doc (#4…
- Loading branch information
Showing
4 changed files
with
228 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
regression-test/suites/doc/table-design/data-partitioning/basic-concepts.md.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// 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. | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
|
||
suite("docs/table-design/data-partitioning/basic-concepts.md") { | ||
try { | ||
sql "drop table if exists example_range_tbl" | ||
multi_sql """ | ||
-- Range Partition | ||
CREATE TABLE IF NOT EXISTS example_range_tbl | ||
( | ||
`user_id` LARGEINT NOT NULL COMMENT "用户id", | ||
`date` DATE NOT NULL COMMENT "数据灌入日期时间", | ||
`timestamp` DATETIME NOT NULL COMMENT "数据灌入的时间戳", | ||
`city` VARCHAR(20) COMMENT "用户所在城市", | ||
`age` SMALLINT COMMENT "用户年龄", | ||
`sex` TINYINT COMMENT "用户性别", | ||
`last_visit_date` DATETIME REPLACE DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次访问时间", | ||
`cost` BIGINT SUM DEFAULT "0" COMMENT "用户总消费", | ||
`max_dwell_time` INT MAX DEFAULT "0" COMMENT "用户最大停留时间", | ||
`min_dwell_time` INT MIN DEFAULT "99999" COMMENT "用户最小停留时间" | ||
) | ||
ENGINE=OLAP | ||
AGGREGATE KEY(`user_id`, `date`, `timestamp`, `city`, `age`, `sex`) | ||
PARTITION BY RANGE(`date`) | ||
( | ||
PARTITION `p201701` VALUES LESS THAN ("2017-02-01"), | ||
PARTITION `p201702` VALUES LESS THAN ("2017-03-01"), | ||
PARTITION `p201703` VALUES LESS THAN ("2017-04-01"), | ||
PARTITION `p2018` VALUES [("2018-01-01"), ("2019-01-01")) | ||
) | ||
DISTRIBUTED BY HASH(`user_id`) BUCKETS 16 | ||
PROPERTIES | ||
( | ||
"replication_num" = "1" | ||
); | ||
""" | ||
|
||
sql "show create table example_range_tbl" | ||
sql "show partitions from example_range_tbl" | ||
sql """ALTER TABLE example_range_tbl ADD PARTITION p201704 VALUES LESS THAN("2020-05-01") DISTRIBUTED BY HASH(`user_id`) BUCKETS 5""" | ||
} catch (Throwable t) { | ||
Assertions.fail("examples in docs/table-design/data-partitioning/basic-concepts.md failed to exec, please fix it", t) | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
regression-test/suites/doc/table-design/data-partitioning/dynamic-partitioning.md.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// 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. | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
|
||
suite("docs/table-design/data-partitioning/dynamic-partitioning.md") { | ||
try { | ||
sql "drop table if exists tbl1" | ||
sql """ | ||
CREATE TABLE tbl1 | ||
( | ||
k1 DATE | ||
) | ||
PARTITION BY RANGE(k1) () | ||
DISTRIBUTED BY HASH(k1) | ||
PROPERTIES | ||
( | ||
"dynamic_partition.enable" = "true", | ||
"dynamic_partition.time_unit" = "DAY", | ||
"dynamic_partition.start" = "-7", | ||
"dynamic_partition.end" = "3", | ||
"dynamic_partition.prefix" = "p", | ||
"dynamic_partition.buckets" = "32", | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
sql "drop table if exists tbl1" | ||
sql """ | ||
CREATE TABLE tbl1 | ||
( | ||
k1 DATETIME, | ||
) | ||
PARTITION BY RANGE(k1) () | ||
DISTRIBUTED BY HASH(k1) | ||
PROPERTIES | ||
( | ||
"dynamic_partition.enable" = "true", | ||
"dynamic_partition.time_unit" = "WEEK", | ||
"dynamic_partition.start" = "-2", | ||
"dynamic_partition.end" = "2", | ||
"dynamic_partition.prefix" = "p", | ||
"dynamic_partition.buckets" = "8", | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
sql "drop table if exists tbl1" | ||
sql """ | ||
CREATE TABLE tbl1 | ||
( | ||
k1 DATE | ||
) | ||
PARTITION BY RANGE(k1) () | ||
DISTRIBUTED BY HASH(k1) | ||
PROPERTIES | ||
( | ||
"dynamic_partition.enable" = "true", | ||
"dynamic_partition.time_unit" = "MONTH", | ||
"dynamic_partition.end" = "2", | ||
"dynamic_partition.prefix" = "p", | ||
"dynamic_partition.buckets" = "8", | ||
"dynamic_partition.start_day_of_month" = "3", | ||
"replication_num" = "1" | ||
) | ||
""" | ||
|
||
sql "SHOW DYNAMIC PARTITION TABLES" | ||
sql """ ADMIN SET FRONTEND CONFIG ("dynamic_partition_enable" = "true") """ | ||
cmd """ curl --location-trusted -u ${context.config.jdbcUser}:${context.config.jdbcPassword} -XGET http://${context.config.feHttpAddress}/api/_set_config?dynamic_partition_enable=true """ | ||
|
||
sql """ ADMIN SET FRONTEND CONFIG ("dynamic_partition_check_interval_seconds" = "7200") """ | ||
cmd """ curl --location-trusted -u ${context.config.jdbcUser}:${context.config.jdbcPassword} -XGET http://${context.config.feHttpAddress}/api/_set_config?dynamic_partition_check_interval_seconds=432000 """ | ||
} catch (Throwable t) { | ||
Assertions.fail("examples in docs/table-design/data-partitioning/dynamic-partitioning.md failed to exec, please fix it", t) | ||
} | ||
} |
Oops, something went wrong.