mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(Fix)(headless)Fix expression replacement issue. (#2024)
This commit is contained in:
@@ -18,26 +18,8 @@ public class QueryExpressionReplaceVisitor extends ExpressionVisitorAdapter {
|
||||
}
|
||||
|
||||
protected void visitBinaryExpression(BinaryExpression expr) {
|
||||
Expression left = expr.getLeftExpression();
|
||||
String toReplace = "";
|
||||
if (left instanceof Function) {
|
||||
Function leftFunc = (Function) left;
|
||||
if (leftFunc.getParameters().getExpressions().get(0) instanceof Column) {
|
||||
toReplace = getReplaceExpr(leftFunc, fieldExprMap);
|
||||
}
|
||||
}
|
||||
if (left instanceof Column) {
|
||||
toReplace = getReplaceExpr((Column) left, fieldExprMap);
|
||||
}
|
||||
if (!toReplace.isEmpty()) {
|
||||
Expression expression = getExpression(toReplace);
|
||||
if (Objects.nonNull(expression)) {
|
||||
expr.setLeftExpression(expression);
|
||||
return;
|
||||
}
|
||||
}
|
||||
expr.getLeftExpression().accept(this);
|
||||
expr.getRightExpression().accept(this);
|
||||
expr.setLeftExpression(replace(expr.getLeftExpression(), fieldExprMap));
|
||||
expr.setRightExpression(replace(expr.getRightExpression(), fieldExprMap));
|
||||
}
|
||||
|
||||
public void visit(SelectItem selectExpressionItem) {
|
||||
@@ -59,6 +41,11 @@ public class QueryExpressionReplaceVisitor extends ExpressionVisitorAdapter {
|
||||
columnName = column.getColumnName();
|
||||
toReplace = getReplaceExpr((Column) expression, fieldExprMap);
|
||||
}
|
||||
if (expression instanceof BinaryExpression) {
|
||||
BinaryExpression binaryExpression = (BinaryExpression) expression;
|
||||
visitBinaryExpression(binaryExpression);
|
||||
}
|
||||
|
||||
if (!toReplace.isEmpty()) {
|
||||
Expression toReplaceExpr = getExpression(toReplace);
|
||||
if (Objects.nonNull(toReplaceExpr)) {
|
||||
|
||||
@@ -11,7 +11,7 @@ public class QueryColumn {
|
||||
|
||||
private String name;
|
||||
private String type;
|
||||
private String nameEn;
|
||||
private String bizName;
|
||||
private String showType;
|
||||
private Boolean authorized = true;
|
||||
private String dataFormatType;
|
||||
@@ -19,16 +19,16 @@ public class QueryColumn {
|
||||
private String comment;
|
||||
private Long modelId;
|
||||
|
||||
public QueryColumn(String nameEn, String type) {
|
||||
public QueryColumn(String bizName, String type) {
|
||||
this.type = type;
|
||||
this.nameEn = nameEn;
|
||||
this.name = nameEn;
|
||||
this.bizName = bizName;
|
||||
this.name = bizName;
|
||||
}
|
||||
|
||||
public QueryColumn(String name, String type, String nameEn) {
|
||||
public QueryColumn(String name, String type, String bizName) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.nameEn = nameEn;
|
||||
this.bizName = bizName;
|
||||
this.showType = "CATEGORY";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user