(Fix)(headless)Fix expression replacement issue. (#2024)
Some checks failed
supersonic CentOS CI / build (21) (push) Has been cancelled
supersonic mac CI / build (21) (push) Has been cancelled
supersonic ubuntu CI / build (21) (push) Has been cancelled
supersonic windows CI / build (21) (push) Has been cancelled

This commit is contained in:
Jun Zhang
2025-01-30 08:54:42 +08:00
committed by GitHub
parent be5eeae707
commit de92b357df
18 changed files with 44 additions and 57 deletions

View File

@@ -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)) {

View File

@@ -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";
}