Skip to content

Commit

Permalink
[chore](Nereids) change some exception type and message
Browse files Browse the repository at this point in the history
  • Loading branch information
morrySnow committed Nov 22, 2024
1 parent babd6ce commit 5e4eefe
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ public ConnectContext getConnectContext() {

public abstract void execute();

public EventProducer getEventTracer() {
throw new UnsupportedOperationException("get_event_tracer is unsupported");
}

protected Optional<CopyInResult> invokeRewriteRuleWithTrace(Rule rule, Plan before, Group targetGroup) {
context.onInvokeRule(rule.getRuleType());
COUNTER_TRACER.log(CounterEvent.of(Memo.getStateId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public boolean hasNext() {
@Override
public Plan next() {
if (!hasNext()) {
throw new NoSuchElementException();
throw new NoSuchElementException("GroupExpressionIterator is empty");
}
return results.get(resultIndex++);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.doris.common.Config;
import org.apache.doris.common.IdGenerator;
import org.apache.doris.common.Pair;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.DebugUtil;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.nereids.glue.translator.ExpressionTranslator;
Expand Down Expand Up @@ -272,7 +271,8 @@ private static Map<String, Expression> evalOnBE(Map<String, Map<String, TExpr>>
try {
List<Long> backendIds = Env.getCurrentSystemInfo().getAllBackendByCurrentCluster(true);
if (backendIds.isEmpty()) {
throw new UserException("No alive backends");
LOG.warn("no available backend ids for folding constant on BE");
return Collections.emptyMap();
}
Collections.shuffle(backendIds);
Backend be = Env.getCurrentSystemInfo().getBackend(backendIds.get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public L next() {
current = doGetNext(current);
return toLiteral.apply(value);
}
throw new NoSuchElementException();
throw new NoSuchElementException("RangePartitionValueIterator is empty");
}

protected abstract C doGetNext(C current);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.doris.catalog.PartitionType;
import org.apache.doris.catalog.RangePartitionItem;
import org.apache.doris.catalog.TableIf;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.Pair;
import org.apache.doris.nereids.CascadesContext;
Expand Down Expand Up @@ -600,7 +599,7 @@ private ColumnStatistic updateMinMaxForPartitionKey(OlapTable olapTable,
return cache;
}

private double convertLegacyLiteralToDouble(LiteralExpr literal) throws AnalysisException {
private double convertLegacyLiteralToDouble(LiteralExpr literal) throws org.apache.doris.common.AnalysisException {
return StatisticsUtil.convertToDouble(literal.getType(), literal.getStringValue());
}

Expand Down Expand Up @@ -641,7 +640,7 @@ private ColumnStatistic updateMinMaxForListPartitionKey(OlapTable olapTable,
if (minExpr != null) {
cache = updateMinMax(cache, minValue, minExpr, maxValue, maxExpr);
}
} catch (AnalysisException e) {
} catch (org.apache.doris.common.AnalysisException e) {
LOG.debug(e.getMessage());
}
}
Expand Down Expand Up @@ -691,7 +690,7 @@ private ColumnStatistic updateMinMaxForTheFirstRangePartitionKey(OlapTable olapT
if (minExpr != null) {
cache = updateMinMax(cache, minValue, minExpr, maxValue, maxExpr);
}
} catch (AnalysisException e) {
} catch (org.apache.doris.common.AnalysisException e) {
LOG.debug(e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.doris.common.Pair;
import org.apache.doris.common.util.DebugUtil;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.plans.PlanType;
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.qe.ConnectContext;
Expand Down Expand Up @@ -87,7 +88,7 @@ public ShowResultSet doRun(ConnectContext ctx, StmtExecutor executor) throws Exc
PrivPredicate.ADMIN.getPrivs().toString());
}
if (tabletIds == null || tabletIds.isEmpty()) {
throw new Exception("Please supply at least one tablet id");
throw new AnalysisException("Please supply at least one tablet id");
}

// main logic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.doris.analysis.DefaultValueExprDef;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.nereids.exceptions.AnalysisException;

/**
* default value of a column.
Expand Down Expand Up @@ -77,7 +78,7 @@ public DefaultValue(String value, String exprName, Long precision) {
*/
public static DefaultValue currentTimeStampDefaultValueWithPrecision(Long precision) {
if (precision > ScalarType.MAX_DATETIMEV2_SCALE || precision < 0) {
throw new IllegalArgumentException("column's default value current_timestamp"
throw new AnalysisException("column's default value current_timestamp"
+ " precision must be between 0 and 6");
}
if (precision == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.doris.analysis.StringLiteral;
import org.apache.doris.catalog.AggregateType;
import org.apache.doris.catalog.PartitionType;
import org.apache.doris.common.DdlException;
import org.apache.doris.nereids.analyzer.UnboundFunction;
import org.apache.doris.nereids.analyzer.UnboundSlot;
import org.apache.doris.nereids.exceptions.AnalysisException;
Expand Down Expand Up @@ -261,16 +260,15 @@ public PartitionDesc convertToPartitionDesc(boolean isExternal) {
partitionDescs.size(), createTablePartitionMaxNum));
}

try {
ArrayList<Expr> exprs = convertToLegacyAutoPartitionExprs(partitionList);
ArrayList<Expr> exprs = convertToLegacyAutoPartitionExprs(partitionList);

// only auto partition support partition expr
if (!isAutoPartition) {
if (exprs.stream().anyMatch(expr -> expr instanceof FunctionCallExpr)) {
throw new DdlException("Non-auto partition table not support partition expr!");
}
// only auto partition support partition expr
if (!isAutoPartition) {
if (exprs.stream().anyMatch(expr -> expr instanceof FunctionCallExpr)) {
throw new AnalysisException("Non-auto partition table not support partition expr!");
}

}
try {
// here we have already extracted identifierPartitionColumns
if (partitionType.equals(PartitionType.RANGE.name())) {
if (isAutoPartition) {
Expand All @@ -293,7 +291,7 @@ public PartitionDesc convertToPartitionDesc(boolean isExternal) {
}

private static ArrayList<Expr> convertToLegacyAutoPartitionExprs(List<Expression> expressions) {
return new ArrayList<>(expressions.stream().map(expression -> {
return expressions.stream().map(expression -> {
if (expression instanceof UnboundSlot) {
return new SlotRef(null, ((UnboundSlot) expression).getName());
} else if (expression instanceof UnboundFunction) {
Expand All @@ -303,9 +301,9 @@ private static ArrayList<Expr> convertToLegacyAutoPartitionExprs(List<Expression
new FunctionParams(convertToLegacyArguments(function.children())));
} else {
throw new AnalysisException(
"unsupported auto partition expr " + expression.toString());
"unsupported auto partition expr " + expression.toString());
}
}).collect(Collectors.toList()));
}).collect(Collectors.toCollection(ArrayList::new));
}

private static List<Expr> convertToLegacyArguments(List<Expression> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ private UnassignedJob buildLeafOrScanJob(
return unassignedJob;
}

throw new IllegalStateException("Unsupported build UnassignedJob for fragment: "
throw new IllegalStateException("Cannot generate unassignedJob for fragment"
+ " has both OlapScanNode and Other ScanNode: "
+ planFragment.getExplainString(TExplainLevel.VERBOSE));
}

Expand Down

0 comments on commit 5e4eefe

Please sign in to comment.