github-actions[bot] commented on code in PR #63635:
URL: https://github.com/apache/doris/pull/63635#discussion_r3532976414
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowCatalogRecycleBinCommand.java:
##########
@@ -98,59 +107,153 @@ 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. "
+ + "Duplicate filters on the same column are not allowed.");
}
}
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;
}
- isAccurateMatch = true;
- } else if (whereClause instanceof Like) {
- Like like = (Like) whereClause;
- if (like.left() instanceof UnboundSlot
- &&
like.child(0).toSql().toLowerCase(Locale.ROOT).equals("name")
- && like.right() instanceof Literal) {
- nameValue = ((Literal) like.right()).getStringValue();
- } else {
+ }
+ 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;
+ }
+ boolean isDuplicateFilter = false;
+ switch (colName) {
+ case NAME:
+ if (nameValue != null) {
+ isDuplicateFilter = true;
+ } else {
+ nameValue = value;
+ isAccurateMatch = true;
+ }
+ break;
+ case TYPE:
+ if (typeValue != null) {
Review Comment:
The new duplicate check makes validation stateful across executions of the
same command object. In the prepared-statement path, `PrepareCommand` stores
the original logical plan and `ExecuteCommand` reuses
`prepareCommand.getLogicalPlan()` for every `EXECUTE`; this command then calls
`validate()` inside `doRun()`. After the first `EXECUTE` of `SHOW CATALOG
RECYCLE BIN WHERE Type = "Table"`, `typeValue` remains set on the command
instance. The next `EXECUTE` reaches this branch with `typeValue != null`,
treats the single valid predicate as a duplicate, and throws the where-clause
`AnalysisException`. Please make the analyzed filter state local to each
validation/run, or clear `nameValue`, `isAccurateMatch`, `typeValue`,
`dbIdValue`, `tableIdValue` before analyzing, and cover repeated
validation/prepared execution in tests.
--
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]