github-actions[bot] commented on code in PR #63635:
URL: https://github.com/apache/doris/pull/63635#discussion_r3339035707


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowCatalogRecycleBinCommand.java:
##########
@@ -98,59 +107,120 @@ public void validate() throws AnalysisException {
 
         if (!analyzeWhereClause()) {
             throw new AnalysisException("Where clause should like: Name = 
\"name\", "
-                    + " or Name LIKE \"matcher\"");
+                    + "or Name LIKE \"matcher\", or Type = 
\"Database|Table|Partition\", "
+                    + "or DbId = \"db_id\", or TableId = \"table_id\", "
+                    + "or compound predicate with operator AND");
         }
     }
 
     private boolean analyzeWhereClause() {
         if (whereClause == null) {
             return true;
-        } else if (whereClause instanceof EqualTo) {
-            EqualTo equalTo = (EqualTo) whereClause;
-            if (equalTo.left() instanceof UnboundSlot
-                    && 
equalTo.child(0).toSql().toLowerCase(Locale.ROOT).equals("name")
-                    && equalTo.right() instanceof Literal) {
-                nameValue = ((Literal) equalTo.right()).getStringValue();
-            } else {
+        }
+        List<Expression> andExprs = 
ExpressionUtils.extractConjunction(whereClause);
+        for (Expression expr : andExprs) {
+            if (!analyzeSinglePredicate(expr)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private boolean analyzeSinglePredicate(Expression expr) {
+        if (expr instanceof EqualTo) {
+            EqualTo equalTo = (EqualTo) expr;
+            if (!(equalTo.left() instanceof UnboundSlot) || !(equalTo.right() 
instanceof Literal)) {
+                return false;
+            }
+            String colName = equalTo.child(0).toSql().toLowerCase(Locale.ROOT);
+            String value = ((Literal) equalTo.right()).getStringValue();
+            if (Strings.isNullOrEmpty(value)) {
+                return false;
+            }
+            switch (colName) {

Review Comment:
   This loses SQL `AND` semantics when the same column appears more than once. 
Each accepted conjunct overwrites the single stored value for that column, so 
`WHERE Type = "Partition" AND Type = "Table"` is validated and then returns all 
tables instead of no rows; similarly `Name = "p111" AND Name LIKE "q%"` is 
reduced to one name predicate, with `isAccurateMatch` also depending on parse 
order. Please either accumulate and apply every single predicate to each row, 
or reject duplicate filters for the same column during validation. The new 
tests only cover distinct columns, so this regression is currently untested.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to