Skip to content

Commit

Permalink
fix regression
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Sep 23, 2024
1 parent 968e382 commit 6a35e96
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 13 deletions.
12 changes: 8 additions & 4 deletions fe/fe-core/src/test/java/org/apache/doris/policy/PolicyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,17 @@ public void testComplexSql() throws Exception {
createPolicy("CREATE ROW POLICY test_row_policy1 ON test.table1 AS RESTRICTIVE TO test_policy USING (k1 = 1)");
createPolicy("CREATE ROW POLICY test_row_policy2 ON test.table1 AS RESTRICTIVE TO test_policy USING (k2 = 1)");
String joinSql = "select * from table1 join table2 on table1.k1=table2.k1";
Assertions.assertTrue(getSQLPlanOrErrorMsg(joinSql).contains("PREDICATES: ((k2 = 1) AND (k1 = 1))"));
Assertions.assertTrue(getSQLPlanOrErrorMsg(joinSql).contains("PREDICATES: ((k2 = 1) AND (k1 = 1))")
|| getSQLPlanOrErrorMsg(joinSql).contains("PREDICATES: ((k1 = 1) AND (k2 = 1))"));
String unionSql = "select * from table1 union select * from table2";
Assertions.assertTrue(getSQLPlanOrErrorMsg(unionSql).contains("PREDICATES: ((k2 = 1) AND (k1 = 1))"));
Assertions.assertTrue(getSQLPlanOrErrorMsg(unionSql).contains("PREDICATES: ((k2 = 1) AND (k1 = 1))")
|| getSQLPlanOrErrorMsg(joinSql).contains("PREDICATES: ((k1 = 1) AND (k2 = 1))"));
String subQuerySql = "select * from table2 where k1 in (select k1 from table1)";
Assertions.assertTrue(getSQLPlanOrErrorMsg(subQuerySql).contains("PREDICATES: ((k2 = 1) AND (k1 = 1))"));
Assertions.assertTrue(getSQLPlanOrErrorMsg(subQuerySql).contains("PREDICATES: ((k2 = 1) AND (k1 = 1))")
|| getSQLPlanOrErrorMsg(joinSql).contains("PREDICATES: ((k1 = 1) AND (k2 = 1))"));
String aliasSql = "select * from table1 t1 join table2 t2 on t1.k1=t2.k1";
Assertions.assertTrue(getSQLPlanOrErrorMsg(aliasSql).contains("PREDICATES: ((k2 = 1) AND (k1 = 1))"));
Assertions.assertTrue(getSQLPlanOrErrorMsg(aliasSql).contains("PREDICATES: ((k2 = 1) AND (k1 = 1))")
|| getSQLPlanOrErrorMsg(joinSql).contains("PREDICATES: ((k1 = 1) AND (k2 = 1))"));
dropPolicy("DROP ROW POLICY test_row_policy1 ON test.table1");
dropPolicy("DROP ROW POLICY test_row_policy2 ON test.table1");
}
Expand Down
2 changes: 1 addition & 1 deletion regression-test/data/nereids_hint_tpch_p0/shape/q12.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PhysicalResultSink
------------------PhysicalProject
--------------------PhysicalOlapScan[orders]
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate > lineitem.l_shipdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate > lineitem.l_commitdate) and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and l_shipmode IN ('MAIL', 'SHIP'))
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Hint log:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PhysicalResultSink
------------------PhysicalProject
--------------------PhysicalOlapScan[orders] apply RFs: RF0
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_commitdate > lineitem.l_shipdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate > lineitem.l_commitdate) and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PhysicalResultSink
------------------PhysicalProject
--------------------PhysicalOlapScan[orders] apply RFs: RF0
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_commitdate > lineitem.l_shipdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate > lineitem.l_commitdate) and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PhysicalResultSink
------------------PhysicalProject
--------------------PhysicalOlapScan[orders] apply RFs: RF0
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_commitdate > lineitem.l_shipdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate > lineitem.l_commitdate) and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PhysicalResultSink
------------------PhysicalProject
--------------------PhysicalOlapScan[orders] apply RFs: RF0
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_commitdate > lineitem.l_shipdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate > lineitem.l_commitdate) and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PhysicalResultSink
------------------PhysicalProject
--------------------PhysicalOlapScan[orders] apply RFs: RF0
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_commitdate > lineitem.l_shipdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate > lineitem.l_commitdate) and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PhysicalResultSink
------------------PhysicalProject
--------------------PhysicalOlapScan[orders] apply RFs: RF0
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_commitdate > lineitem.l_shipdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate > lineitem.l_commitdate) and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PhysicalResultSink
------------------PhysicalProject
--------------------PhysicalOlapScan[orders] apply RFs: RF0
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_commitdate > lineitem.l_shipdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate > lineitem.l_commitdate) and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PhysicalResultSink
------------------PhysicalProject
--------------------PhysicalOlapScan[orders] apply RFs: RF0
------------------PhysicalProject
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_commitdate > lineitem.l_shipdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate > lineitem.l_commitdate) and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP'))
----------------------PhysicalOlapScan[lineitem]

Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ suite("infer_unequal_predicates") {
sql "insert into test_like2 values(1,'d2',3,5);"
sql "insert into test_like2 values(0,'d2',3,5);"
sql "insert into test_like2 values(0,'d2',3,7);"

sql "drop table if exists test_cast_infer9"
sql """
create table test_cast_infer9(d_int int, d_char100 char(100), d_smallint smallint, d_tinyint tinyint, d_char10 char(10),d_datetimev2 datetimev2, d_datev2 datev2,d_date date, d_datetime datetime) properties('replication_num'='1');
"""
sql """
insert into test_cast_infer9 values(1,'01234567890123456789', 3,3,'0123456789','2020-01-09 10:00:00.99','2020-01-09','2022-08-09','2022-08-09 10:00:00'),(14,'01234567890123456789', 33,23,'0123456789','2020-01-11 10:00:00.99','2020-01-11','2022-08-03','2022-08-09 10:00:02');
"""

// c<a, a<1 -> c<1 should not be inferred
qt_not_infer_same_table_have_mid_column """
explain shape plan
Expand Down

0 comments on commit 6a35e96

Please sign in to comment.