Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test](mv) Move inject statistic earlier for cbo chose stabilization #46787

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ suite ("agg_have_dup_base") {
sql "insert into d_table select -4,-4,-4,'d';"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k4 set stats ('row_count'='5');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1;"
Expand All @@ -60,7 +61,6 @@ suite ("agg_have_dup_base") {
qt_select_mv "select unix_timestamp(k1) tmp,sum(k2) from d_table group by tmp order by tmp;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k4 set stats ('row_count'='5');"""

mv_rewrite_success("select k1,sum(k2),max(k2) from d_table group by k1;", "k12s3m")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ suite ("test_agg_state_max_by") {
}

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k4 set stats ('row_count'='8');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by 1,2;"
mv_rewrite_success("select k1,max_by(k2,k3) from d_table group by k1 order by 1,2;", "k1mb")
sql """set enable_stats=true;"""
sql """alter table d_table modify column k4 set stats ('row_count'='8');"""
mv_rewrite_success("select k1,max_by(k2,k3) from d_table group by k1 order by 1,2;", "k1mb")
qt_select_mv "select k1,max_by(k2,k3) from d_table group by k1 order by 1,2;"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ suite ("case_ignore") {
sql "insert into d_table select -4,-4,-4,'d';"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k4 set stats ('row_count'='8');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1;"
Expand Down
2 changes: 1 addition & 1 deletion regression-test/suites/mv_p0/count_star/count_star.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ suite ("count_star") {
sql "insert into d_table values(2,1,1,'a'),(2,1,1,'a');"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k4 set stats ('row_count'='8');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1,k2,k3,k4;"
Expand All @@ -65,7 +66,6 @@ suite ("count_star") {

sql """set enable_stats=true;"""

sql """alter table d_table modify column k4 set stats ('row_count'='8');"""
mv_rewrite_success("select k1,k4,count(*) from d_table group by k1,k4;", "kstar")
mv_rewrite_success("select k1,k4,count(*) from d_table where k1=1 group by k1,k4;", "kstar")
mv_rewrite_fail("select k1,k4,count(*) from d_table where k3=1 group by k1,k4;", "kstar")
Expand Down
2 changes: 2 additions & 0 deletions regression-test/suites/mv_p0/dis_26495/dis_26495.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ suite ("dis_26495") {

sql """alter table doris_test modify column agg_st_1 set stats ('row_count'='1');"""

sql """set enable_stats=false;"""

streamLoad {
table "doris_test"
set 'column_separator', ','
Expand Down
4 changes: 2 additions & 2 deletions regression-test/suites/mv_p0/k1ap2spa/k1ap2spa.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ suite ("k1ap2spa") {

qt_select_star "select * from d_table order by k1;"

sql """alter table d_table modify column k1 set stats ('row_count'='5');"""

sql "analyze table d_table with sync;"
sql """set enable_stats=false;"""

Expand All @@ -52,8 +54,6 @@ suite ("k1ap2spa") {

sql """set enable_stats=true;"""

sql """alter table d_table modify column k1 set stats ('row_count'='5');"""

mv_rewrite_success("select abs(k1)+1 t,sum(abs(k2+1)) from d_table group by t order by t;", "k1ap2spa")

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ suite ("k1s2m3_auto_inc") {
qt_select_star "select * from d_table order by k1;"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k1 set stats ('row_count'='2');"""
sql """set enable_stats=false;"""

mv_rewrite_success("select k3,sum(abs(k2+1)) from d_table group by k3 order by 1;", "k3ap2spa")
qt_select_mv "select k3,sum(abs(k2+1)) from d_table group by k3 order by 1;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='2');"""
mv_rewrite_success("select k3,sum(abs(k2+1)) from d_table group by k3 order by 1;", "k3ap2spa")
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ suite ("multi_agg_with_same_slot") {
sql "insert into d_table(k4,k2,k5) values('d',4,4);"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1;"
Expand All @@ -64,7 +65,6 @@ suite ("multi_agg_with_same_slot") {

sql """set enable_stats=true;"""

sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
mv_rewrite_success("select k1,k2,avg(k3),max(k3) from d_table group by k1,k2 order by 1,2;", "kmv")
mv_rewrite_success("select k1,k2,avg(k3)+max(k3) from d_table group by k1,k2 order by 1,2;", "kmv")
mv_rewrite_success("select k1,k2,avg(k3)+max(k3) from d_table group by grouping sets((k1),(k1,k2),()) order by 1,2;", "kmv")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ suite ("multi_slot_k123p") {
}
sql """sync"""
sql "analyze table d_table with sync;"
sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
sql """set enable_stats=false;"""
qt_select_star "select * from d_table order by k1,k4;"

Expand All @@ -63,6 +64,5 @@ suite ("multi_slot_k123p") {
qt_select_mv "select k1,version() from d_table order by k1;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
mv_rewrite_success("select k1,k2+k3 from d_table order by k1;", "k123p")
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ suite ("multi_slot_k1a2p2ap3p") {
qt_select_star "select * from d_table order by k1;"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k1 set stats ('row_count'='7');"""
sql """set enable_stats=false;"""

mv_rewrite_success("select abs(k1)+k2+1,abs(k2+2)+k3+3 from d_table order by abs(k1)+k2+1,abs(k2+2)+k3+3", "k1a2p2ap3p")
qt_select_mv "select abs(k1)+k2+1,abs(k2+2)+k3+3 from d_table order by abs(k1)+k2+1,abs(k2+2)+k3+3;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='7');"""
mv_rewrite_success("select abs(k1)+k2+1,abs(k2+2)+k3+3 from d_table order by abs(k1)+k2+1,abs(k2+2)+k3+3", "k1a2p2ap3p")

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ suite ("multi_slot_k1a2p2ap3ps") {
sql "insert into d_table select -4,-4,-4,'d';"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k1 set stats ('row_count'='4');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1;"
Expand All @@ -60,8 +61,6 @@ suite ("multi_slot_k1a2p2ap3ps") {
mv_rewrite_fail("select abs(k1)+k2+1,sum(abs(k2+2)+k3+3) from d_table group by abs(k1)+k2 order by abs(k1)+k2", "k1a2p2ap3ps")
qt_select_base "select abs(k1)+k2+1,sum(abs(k2+2)+k3+3) from d_table group by abs(k1)+k2 order by abs(k1)+k2;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='4');"""
mv_rewrite_success("select abs(k1)+k2+1,sum(abs(k2+2)+k3+3) from d_table group by abs(k1)+k2+1 order by abs(k1)+k2+1", "k1a2p2ap3ps")

mv_rewrite_fail("select abs(k1)+k2+1,sum(abs(k2+2)+k3+3) from d_table group by abs(k1)+k2 order by abs(k1)+k2", "k1a2p2ap3ps")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ suite ("multi_slot_k1p2ap3p") {
sql "insert into d_table select -4,-4,-4,'d';"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k1 set stats ('row_count'='4');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1;"
Expand All @@ -50,6 +51,5 @@ suite ("multi_slot_k1p2ap3p") {
qt_select_mv "select k1+1,abs(k2+2)+k3+3 from d_table order by k1+1;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='4');"""
mv_rewrite_success("select k1+1,abs(k2+2)+k3+3 from d_table order by k1+1;", "k1p2ap3p")
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ suite ("multi_slot_k1p2ap3ps") {
sql "insert into d_table select -4,-4,-4,'d';"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1;"
Expand All @@ -50,6 +51,5 @@ suite ("multi_slot_k1p2ap3ps") {
qt_select_mv "select k1+1,sum(abs(k2+2)+k3+3) from d_table group by k1+1 order by k1+1;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
mv_rewrite_success("select k1+1,sum(abs(k2+2)+k3+3) from d_table group by k1+1 order by k1+1;", "k1p2ap3ps")
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ suite ("multi_slot_multi_mv") {
qt_select_star "select * from d_table order by k1;"

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
sql """set enable_stats=false;"""

def retry_times = 60
Expand Down Expand Up @@ -82,7 +83,6 @@ suite ("multi_slot_multi_mv") {
qt_select_mv "select abs(k1)+k2+1,abs(k2+2)+k3+3 from d_table order by abs(k1)+k2+1,abs(k2+2)+k3+3;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
for (def i = 0; i < retry_times; ++i) {
boolean is_k1a2p2ap3p = false
boolean is_k1a2p2ap3ps = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ suite ("mv_with_view") {
sql """insert into d_table select 3,-3,null,'c';"""

sql "analyze table d_table with sync;"
sql """alter table d_table modify column k1 set stats ('row_count'='3');"""
sql """set enable_stats=false;"""

mv_rewrite_fail("select * from d_table order by k1;", "k312")
Expand All @@ -67,7 +68,6 @@ suite ("mv_with_view") {
qt_select_mv "select * from v_k124 order by k1;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='3');"""
mv_rewrite_fail("select * from d_table order by k1;", "k312")

sql """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ suite ("routine_load_hll") {
qt_select "select event_id,time_stamp,hll_cardinality(device_id) from test order by 1,2;"

sql "analyze table test with sync;"
sql """alter table test modify column event_id set stats ('row_count'='2');"""
sql """set enable_stats=false;"""

mv_rewrite_success("select time_stamp, hll_union_agg(device_id) from test group by time_stamp order by 1;", "m_view")
qt_select_mv "select time_stamp, hll_union_agg(device_id) from test group by time_stamp order by 1;"

sql """set enable_stats=true;"""
sql """alter table test modify column event_id set stats ('row_count'='2');"""
mv_rewrite_success("select time_stamp, hll_union_agg(device_id) from test group by time_stamp order by 1;", "m_view")
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ suite ("multiple_ssb") {
qt_select_star "select * from lineorder_flat order by 1,2,LO_ORDERPRIORITY, P_MFGR;"

sql """analyze table lineorder_flat with sync;"""
sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='8');"""
sql """set enable_stats=false;"""

mv_rewrite_success("""SELECT SUM(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue
Expand Down Expand Up @@ -240,7 +241,6 @@ suite ("multiple_ssb") {
qt_select_count_3 "select LO_ORDERPRIORITY, count(1) from lineorder_flat where LO_ORDERPRIORITY in ('1','2','3') group by LO_ORDERPRIORITY order by 1,2;"

sql """set enable_stats=true;"""
sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='8');"""
mv_rewrite_success("""SELECT SUM(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue
FROM lineorder_flat
WHERE
Expand Down
2 changes: 1 addition & 1 deletion regression-test/suites/mv_p0/ssb/q_4_1_r1/q_4_1_r1.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ suite ("q_4_1_r1") {
qt_select_star "select * from lineorder_flat order by 1,2,P_MFGR;"

sql """analyze table lineorder_flat with sync;"""
sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='8');"""
sql """set enable_stats=false;"""

mv_rewrite_success("""SELECT (LO_ORDERDATE DIV 10000) AS YEAR,
Expand All @@ -119,7 +120,6 @@ suite ("q_4_1_r1") {
GROUP BY YEAR, C_NATION
ORDER BY YEAR ASC, C_NATION ASC;"""
sql """set enable_stats=true;"""
sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='8');"""
mv_rewrite_success("""SELECT (LO_ORDERDATE DIV 10000) AS YEAR,
C_NATION,
SUM(LO_REVENUE - LO_SUPPLYCOST) AS profit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ suite ("sum_devide_count") {
qt_select_star "select * from d_table order by k1,k2,k3,k4;"

sql """analyze table d_table with sync;"""
sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
sql """set enable_stats=false;"""


Expand All @@ -60,7 +61,6 @@ suite ("sum_devide_count") {
qt_select_mv "select sum(k2)/count(k2) from d_table;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='5');"""
mv_rewrite_success("select k1,k4,sum(k2)/count(k2) from d_table group by k1,k4 order by k1,k4;", "kavg")

mv_rewrite_success("select k1,sum(k2)/count(k2) from d_table group by k1 order by k1;", "kavg")
Expand Down
2 changes: 1 addition & 1 deletion regression-test/suites/mv_p0/test_28741/test_28741.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ suite ("test_28741") {
sql "INSERT INTO test(a,a1,b,b1,c,t,d,d1,e) VALUES (1,1,2,'-',3,'2023-12-20 17:21:00', 56, 78, 89)"

sql """analyze table test with sync;"""
sql """alter table test modify column a set stats ('row_count'='2');"""
sql """set enable_stats=false;"""

mv_rewrite_fail("select b1 from test where t >= '2023-12-20 17:21:00'", "mv_test")

sql """set enable_stats=true;"""
sql """alter table test modify column a set stats ('row_count'='2');"""
mv_rewrite_fail("select b1 from test where t >= '2023-12-20 17:21:00'", "mv_test")
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ suite ("test_approx_count_distinct") {
sql """insert into user_tags values("2020-01-01",1,"a",2);"""

sql """analyze table user_tags with sync;"""
sql """alter table user_tags modify column time_col set stats ('row_count'='3');"""
sql """set enable_stats=false;"""

mv_rewrite_fail("select * from user_tags order by time_col;", "user_tags_mv")
Expand All @@ -50,7 +51,6 @@ suite ("test_approx_count_distinct") {
qt_select_mv "select user_id, approx_count_distinct(tag_id) a from user_tags group by user_id order by user_id;"

sql """set enable_stats=true;"""
sql """alter table user_tags modify column time_col set stats ('row_count'='3');"""
mv_rewrite_fail("select * from user_tags order by time_col;", "user_tags_mv")

mv_rewrite_success("select user_id, ndv(tag_id) a from user_tags group by user_id order by user_id;", "user_tags_mv")
Expand Down
2 changes: 1 addition & 1 deletion regression-test/suites/mv_p0/test_base/test_base.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ suite ("test_base") {
sql """insert into dwd(id) values(2);"""

sql "analyze table dwd with sync;"
sql """alter table dwd modify column id set stats ('row_count'='2');"""
sql """set enable_stats=false;"""

mv_rewrite_success("SELECT created_at, id FROM dwd where created_at = '2020-09-09 00:00:00' order by 1, 2;", "dwd_mv")
Expand All @@ -53,7 +54,6 @@ suite ("test_base") {
qt_select_mv "SELECT id,created_at FROM dwd order by 1, 2;"

sql """set enable_stats=true;"""
sql """alter table dwd modify column id set stats ('row_count'='2');"""
mv_rewrite_success("SELECT created_at, id FROM dwd where created_at = '2020-09-09 00:00:00' order by 1, 2;", "dwd_mv")

mv_rewrite_success("SELECT id,created_at FROM dwd where id is not null order by 1, 2;", "dwd_mv")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ suite ("test_casewhen") {
sql """insert into sales_records values(1,1,1,"2020-02-02",1),(1,2,2,"2020-02-02",1);"""

sql """analyze table sales_records with sync;"""
sql """alter table sales_records modify column record_id set stats ('row_count'='4');"""
sql """set enable_stats=false;"""

qt_select_star "select * from sales_records order by 1,2;"
Expand All @@ -40,6 +41,5 @@ suite ("test_casewhen") {
qt_select_mv "select store_id, sum(case when sale_amt>10 then 1 else 2 end) from sales_records group by store_id order by 1;"

sql """set enable_stats=true;"""
sql """alter table sales_records modify column record_id set stats ('row_count'='4');"""
mv_rewrite_success("select store_id, sum(case when sale_amt>10 then 1 else 2 end) from sales_records group by store_id order by 1;", "store_amt")
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ suite ("test_doc_e4") {
sql "insert into d_table select 3,-3,null,'2022-02-20';"

sql """analyze table d_table with sync;"""
sql """alter table d_table modify column k1 set stats ('row_count'='3');"""
sql """set enable_stats=false;"""

mv_rewrite_success("select abs(k1)+k2+1,sum(abs(k2+2)+k3+3) from d_table group by abs(k1)+k2+1 order by 1,2;", "k1a2p2ap3ps")
Expand All @@ -57,7 +58,6 @@ suite ("test_doc_e4") {
qt_select_mv "select year(k4)+month(k4) from d_table where year(k4) = 2020 order by 1;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='3');"""
mv_rewrite_success("select abs(k1)+k2+1,sum(abs(k2+2)+k3+3) from d_table group by abs(k1)+k2+1 order by 1,2;", "k1a2p2ap3ps")

mv_rewrite_success("select bin(abs(k1)+k2+1),sum(abs(k2+2)+k3+3) from d_table group by bin(abs(k1)+k2+1);", "k1a2p2ap3ps")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ suite ("test_dup_group_by_mv_abs") {
sql "insert into d_table select -4,-4,-4,'d';"

sql """analyze table d_table with sync;"""
sql """alter table d_table modify column k1 set stats ('row_count'='4');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1;"
Expand All @@ -53,7 +54,6 @@ suite ("test_dup_group_by_mv_abs") {
qt_select_mv_sub "select sum(abs(k2)) from d_table group by k1 order by k1;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='4');"""
mv_rewrite_success("select k1,sum(abs(k2)) from d_table group by k1;", "k12sa")
mv_rewrite_success("select sum(abs(k2)) from d_table group by k1;", "k12sa")
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ suite ("test_dup_group_by_mv_plus") {
sql "insert into d_table select -4,-4,-4,'d';"

sql """analyze table d_table with sync;"""
sql """alter table d_table modify column k1 set stats ('row_count'='4');"""
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1;"
Expand All @@ -53,7 +54,6 @@ suite ("test_dup_group_by_mv_plus") {
qt_select_mv_sub "select sum(k2+1) from d_table group by k1 order by k1;"

sql """set enable_stats=true;"""
sql """alter table d_table modify column k1 set stats ('row_count'='4');"""
mv_rewrite_success("select k1,sum(k2+1) from d_table group by k1;", "k12sp")
mv_rewrite_success("select sum(k2+1) from d_table group by k1;", "k12sp")

Expand Down
Loading
Loading