This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 4610f26a6e [fix](auth)fix row policy use alias error (#19976)
4610f26a6e is described below
commit 4610f26a6ed88d1b77e622addc6df7821c5541a8
Author: zhangdong <[email protected]>
AuthorDate: Thu May 25 09:10:31 2023 +0800
[fix](auth)fix row policy use alias error (#19976)
Issue Number: close #19975
---
.../org/apache/doris/analysis/StmtRewriter.java | 2 +-
.../java/org/apache/doris/policy/PolicyTest.java | 27 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
index 68025e2e1f..23aa255d57 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
@@ -1335,7 +1335,7 @@ public class StmtRewriter {
SelectStmt stmt = new SelectStmt(selectList,
new FromClause(Lists.newArrayList(tableRef)),
- matchPolicy.getWherePredicate(),
+ matchPolicy.getWherePredicate().clone(),
null,
null,
null,
diff --git a/fe/fe-core/src/test/java/org/apache/doris/policy/PolicyTest.java
b/fe/fe-core/src/test/java/org/apache/doris/policy/PolicyTest.java
index b53bbe46ef..554e5dca70 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/policy/PolicyTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/policy/PolicyTest.java
@@ -104,6 +104,33 @@ public class PolicyTest extends TestWithFeService {
dropPolicy("DROP ROW POLICY test_row_policy ON test.table1 FOR
test_policy");
}
+ @Test
+ public void testAliasSql() throws Exception {
+ createPolicy("CREATE ROW POLICY test_row_policy ON test.table1 AS
PERMISSIVE TO test_policy USING (k1 = 1)");
+ String queryStr = "EXPLAIN select * from test.table1 a";
+ String explainString = getSQLPlanOrErrorMsg(queryStr);
+ Assertions.assertTrue(explainString.contains("`a`.`k1` = 1"));
+ queryStr = "EXPLAIN select * from test.table1 b";
+ explainString = getSQLPlanOrErrorMsg(queryStr);
+ Assertions.assertTrue(explainString.contains("`b`.`k1` = 1"));
+ dropPolicy("DROP ROW POLICY test_row_policy ON test.table1 FOR
test_policy");
+ }
+
+ @Test
+ public void testAliasSqlNereidsPlanner() throws Exception {
+ boolean beforeConfig =
connectContext.getSessionVariable().isEnableNereidsPlanner();
+ connectContext.getSessionVariable().setEnableNereidsPlanner(true);
+ createPolicy("CREATE ROW POLICY test_row_policy ON test.table1 AS
PERMISSIVE TO test_policy USING (k1 = 1)");
+ String queryStr = "EXPLAIN select * from test.table1 a";
+ String explainString = getSQLPlanOrErrorMsg(queryStr);
+ Assertions.assertTrue(explainString.contains("`a`.`k1` = 1"));
+ queryStr = "EXPLAIN select * from test.table1 b";
+ explainString = getSQLPlanOrErrorMsg(queryStr);
+ Assertions.assertTrue(explainString.contains("`b`.`k1` = 1"));
+ dropPolicy("DROP ROW POLICY test_row_policy ON test.table1 FOR
test_policy");
+
connectContext.getSessionVariable().setEnableNereidsPlanner(beforeConfig);
+ }
+
@Test
public void testUnionSql() throws Exception {
createPolicy("CREATE ROW POLICY test_row_policy ON test.table1 AS
PERMISSIVE TO test_policy USING (k1 = 1)");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]