mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 13:07:32 +00:00
(improvement)(headless) Delete 'is null' and 'is not null' expressions only in the WHERE clause, and keep them in the HAVING clause (#1680)
This commit is contained in:
@@ -406,9 +406,18 @@ public class SqlRemoveHelper {
|
||||
SelectDeParser selectDeParser = new SelectDeParser(expressionDeParser, buffer);
|
||||
expressionDeParser.setSelectVisitor(selectDeParser);
|
||||
expressionDeParser.setBuffer(buffer);
|
||||
|
||||
selectStatement.accept(selectDeParser);
|
||||
return buffer.toString();
|
||||
PlainSelect plainSelect = (PlainSelect) selectStatement.getSelectBody();
|
||||
if (plainSelect.getWhere() != null) {
|
||||
plainSelect.getWhere().accept(expressionDeParser);
|
||||
}
|
||||
// Parse the modified WHERE clause back to an Expression
|
||||
try {
|
||||
Expression newWhere = CCJSqlParserUtil.parseCondExpression(buffer.toString());
|
||||
plainSelect.setWhere(newWhere);
|
||||
} catch (Exception e) {
|
||||
log.error("parseCondExpression error:{}", buffer, e);
|
||||
}
|
||||
return selectStatement.toString();
|
||||
}
|
||||
|
||||
private static boolean isInvalidSelect(Select selectStatement) {
|
||||
|
||||
Reference in New Issue
Block a user