Skip to content

Commit 665ef2d

Browse files
committed
update
Signed-off-by: Seaven <seaven_7@qq.com>
1 parent 5499393 commit 665ef2d

16 files changed

+717
-153
lines changed

fe/fe-core/src/main/java/com/starrocks/analysis/AnalyticExpr.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ public boolean isSkewed() {
203203
return isSkewed;
204204
}
205205

206+
public String getSqlString() {
207+
return sqlString;
208+
}
209+
206210
@Override
207211
public boolean equalsWithoutChild(Object obj) {
208212
if (!super.equalsWithoutChild(obj)) {

fe/fe-core/src/main/java/com/starrocks/analysis/ArithmeticExpr.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,6 @@ public String toSqlImpl() {
435435
}
436436
}
437437

438-
@Override
439-
protected String explainImpl() {
440-
if (children.size() == 1) {
441-
return op.toString() + " " + getChild(0).explain();
442-
} else {
443-
return getChild(0).explain() + " " + op.toString() + " " + getChild(1).explain();
444-
}
445-
}
446-
447438
@Override
448439
protected void toThrift(TExprNode msg) {
449440
msg.node_type = TExprNodeType.ARITHMETIC_EXPR;

fe/fe-core/src/main/java/com/starrocks/analysis/BinaryPredicate.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,6 @@ public String toSqlImpl() {
145145
return getChild(0).toSql() + " " + op.toString() + " " + getChild(1).toSql();
146146
}
147147

148-
@Override
149-
public String explainImpl() {
150-
return getChild(0).explain() + " " + op.toString() + " " + getChild(1).explain();
151-
}
152-
153148
@Override
154149
protected void toThrift(TExprNode msg) {
155150
msg.node_type = TExprNodeType.BINARY_PRED;

fe/fe-core/src/main/java/com/starrocks/analysis/CastExpr.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ private static String getFnName(Type targetType) {
117117
return "castTo" + targetType.getPrimitiveType().toString();
118118
}
119119

120+
public boolean isNoOp() {
121+
return noOp;
122+
}
123+
120124
@Override
121125
public Expr clone() {
122126
return new CastExpr(this);
@@ -131,15 +135,6 @@ public String toSqlImpl() {
131135
}
132136
}
133137

134-
@Override
135-
protected String explainImpl() {
136-
if (noOp) {
137-
return getChild(0).explain();
138-
} else {
139-
return "cast(" + getChild(0).explain() + " as " + type.toString() + ")";
140-
}
141-
}
142-
143138
@Override
144139
protected void toThrift(TExprNode msg) {
145140
msg.node_type = TExprNodeType.CAST_EXPR;

fe/fe-core/src/main/java/com/starrocks/analysis/CloneExpr.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ protected String toSqlImpl() {
4444
return "clone(" + getChild(0).toSqlImpl() + ")";
4545
}
4646

47-
@Override
48-
protected String explainImpl() {
49-
return "clone(" + getChild(0).explain() + ")";
50-
}
51-
5247
@Override
5348
protected void toThrift(TExprNode msg) {
5449
msg.setNode_type(TExprNodeType.CLONE_EXPR);

fe/fe-core/src/main/java/com/starrocks/analysis/DateLiteral.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,6 @@ public void parseMysqlParam(ByteBuffer data) {
501501

502502
@Override
503503
public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
504-
return ((AstVisitorExtendInterface<R, C>) visitor).visitLiteral(this, context);
504+
return ((AstVisitorExtendInterface<R, C>) visitor).visitDateLiteral(this, context);
505505
}
506506
}

fe/fe-core/src/main/java/com/starrocks/analysis/Expr.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
import com.starrocks.sql.common.StarRocksPlannerException;
6464
import com.starrocks.sql.common.UnsupportedException;
6565
import com.starrocks.sql.formatter.AST2SQLVisitor;
66+
import com.starrocks.sql.formatter.ExprExplainVisitor;
67+
import com.starrocks.sql.formatter.ExprVerboseVisitor;
6668
import com.starrocks.sql.formatter.FormatOptions;
6769
import com.starrocks.sql.optimizer.operator.scalar.ColumnRefOperator;
6870
import com.starrocks.sql.optimizer.operator.scalar.ScalarOperator;
@@ -569,7 +571,7 @@ public static <C extends Expr> boolean containsAggregate(List<? extends Expr> in
569571
@Deprecated
570572
public String toSql() {
571573
Preconditions.checkState(!printSqlInParens);
572-
return (printSqlInParens) ? "(" + toSqlImpl() + ")" : toSqlImpl();
574+
return ExprExplainVisitor.explain(this);
573575
}
574576

575577
/**
@@ -583,7 +585,7 @@ public String toSqlWithoutTbl() {
583585

584586
public String explain() {
585587
Preconditions.checkState(!printSqlInParens);
586-
return (printSqlInParens) ? "(" + explainImpl() + ")" : explainImpl();
588+
return ExprVerboseVisitor.explain(this);
587589
}
588590

589591
/**
@@ -594,10 +596,6 @@ protected String toSqlImpl() {
594596
throw new StarRocksPlannerException("Not implement toSqlImpl function", ErrorType.INTERNAL_ERROR);
595597
}
596598

597-
protected String explainImpl() {
598-
return toSqlImpl();
599-
}
600-
601599
public String toMySql() {
602600
return toSql();
603601
}

fe/fe-core/src/main/java/com/starrocks/analysis/FunctionCallExpr.java

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ public void resetAnalysisState() {
214214
}
215215
}
216216

217+
public FunctionParams getFnParams() {
218+
return fnParams;
219+
}
220+
217221
// TODO: process order by
218222
@Override
219223
public String toSqlImpl() {
@@ -235,54 +239,6 @@ public String toSqlImpl() {
235239
return sb.toString();
236240
}
237241

238-
@Override
239-
public String explainImpl() {
240-
StringBuilder sb = new StringBuilder();
241-
sb.append(fnName);
242-
243-
sb.append("[");
244-
sb.append("(");
245-
if (fnParams.isStar()) {
246-
sb.append("*");
247-
}
248-
if (fnParams.isDistinct()) {
249-
sb.append("distinct ");
250-
}
251-
if (fnParams.getOrderByElements() == null) {
252-
sb.append(Joiner.on(", ").join(firstNChildrenToExplain(children.size()))).append(");");
253-
} else {
254-
sb.append(Joiner.on(", ").join(firstNChildrenToExplain(
255-
children.size() - fnParams.getOrderByElements().size())));
256-
sb.append(fnParams.getOrderByStringToExplain());
257-
sb.append(')');
258-
}
259-
if (fn != null) {
260-
sb.append(" args: ");
261-
for (int i = 0; i < fn.getArgs().length; ++i) {
262-
if (i != 0) {
263-
sb.append(',');
264-
}
265-
sb.append(fn.getArgs()[i].getPrimitiveType().toString());
266-
}
267-
sb.append(";");
268-
sb.append(" result: ").append(type).append(";");
269-
}
270-
sb.append(" args nullable: ").append(hasNullableChild()).append(";");
271-
sb.append(" result nullable: ").append(isNullable());
272-
sb.append("]");
273-
return sb.toString();
274-
}
275-
276-
// explain the first N children
277-
public List<String> firstNChildrenToExplain(int n) {
278-
Preconditions.checkState(n <= children.size());
279-
List<String> result = Lists.newArrayList();
280-
for (int i = 0; i < n; i++) {
281-
result.add(children.get(i).explain());
282-
}
283-
return result;
284-
}
285-
286242
public List<String> firstNChildrenToSql(int n) {
287243
Preconditions.checkState(n <= children.size());
288244
List<String> result = Lists.newArrayList();

fe/fe-core/src/main/java/com/starrocks/analysis/FunctionParams.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,6 @@ public String getOrderByStringToSql() {
130130
}
131131
}
132132

133-
public String getOrderByStringToExplain() {
134-
if (orderByElements != null && !orderByElements.isEmpty()) {
135-
StringBuilder sb = new StringBuilder();
136-
sb.append(" ORDER BY ").append(orderByElements.stream().map(OrderByElement::explain).
137-
collect(Collectors.joining(" ")));
138-
return sb.toString();
139-
} else {
140-
return "";
141-
}
142-
}
143133
public boolean isStar() {
144134
return isStar;
145135
}

fe/fe-core/src/main/java/com/starrocks/analysis/SlotRef.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ public SlotDescriptor getSlotDescriptorWithoutCheck() {
268268
return desc;
269269
}
270270

271+
public TableName getTblName() {
272+
return tblName;
273+
}
274+
275+
public String getColName() {
276+
return colName;
277+
}
278+
271279
@Override
272280
public String debugString() {
273281
MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this);
@@ -306,19 +314,6 @@ public boolean isColumnRef() {
306314
return tblName != null && !isFromLambda();
307315
}
308316

309-
@Override
310-
public String explainImpl() {
311-
if (label != null) {
312-
return "[" + label + "," +
313-
" " + desc.getType() + "," +
314-
" " + desc.getIsNullable() + "]";
315-
} else {
316-
return "[" + desc.getId().asInt() + "," +
317-
" " + desc.getType() + "," +
318-
" " + desc.getIsNullable() + "]";
319-
}
320-
}
321-
322317
@Override
323318
public String toMySql() {
324319
if (label == null) {

0 commit comments

Comments
 (0)