Skip to content

Commit 8e3c030

Browse files
zy-kkkdataroaring
authored andcommitted
[fix](expr) Enhance SQL Expression Handling by Introducing printSqlInParens to CompoundPredicate (#39064)
This PR enhances SQL expression handling by introducing a printSqlInParens flag to the CompoundPredicate class and setting it to true. This ensures that expressions in a CompoundPredicate are always enclosed in parentheses, similar to how it is handled in a BinaryPredicate. . By removing redundant handling of CompoundPredicate, the logic for handling SQL generation in the JdbcScanNode node has been simplified as the updated toSql method now handles this uniformly across expressions.
1 parent 75f9594 commit 8e3c030

File tree

14 files changed

+128
-87
lines changed

14 files changed

+128
-87
lines changed

fe/fe-core/src/main/java/org/apache/doris/analysis/CompoundPredicate.java

+2
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ public CompoundPredicate(Operator op, Expr e1, Expr e2) {
6767
if (e2 != null) {
6868
children.add(e2);
6969
}
70+
printSqlInParens = true;
7071
}
7172

7273
protected CompoundPredicate(CompoundPredicate other) {
7374
super(other);
7475
op = other.op;
76+
printSqlInParens = true;
7577
}
7678

7779
@Override

fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/source/JdbcScanNode.java

+1-33
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import org.apache.doris.analysis.Analyzer;
2121
import org.apache.doris.analysis.BinaryPredicate;
2222
import org.apache.doris.analysis.BoolLiteral;
23-
import org.apache.doris.analysis.CompoundPredicate;
24-
import org.apache.doris.analysis.CompoundPredicate.Operator;
2523
import org.apache.doris.analysis.DateLiteral;
2624
import org.apache.doris.analysis.Expr;
2725
import org.apache.doris.analysis.ExprSubstitutionMap;
@@ -329,36 +327,6 @@ private static boolean containsFunctionCallExpr(Expr expr) {
329327
}
330328

331329
public static String conjunctExprToString(TOdbcTableType tableType, Expr expr, TableIf tbl) {
332-
if (expr instanceof CompoundPredicate) {
333-
StringBuilder result = new StringBuilder();
334-
CompoundPredicate compoundPredicate = (CompoundPredicate) expr;
335-
336-
// If the operator is 'NOT', prepend 'NOT' to the start of the string
337-
if (compoundPredicate.getOp() == Operator.NOT) {
338-
result.append("NOT ");
339-
}
340-
341-
// Iterate through all children of the CompoundPredicate
342-
for (Expr child : compoundPredicate.getChildren()) {
343-
// Recursively call conjunctExprToString for each child and append to the result
344-
result.append(conjunctExprToString(tableType, child, tbl));
345-
346-
// If the operator is not 'NOT', append the operator after each child expression
347-
if (!(compoundPredicate.getOp() == Operator.NOT)) {
348-
result.append(" ").append(compoundPredicate.getOp().toString()).append(" ");
349-
}
350-
}
351-
352-
// For operators other than 'NOT', remove the extra appended operator at the end
353-
// This is necessary for operators like 'AND' or 'OR' that appear between child expressions
354-
if (!(compoundPredicate.getOp() == Operator.NOT)) {
355-
result.setLength(result.length() - compoundPredicate.getOp().toString().length() - 2);
356-
}
357-
358-
// Return the processed string trimmed of any extra spaces
359-
return result.toString().trim();
360-
}
361-
362330
if (expr.contains(DateLiteral.class) && expr instanceof BinaryPredicate) {
363331
ArrayList<Expr> children = expr.getChildren();
364332
String filter = children.get(0).toExternalSql(TableType.JDBC_EXTERNAL_TABLE, tbl);
@@ -375,7 +343,7 @@ public static String conjunctExprToString(TOdbcTableType tableType, Expr expr, T
375343
return filter;
376344
}
377345

378-
// only for old planner
346+
// Only for old planner
379347
if (expr.contains(BoolLiteral.class) && "1".equals(expr.getStringValue()) && expr.getChildren().isEmpty()) {
380348
return "1 = 1";
381349
}

fe/fe-core/src/test/java/org/apache/doris/analysis/CancelExportStmtTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ public void testNormal() throws UserException {
9393
stmt = new CancelExportStmt(null, compoundAndPredicate);
9494
stmt.analyze(analyzer);
9595
Assertions.assertEquals(
96-
"CANCEL EXPORT FROM testDb WHERE (`label` = 'doris_test_label') AND (`state` = 'PENDING')",
96+
"CANCEL EXPORT FROM testDb WHERE ((`label` = 'doris_test_label') AND (`state` = 'PENDING'))",
9797
stmt.toString());
9898

9999
CompoundPredicate compoundOrPredicate = new CompoundPredicate(Operator.OR, labelBinaryPredicate,
100100
stateBinaryPredicate);
101101
stmt = new CancelExportStmt(null, compoundOrPredicate);
102102
stmt.analyze(analyzer);
103103
Assertions.assertEquals(
104-
"CANCEL EXPORT FROM testDb WHERE (`label` = 'doris_test_label') OR (`state` = 'PENDING')",
104+
"CANCEL EXPORT FROM testDb WHERE ((`label` = 'doris_test_label') OR (`state` = 'PENDING'))",
105105
stmt.toString());
106106
}
107107

fe/fe-core/src/test/java/org/apache/doris/analysis/CancelLoadStmtTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ public void testNormal() throws UserException {
9494
stmt = new CancelLoadStmt(null, compoundAndPredicate);
9595
stmt.analyze(analyzer);
9696
Assertions.assertEquals(
97-
"CANCEL LOAD FROM testDb WHERE (`label` = 'doris_test_label') AND (`state` = 'LOADING')",
97+
"CANCEL LOAD FROM testDb WHERE ((`label` = 'doris_test_label') AND (`state` = 'LOADING'))",
9898
stmt.toString());
9999

100100
CompoundPredicate compoundOrPredicate = new CompoundPredicate(Operator.OR, labelBinaryPredicate,
101101
stateBinaryPredicate);
102102
stmt = new CancelLoadStmt(null, compoundOrPredicate);
103103
stmt.analyze(analyzer);
104104
Assertions.assertEquals(
105-
"CANCEL LOAD FROM testDb WHERE (`label` = 'doris_test_label') OR (`state` = 'LOADING')",
105+
"CANCEL LOAD FROM testDb WHERE ((`label` = 'doris_test_label') OR (`state` = 'LOADING'))",
106106
stmt.toString());
107107

108108
// test match

fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ public void testDeduplicateOrs() throws Exception {
300300
String commonExpr2 = "`t3`.`k3` = `t1`.`k3`";
301301
String commonExpr3 = "`t1`.`k1` = `t5`.`k1`";
302302
String commonExpr4 = "t5`.`k2` = 'United States'";
303-
String betweenExpanded1 = "(CAST(CAST(`t1`.`k4` AS decimalv3(12,2)) AS int) >= 100) AND (CAST(CAST(`t1`.`k4` AS decimalv3(12,2)) AS int) <= 150)";
304-
String betweenExpanded2 = "(CAST(CAST(`t1`.`k4` AS decimalv3(12,2)) AS int) >= 50) AND (CAST(CAST(`t1`.`k4` AS decimalv3(12,2)) AS int) <= 100)";
305-
String betweenExpanded3 = "(`t1`.`k4` >= 50) AND (`t1`.`k4` <= 250)";
303+
String betweenExpanded1 = "(CAST(CAST(`t1`.`k4` AS decimalv3(12,2)) AS int) >= 100)) AND (CAST(CAST(`t1`.`k4` AS decimalv3(12,2)) AS int) <= 150))";
304+
String betweenExpanded2 = "(CAST(CAST(`t1`.`k4` AS decimalv3(12,2)) AS int) >= 50)) AND (CAST(CAST(`t1`.`k4` AS decimalv3(12,2)) AS int) <= 100))";
305+
String betweenExpanded3 = "(`t1`.`k4` >= 50)) AND (`t1`.`k4` <= 250)";
306306

307307
String rewrittenSql = stmt.toSql();
308308
Assert.assertTrue(rewrittenSql.contains(commonExpr1));
@@ -346,17 +346,17 @@ public void testDeduplicateOrs() throws Exception {
346346
SelectStmt stmt2 = (SelectStmt) UtFrameUtils.parseAndAnalyzeStmt(sql2, ctx);
347347
stmt2.rewriteExprs(new Analyzer(ctx.getEnv(), ctx).getExprRewriter());
348348
String fragment3 =
349-
"((((`t1`.`k4` >= 50) AND (`t1`.`k4` <= 300)) AND `t2`.`k2` IN ('United States', 'United States1') "
349+
"(((((`t1`.`k4` >= 50) AND (`t1`.`k4` <= 300)) AND `t2`.`k2` IN ('United States', 'United States1')) "
350350
+ "AND `t2`.`k3` IN ('CO', 'IL', 'MN', 'OH', 'MT', 'NM', 'TX', 'MO', 'MI')) "
351-
+ "AND (`t1`.`k1` = `t2`.`k3`) AND (`t2`.`k2` = 'United States') "
352-
+ "AND `t2`.`k3` IN ('CO', 'IL', 'MN') AND (`t1`.`k4` >= 100) AND (`t1`.`k4` <= 200) "
351+
+ "AND (((((((`t1`.`k1` = `t2`.`k3`) AND (`t2`.`k2` = 'United States')) "
352+
+ "AND `t2`.`k3` IN ('CO', 'IL', 'MN')) AND (`t1`.`k4` >= 100)) AND (`t1`.`k4` <= 200)) "
353353
+ "OR "
354-
+ "(`t1`.`k1` = `t2`.`k1`) AND (`t2`.`k2` = 'United States1') "
355-
+ "AND `t2`.`k3` IN ('OH', 'MT', 'NM') AND (`t1`.`k4` >= 150) AND (`t1`.`k4` <= 300) "
354+
+ "(((((`t1`.`k1` = `t2`.`k1`) AND (`t2`.`k2` = 'United States1')) "
355+
+ "AND `t2`.`k3` IN ('OH', 'MT', 'NM')) AND (`t1`.`k4` >= 150)) AND (`t1`.`k4` <= 300))) "
356356
+ "OR "
357-
+ "(`t1`.`k1` = `t2`.`k1`) AND (`t2`.`k2` = 'United States') "
358-
+ "AND `t2`.`k3` IN ('TX', 'MO', 'MI') "
359-
+ "AND (`t1`.`k4` >= 50) AND (`t1`.`k4` <= 250))";
357+
+ "(((((`t1`.`k1` = `t2`.`k1`) AND (`t2`.`k2` = 'United States')) "
358+
+ "AND `t2`.`k3` IN ('TX', 'MO', 'MI')) "
359+
+ "AND (`t1`.`k4` >= 50)) AND (`t1`.`k4` <= 250))))";
360360
Assert.assertTrue(stmt2.toSql().contains(fragment3));
361361

362362
String sql3 = "select\n"
@@ -416,7 +416,7 @@ public void testDeduplicateOrs() throws Exception {
416416
SelectStmt stmt7 = (SelectStmt) UtFrameUtils.parseAndAnalyzeStmt(sql7, ctx);
417417
stmt7.rewriteExprs(new Analyzer(ctx.getEnv(), ctx).getExprRewriter());
418418
Assert.assertTrue(stmt7.toSql()
419-
.contains("`t2`.`k1` IS NOT NULL OR `t1`.`k1` IS NOT NULL AND `t1`.`k2` IS NOT NULL"));
419+
.contains("`t2`.`k1` IS NOT NULL OR (`t1`.`k1` IS NOT NULL AND `t1`.`k2` IS NOT NULL)"));
420420

421421
String sql8 = "select\n"
422422
+ " avg(t1.k4)\n"
@@ -428,13 +428,13 @@ public void testDeduplicateOrs() throws Exception {
428428
SelectStmt stmt8 = (SelectStmt) UtFrameUtils.parseAndAnalyzeStmt(sql8, ctx);
429429
stmt8.rewriteExprs(new Analyzer(ctx.getEnv(), ctx).getExprRewriter());
430430
Assert.assertTrue(stmt8.toSql()
431-
.contains("`t2`.`k1` IS NOT NULL AND `t1`.`k1` IS NOT NULL AND `t1`.`k1` IS NOT NULL"));
431+
.contains("(`t2`.`k1` IS NOT NULL AND `t1`.`k1` IS NOT NULL) AND `t1`.`k1` IS NOT NULL"));
432432

433433
String sql9 = "select * from db1.tbl1 where (k1='shutdown' and k4<1) or (k1='switchOff' and k4>=1)";
434434
SelectStmt stmt9 = (SelectStmt) UtFrameUtils.parseAndAnalyzeStmt(sql9, ctx);
435435
stmt9.rewriteExprs(new Analyzer(ctx.getEnv(), ctx).getExprRewriter());
436436
Assert.assertTrue(
437-
stmt9.toSql().contains("(`k1` = 'shutdown') AND (`k4` < 1) OR (`k1` = 'switchOff') AND (`k4` >= 1)"));
437+
stmt9.toSql().contains("((`k1` = 'shutdown') AND (`k4` < 1)) OR ((`k1` = 'switchOff') AND (`k4` >= 1))"));
438438
}
439439

440440
@Test

fe/fe-core/src/test/java/org/apache/doris/analysis/ShowBuildIndexStmtTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ public ProcNodeInterface open(String path) throws AnalysisException {
9898
List<OrderByElement> orderBy = Arrays.asList(
9999
new OrderByElement(new SlotRef(tableName, "TableName"), false, false));
100100
ShowBuildIndexStmt stmt1 = new ShowBuildIndexStmt(null, where, orderBy, new LimitElement(1, 100));
101-
Assertions.assertEquals(stmt1.toSql(), "SHOW BUILD INDEX WHERE (`a`.`b`.`c`.`createtime` > '%.b.%') "
102-
+ "AND (`a`.`b`.`c`.`tablename` = '%.b.%') ORDER BY `a`.`b`.`c`.`TableName` DESC NULLS LAST "
101+
Assertions.assertEquals(stmt1.toSql(), "SHOW BUILD INDEX WHERE ((`a`.`b`.`c`.`createtime` > '%.b.%') "
102+
+ "AND (`a`.`b`.`c`.`tablename` = '%.b.%')) ORDER BY `a`.`b`.`c`.`TableName` DESC NULLS LAST "
103103
+ "LIMIT 1, 100");
104104

105105
stmt1.analyze(analyzer);
106106
Assertions.assertEquals(stmt1.toSql(), "SHOW BUILD INDEX FROM `testDb` WHERE "
107-
+ "(`a`.`b`.`c`.`createtime` > CAST('%.b.%' AS datetimev2(0))) "
108-
+ "AND (`a`.`b`.`c`.`tablename` = '%.b.%') "
107+
+ "((`a`.`b`.`c`.`createtime` > CAST('%.b.%' AS datetimev2(0))) "
108+
+ "AND (`a`.`b`.`c`.`tablename` = '%.b.%')) "
109109
+ "ORDER BY `a`.`b`.`c`.`TableName` DESC NULLS LAST LIMIT 1, 100");
110110

111111
Assertions.assertEquals(stmt1.getFilterMap().size(), 2);

fe/fe-core/src/test/java/org/apache/doris/analysis/SqlModeTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void testPipesAsConcatMode() {
8080
if (!(expr instanceof CompoundPredicate)) {
8181
Assert.fail();
8282
}
83-
Assert.assertEquals("'a' OR 'b' OR 'c'", expr.toSql());
83+
Assert.assertEquals("(('a' OR 'b') OR 'c')", expr.toSql());
8484
}
8585

8686
@Test

fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java

+11-12
Original file line numberDiff line numberDiff line change
@@ -2235,15 +2235,15 @@ public void testRewriteOrToIn() throws Exception {
22352235

22362236
sql = "SELECT /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where (query_time = 1 or query_time = 2) and query_time in (3, 4)";
22372237
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
2238-
Assert.assertTrue(explainString.contains("PREDICATES: `query_time` IN (1, 2) AND `query_time` IN (3, 4)\n"));
2238+
Assert.assertTrue(explainString.contains("PREDICATES: (`query_time` IN (1, 2) AND `query_time` IN (3, 4))\n"));
22392239

22402240
sql = "SELECT /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where (query_time = 1 or query_time = 2 or scan_bytes = 2) and scan_bytes in (2, 3)";
22412241
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
2242-
Assert.assertTrue(explainString.contains("PREDICATES: `query_time` IN (1, 2) OR (`scan_bytes` = 2) AND `scan_bytes` IN (2, 3)\n"));
2242+
Assert.assertTrue(explainString.contains("PREDICATES: ((`query_time` IN (1, 2) OR (`scan_bytes` = 2)) AND `scan_bytes` IN (2, 3))\n"));
22432243

22442244
sql = "SELECT /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where (query_time = 1 or query_time = 2) and (scan_bytes = 2 or scan_bytes = 3)";
22452245
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
2246-
Assert.assertTrue(explainString.contains("PREDICATES: `query_time` IN (1, 2) AND `scan_bytes` IN (2, 3)\n"));
2246+
Assert.assertTrue(explainString.contains("PREDICATES: (`query_time` IN (1, 2) AND `scan_bytes` IN (2, 3))\n"));
22472247

22482248
sql = "SELECT /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where query_time = 1 or query_time = 2 or query_time = 3 or query_time = 1";
22492249
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
@@ -2256,22 +2256,22 @@ public void testRewriteOrToIn() throws Exception {
22562256
connectContext.getSessionVariable().setRewriteOrToInPredicateThreshold(100);
22572257
sql = "SELECT /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where query_time = 1 or query_time = 2 or query_time in (3, 4)";
22582258
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
2259-
Assert.assertTrue(explainString.contains("PREDICATES: (`query_time` = 1) OR (`query_time` = 2) OR `query_time` IN (3, 4)\n"));
2259+
Assert.assertTrue(explainString.contains("PREDICATES: (((`query_time` = 1) OR (`query_time` = 2)) OR `query_time` IN (3, 4))\n"));
22602260
connectContext.getSessionVariable().setRewriteOrToInPredicateThreshold(2);
22612261

22622262
sql = "SELECT /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where (query_time = 1 or query_time = 2) and query_time in (3, 4)";
22632263
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
2264-
Assert.assertTrue(explainString.contains("PREDICATES: `query_time` IN (1, 2) AND `query_time` IN (3, 4)\n"));
2264+
Assert.assertTrue(explainString.contains("PREDICATES: (`query_time` IN (1, 2) AND `query_time` IN (3, 4))\n"));
22652265

22662266
//test we can handle `!=` and `not in`
22672267
sql = "select /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where (query_time = 1 or query_time = 2 or query_time!= 3 or query_time not in (5, 6))";
22682268
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
2269-
Assert.assertTrue(explainString.contains("PREDICATES: `query_time` IN (1, 2) OR (`query_time` != 3) OR `query_time` NOT IN (5, 6)\n"));
2269+
Assert.assertTrue(explainString.contains("PREDICATES: (`query_time` IN (1, 2) OR ((`query_time` != 3) OR `query_time` NOT IN (5, 6)))\n"));
22702270

22712271
//test we can handle merge 2 or more columns
22722272
sql = "select /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where (query_time = 1 or query_time = 2 or scan_rows = 3 or scan_rows = 4)";
22732273
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
2274-
Assert.assertTrue(explainString.contains("PREDICATES: `query_time` IN (1, 2) OR `scan_rows` IN (3, 4)"));
2274+
Assert.assertTrue(explainString.contains("PREDICATES: (`query_time` IN (1, 2) OR `scan_rows` IN (3, 4))"));
22752275

22762276
//merge in-pred or in-pred
22772277
sql = "select /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where (query_time = 1 or query_time = 2 or query_time = 3 or query_time = 4)";
@@ -2286,16 +2286,15 @@ public void testRewriteOrToIn() throws Exception {
22862286
+ " or (db not in ('x', 'y')) ";
22872287
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
22882288
Assert.assertTrue(explainString.contains(
2289-
"PREDICATES: (`query_id` = `client_ip`) "
2290-
+ "AND (`stmt_id` IN (1, 2, 3) OR (`user` = 'abc') AND `state` IN ('a', 'b', 'c', 'd')) "
2291-
+ "OR (`db` NOT IN ('x', 'y'))\n"));
2289+
"PREDICATES: (((`query_id` = `client_ip`) AND (`stmt_id` IN (1, 2, 3) OR ((`user` = 'abc') "
2290+
+ "AND `state` IN ('a', 'b', 'c', 'd')))) OR (`db` NOT IN ('x', 'y')))\n"));
22922291

22932292
//ExtractCommonFactorsRule may generate more expr, test the rewriteOrToIn applied on generated exprs
22942293
sql = "select /*+ SET_VAR(enable_nereids_planner=false) */ * from test1 where (stmt_id=1 and state='a') or (stmt_id=2 and state='b')";
22952294
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "EXPLAIN " + sql);
22962295
Assert.assertTrue(explainString.contains(
2297-
"PREDICATES: `state` IN ('a', 'b') AND `stmt_id` IN (1, 2) AND"
2298-
+ " (`stmt_id` = 1) AND (`state` = 'a') OR (`stmt_id` = 2) AND (`state` = 'b')\n"
2296+
"PREDICATES: ((`state` IN ('a', 'b') AND `stmt_id` IN (1, 2)) AND (((`stmt_id` = 1) AND "
2297+
+ "(`state` = 'a')) OR ((`stmt_id` = 2) AND (`state` = 'b'))))\n"
22992298
));
23002299
}
23012300
}

fe/fe-core/src/test/java/org/apache/doris/policy/PolicyTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public void testMergeFilter() throws Exception {
270270
createPolicy("CREATE ROW POLICY test_row_policy4 ON test.table1 AS PERMISSIVE TO test_policy USING (k2 = 1)");
271271
String queryStr = "EXPLAIN select /*+ SET_VAR(enable_nereids_planner=false) */ * from test.table1";
272272
String explainString = getSQLPlanOrErrorMsg(queryStr);
273-
Assertions.assertTrue(explainString.contains("(`k1` = 1) AND (`k2` = 1) AND (`k2` = 2) OR (`k2` = 1)"));
273+
Assertions.assertTrue(explainString.contains("(((`k1` = 1) AND (`k2` = 1)) AND ((`k2` = 2) OR (`k2` = 1)))"));
274274
dropPolicy("DROP ROW POLICY test_row_policy1 ON test.table1");
275275
dropPolicy("DROP ROW POLICY test_row_policy2 ON test.table1");
276276
dropPolicy("DROP ROW POLICY test_row_policy3 ON test.table1");
@@ -318,13 +318,13 @@ public void testComplexSqlNereidsPlanner() throws Exception {
318318
createPolicy("CREATE ROW POLICY test_row_policy1 ON test.table1 AS RESTRICTIVE TO test_policy USING (k1 = 1)");
319319
createPolicy("CREATE ROW POLICY test_row_policy2 ON test.table1 AS RESTRICTIVE TO test_policy USING (k2 = 1)");
320320
String joinSql = "select * from table1 join table2 on table1.k1=table2.k1";
321-
Assertions.assertTrue(getSQLPlanOrErrorMsg(joinSql).contains("PREDICATES: (k1 = 1) AND (k2 = 1)"));
321+
Assertions.assertTrue(getSQLPlanOrErrorMsg(joinSql).contains("PREDICATES: ((k1 = 1) AND (k2 = 1))"));
322322
String unionSql = "select * from table1 union select * from table2";
323-
Assertions.assertTrue(getSQLPlanOrErrorMsg(unionSql).contains("PREDICATES: (k1 = 1) AND (k2 = 1)"));
323+
Assertions.assertTrue(getSQLPlanOrErrorMsg(unionSql).contains("PREDICATES: ((k1 = 1) AND (k2 = 1))"));
324324
String subQuerySql = "select * from table2 where k1 in (select k1 from table1)";
325-
Assertions.assertTrue(getSQLPlanOrErrorMsg(subQuerySql).contains("PREDICATES: (k1 = 1) AND (k2 = 1)"));
325+
Assertions.assertTrue(getSQLPlanOrErrorMsg(subQuerySql).contains("PREDICATES: ((k1 = 1) AND (k2 = 1))"));
326326
String aliasSql = "select * from table1 t1 join table2 t2 on t1.k1=t2.k1";
327-
Assertions.assertTrue(getSQLPlanOrErrorMsg(aliasSql).contains("PREDICATES: (k1 = 1) AND (k2 = 1)"));
327+
Assertions.assertTrue(getSQLPlanOrErrorMsg(aliasSql).contains("PREDICATES: ((k1 = 1) AND (k2 = 1))"));
328328
dropPolicy("DROP ROW POLICY test_row_policy1 ON test.table1");
329329
dropPolicy("DROP ROW POLICY test_row_policy2 ON test.table1");
330330
}

0 commit comments

Comments
 (0)