Skip to content

Commit

Permalink
fix create table like not stable
Browse files Browse the repository at this point in the history
  • Loading branch information
seawinde committed Nov 6, 2024
1 parent bd682b6 commit 02c39d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1528,35 +1528,6 @@ class Suite implements GroovyInterceptable {
Assert.assertEquals("FINISHED", result)
}

def waitIndexVisible = (tbName, indexNames, timeoutMillisecond) -> {
def descAllResult = sql """ desc ${tbName} all"""
long startTime = System.currentTimeMillis()
long timeoutTimestamp = startTime + timeoutMillisecond
if (descAllResult == null || descAllResult.isEmpty()) {
logger.info("waitIndexVisible descAllResult is null")
Assert.assertTrue(false)
}
logger.info("waitIndexVisible descAllResult " + descAllResult)
Set<String> currentIndexSet = null;
while (timeoutTimestamp > System.currentTimeMillis()) {
currentIndexSet = new HashSet<>();
for (List<Object> row : descAllResult) {
if (row.size() < 1 || row.get(0) == null || row.get(0).toString().trim().size() == 0
|| Objects.equals(tbName, row.get(0).toString())) {
continue
}
currentIndexSet.add(String.valueOf(row.get(0)));
}
if (!Objects.equals(currentIndexSet, new HashSet(indexNames))) {
logger.info("waitIndexVisible currentIndexSet " + currentIndexSet)
sleep(200)
} else {
return
}
}
Assert.assertTrue(Objects.equals(currentIndexSet, new HashSet(indexNames)))
}

void testFoldConst(String foldSql) {
String openFoldConstant = "set debug_skip_fold_constant=false";
sql(openFoldConstant)
Expand Down
33 changes: 12 additions & 21 deletions regression-test/suites/ddl_p0/test_create_table_like_nereids.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,30 @@ suite("test_create_table_like_nereids") {
// with all rollup
sql "drop table if exists table_like_with_roll_up"
sql "CREATE TABLE table_like_with_roll_up LIKE mal_test_create_table_like with rollup;"
waitIndexVisible("table_like_with_roll_up", ["ru1", "ru2"], 60000)
explain {
sql ("select sum(a) from table_like_with_roll_up group by a")
contains "ru1"
} ;
explain {
sql ("select sum(b) from table_like_with_roll_up group by b,pk ;")
contains "ru2"
} ;

sql """insert into table_like_with_roll_up values(2,1,3),(1,1,2),(3,5,6),(6,null,6),(4,5,6),(2,1,4),(2,3,5),(1,1,4)
,(3,5,6),(3,5,null),(6,7,1),(2,1,7),(2,4,2),(2,3,9),(1,3,6),(3,5,8),(3,2,8);"""

mv_rewrite_success_without_check_chosen("select sum(a) from table_like_with_roll_up group by a", "ru1")
mv_rewrite_success_without_check_chosen("select sum(b) from table_like_with_roll_up group by b,pk ;", "ru2")

// with partial rollup
sql "drop table if exists table_like_with_partial_roll_up;"
sql "CREATE TABLE table_like_with_partial_roll_up LIKE mal_test_create_table_like with rollup (ru1);"
waitIndexVisible("table_like_with_partial_roll_up", ["ru1"], 60000)
sql "select * from table_like_with_partial_roll_up order by pk, a, b"
explain {
sql("select sum(a) from table_like_with_partial_roll_up group by a")
contains("ru1")
} ;
explain {
sql ("select sum(b) from table_like_with_partial_roll_up group by b,pk ;")
notContains "ru2"
} ;

sql """insert into table_like_with_partial_roll_up values(2,1,3),(1,1,2),(3,5,6),(6,null,6),(4,5,6),(2,1,4),(2,3,5),(1,1,4)
,(3,5,6),(3,5,null),(6,7,1),(2,1,7),(2,4,2),(2,3,9),(1,3,6),(3,5,8),(3,2,8);"""
sleep(2000)

sql "select * from table_like_with_partial_roll_up order by pk, a, b"
mv_rewrite_success_without_check_chosen("select sum(a) from table_like_with_partial_roll_up group by a", "ru1")
mv_not_part_in("select sum(b) from table_like_with_partial_roll_up group by b,pk ;", "ru2")

sql "select sum(a) from table_like_with_partial_roll_up group by a order by 1"

// test if not exists
sql "drop table if exists table_like_with_partial_roll_up_exists"
sql """CREATE TABLE if not exists table_like_with_partial_roll_up_exists
LIKE mal_test_create_table_like with rollup (ru1);"""
waitIndexVisible("table_like_with_partial_roll_up_exists", ["ru1"], 60000)

sql "drop table if exists test_create_table_like_char_255"
sql """
Expand Down

0 comments on commit 02c39d0

Please sign in to comment.