mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
(improvement)(chat) fix in replace bug (#302)
This commit is contained in:
@@ -59,6 +59,9 @@ public class FieldlValueReplaceVisitor extends ExpressionVisitorAdapter {
|
||||
}
|
||||
|
||||
public void visit(InExpression inExpression) {
|
||||
if (!(inExpression.getLeftExpression() instanceof Column)) {
|
||||
return;
|
||||
}
|
||||
Column column = (Column) inExpression.getLeftExpression();
|
||||
Map<String, String> valueMap = filedNameToValueMap.get(column.getColumnName());
|
||||
ExpressionList rightItemsList = (ExpressionList) inExpression.getRightItemsList();
|
||||
@@ -69,7 +72,13 @@ public class FieldlValueReplaceVisitor extends ExpressionVisitorAdapter {
|
||||
values.add(((StringValue) o).getValue());
|
||||
}
|
||||
});
|
||||
if (valueMap == null) {
|
||||
return;
|
||||
}
|
||||
String value = valueMap.get(JsonUtil.toString(values));
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return;
|
||||
}
|
||||
List<String> valueList = JsonUtil.toList(value, String.class);
|
||||
List<Expression> newExpressions = new ArrayList<>();
|
||||
valueList.stream().forEach(o -> {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.tencent.supersonic.common.util.jsqlparser;
|
||||
|
||||
import java.util.List;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.statement.select.Select;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -13,6 +14,10 @@ class SqlParserSelectHelperTest {
|
||||
@Test
|
||||
void getWhereFilterExpression() {
|
||||
|
||||
Select selectStatement = SqlParserSelectHelper.getSelect(
|
||||
"select 用户名, 访问次数 from 超音数 where 用户名 in ('alice', 'lucy')");
|
||||
System.out.println(selectStatement);
|
||||
|
||||
List<FilterExpression> filterExpression = SqlParserSelectHelper.getFilterExpression(
|
||||
"SELECT department, user_id, field_a FROM s2 WHERE "
|
||||
+ "sys_imp_date = '2023-08-08' AND YEAR(publish_date) = 2023 "
|
||||
|
||||
Reference in New Issue
Block a user