forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX](agg) fix vertical_compaction_reader for agg table with array/ma…
…p type apache#33130 (apache#33216)
- Loading branch information
Showing
11 changed files
with
184 additions
and
29 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
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
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
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
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
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
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
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
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
13 changes: 13 additions & 0 deletions
13
regression-test/data/compaction/test_compaction_agg_keys_with_array_map.out
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,13 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select_default -- | ||
1 2017-10-01 2017-10-01 2017-10-01T11:11:11.110 2017-10-01T11:11:11.110111 Beijing 10 1 ["a", "b", "c"] {"b":1, "c":2} | ||
2 2017-10-01 2017-10-01 2017-10-01T11:11:11.110 2017-10-01T11:11:11.110111 Beijing 10 1 ["amory", "doris", "2024-04-29"] {"c":2} | ||
3 2017-10-01 2017-10-01 2017-10-01T11:11:11.110 2017-10-01T11:11:11.110111 Beijing 10 1 \N \N | ||
4 2017-10-01 2017-10-01 2017-10-01T11:11:11.110 2017-10-01T11:11:11.110111 Beijing 10 1 [null, "sdf"] \N | ||
|
||
-- !select_default2 -- | ||
1 2017-10-01 2017-10-01 2017-10-01T11:11:11.110 2017-10-01T11:11:11.110111 Beijing 10 1 ["a", "b", "c"] {"b":1, "c":2} | ||
2 2017-10-01 2017-10-01 2017-10-01T11:11:11.110 2017-10-01T11:11:11.110111 Beijing 10 1 ["amory", "doris", "2024-04-29"] {"c":2} | ||
3 2017-10-01 2017-10-01 2017-10-01T11:11:11.110 2017-10-01T11:11:11.110111 Beijing 10 1 \N \N | ||
4 2017-10-01 2017-10-01 2017-10-01T11:11:11.110 2017-10-01T11:11:11.110111 Beijing 10 1 [null, "sdf"] \N | ||
|
153 changes: 153 additions & 0 deletions
153
regression-test/suites/compaction/test_compaction_agg_keys_with_array_map.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,153 @@ | ||
// 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.codehaus.groovy.runtime.IOGroovyMethods | ||
|
||
suite("test_compaction_agg_keys_with_array_map") { | ||
def tableName = "compaction_agg_keys_regression_test_complex" | ||
|
||
try { | ||
String backend_id; | ||
def backendId_to_backendIP = [:] | ||
def backendId_to_backendHttpPort = [:] | ||
getBackendIpHttpPort(backendId_to_backendIP, backendId_to_backendHttpPort); | ||
backend_id = backendId_to_backendIP.keySet()[0] | ||
|
||
def (code, out, err) = show_be_config(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id)) | ||
logger.info("Show config: code=" + code + ", out=" + out + ", err=" + err) | ||
assertEquals(code, 0) | ||
def configList = parseJson(out.trim()) | ||
assert configList instanceof List | ||
|
||
boolean disableAutoCompaction = true | ||
for (Object ele in (List) configList) { | ||
assert ele instanceof List<String> | ||
if (((List<String>) ele)[0] == "disable_auto_compaction") { | ||
disableAutoCompaction = Boolean.parseBoolean(((List<String>) ele)[2]) | ||
} | ||
} | ||
|
||
sql """ DROP TABLE IF EXISTS ${tableName} """ | ||
sql """ | ||
CREATE TABLE IF NOT EXISTS ${tableName} ( | ||
`user_id` LARGEINT NOT NULL COMMENT "用户id", | ||
`date` DATE NOT NULL COMMENT "数据灌入日期时间", | ||
`datev2` DATEV2 NOT NULL COMMENT "数据灌入日期时间", | ||
`datetimev2_1` DATETIMEV2(3) NOT NULL COMMENT "数据灌入日期时间", | ||
`datetimev2_2` DATETIMEV2(6) NOT NULL COMMENT "数据灌入日期时间", | ||
`city` VARCHAR(20) COMMENT "用户所在城市", | ||
`age` SMALLINT COMMENT "用户年龄", | ||
`sex` TINYINT COMMENT "用户性别", | ||
`array_col` ARRAY<STRING> REPLACE NULL COMMENT "array column", | ||
`map_col` MAP<STRING, INT> REPLACE NULL COMMENT "map column") | ||
AGGREGATE KEY(`user_id`, `date`, `datev2`, `datetimev2_1`, `datetimev2_2`, `city`, `age`, `sex`) DISTRIBUTED BY HASH(`user_id`) | ||
PROPERTIES ( "replication_num" = "1" ); | ||
""" | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(1, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.110111', 'Beijing', 10, 1, ['a', 'b'], map('a', 1)); | ||
""" | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(1, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.110111', 'Beijing', 10, 1, ['a', 'b', 'c'], map('b', 1, 'c', 2)); | ||
""" | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(2, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.110111', 'Beijing', 10, 1, ['amory', 'doris', 'commiter'], map('b', 1)); | ||
""" | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(2, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.110111', 'Beijing', 10, 1, ['amory', 'doris', '2024-04-29'], map('c', 2)); | ||
""" | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.110111', 'Beijing', 10, 1, ['e', 'f', 'g', 'd'], map()); | ||
""" | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.110111', 'Beijing', 10, 1, ['e', 'f', 'g', 'd'], map('a', 1, 'b', 2)); | ||
""" | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(3, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.110111', 'Beijing', 10, 1, NULL, NULL); | ||
""" | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(4, '2017-10-01', '2017-10-01', '2017-10-01 11:11:11.110000', '2017-10-01 11:11:11.110111', 'Beijing', 10, 1, [NULL, 'sdf'], NULL); | ||
""" | ||
|
||
qt_select_default """ SELECT * FROM ${tableName} t ORDER BY user_id; """ | ||
|
||
//TabletId,ReplicaId,BackendId,SchemaHash,Version,LstSuccessVersion,LstFailedVersion,LstFailedTime,LocalDataSize,RemoteDataSize,RowCount,State,LstConsistencyCheckTime,CheckVersion,QueryHits,VersionCount,PathHash,MetaUrl,CompactionStatus | ||
def tablets = sql_return_maparray """ show tablets from ${tableName}; """ | ||
|
||
// trigger compactions for all tablets in ${tableName} | ||
for (def tablet in tablets) { | ||
String tablet_id = tablet.TabletId | ||
backend_id = tablet.BackendId | ||
(code, out, err) = be_run_cumulative_compaction(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id) | ||
logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err) | ||
assertEquals(code, 0) | ||
def compactJson = parseJson(out.trim()) | ||
if (compactJson.status.toLowerCase() == "fail") { | ||
assertEquals(disableAutoCompaction, false) | ||
logger.info("Compaction was done automatically!") | ||
} | ||
if (disableAutoCompaction) { | ||
assertEquals("success", compactJson.status.toLowerCase()) | ||
} | ||
} | ||
|
||
// wait for all compactions done | ||
for (def tablet in tablets) { | ||
boolean running = true | ||
do { | ||
Thread.sleep(1000) | ||
String tablet_id = tablet.TabletId | ||
backend_id = tablet.BackendId | ||
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id) | ||
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err) | ||
assertEquals(code, 0) | ||
|
||
def compactionStatus = parseJson(out.trim()) | ||
assertEquals("success", compactionStatus.status.toLowerCase()) | ||
running = compactionStatus.run_status | ||
} while (running) | ||
} | ||
|
||
int rowCount = 0 | ||
for (def tablet in tablets) { | ||
String tablet_id = tablet.TabletId | ||
def compactionStatusUrlIndex = 18 | ||
|
||
(code, out, err) = curl("GET", tablet.CompactionStatus) | ||
logger.info("Show tablets status: code=" + code + ", out=" + out + ", err=" + err) | ||
|
||
assertEquals(code, 0) | ||
def tabletJson = parseJson(out.trim()) | ||
assert tabletJson.rowsets instanceof List | ||
for (String rowset in (List<String>) tabletJson.rowsets) { | ||
rowCount += Integer.parseInt(rowset.split(" ")[1]) | ||
} | ||
} | ||
assert (rowCount < 8) | ||
qt_select_default2 """ SELECT * FROM ${tableName} t ORDER BY user_id; """ | ||
} finally { | ||
try_sql("DROP TABLE IF EXISTS ${tableName}") | ||
} | ||
} | ||
|