[fix](compile) fe compile failed when generate doc and FE UT failed (#26164)

1. FE could not compile because below error. Intro by PR #25933
```
[INFO] --- exec:3.1.0:java (doc) @ fe-core ---
...
Failed to generate doc for ignoreRuntimeFilterIds
```

2. fix UT bugs intro by below PRs
> - #25951
> - #26031

3. because fe could not compile, FE UT CI do not work well. So, some UT failed be introduced by the PRs merged after PR #25933 merged. So this PR revert them to fix FE UT

> - Revert "[Bug](materialized-view) SelectMaterializedIndexWithAggregate do not change plan > when match ba… (#26145)"
> This reverts commit 8d7abf60f94d2d1208b71e96b9290ea02122b8d8.

> - Revert "[enhancement](Nereids): optimize GroupExpressionMatching (#26130)"
> This reverts commit 19122b55cd95af097b4ef7b6eb809f37db29765f.

> - Revert "[Performance](Nereids): optimize GroupExpressionMatching (#26084)"
> This reverts commit 0d956e90cf920039b8baa79c170a298be56a128d.
This commit is contained in:
morrySnow
2023-11-01 09:50:44 +08:00
committed by GitHub
parent d3c475b06a
commit 18dabe7386
27 changed files with 200 additions and 260 deletions

View File

@ -298,9 +298,6 @@ public class CreateMaterializedViewStmt extends DdlStmt {
if (tableRefList.size() != 1) {
throw new AnalysisException("The materialized view only support one table in from clause.");
}
if (!isReplay && tableRefList.get(0).hasExplicitAlias()) {
throw new AnalysisException("The materialized view not support table with alias.");
}
TableName tableName = tableRefList.get(0).getName();
if (tableName == null) {
throw new AnalysisException("table in from clause is invalid, please check if it's single table "

View File

@ -723,12 +723,12 @@ public class Column implements Writable, GsonPostProcessable {
// show change datetimeV2/dateV2 to datetime/date
if (isCompatible) {
if (type.isDatetimeV2()) {
sb.append("datetime");
sb.append("DATETIME");
if (((ScalarType) type).getScalarScale() > 0) {
sb.append("(").append(((ScalarType) type).getScalarScale()).append(")");
}
} else if (type.isDateV2()) {
sb.append("date");
sb.append("DATE");
} else if (type.isDecimalV3()) {
sb.append("DECIMAL");
ScalarType sType = (ScalarType) type;

View File

@ -61,7 +61,7 @@ public class ApplyRuleJob extends Job {
}
@Override
public final void execute() throws AnalysisException {
public void execute() throws AnalysisException {
if (groupExpression.hasApplied(rule)
|| groupExpression.isUnused()) {
return;

View File

@ -20,6 +20,7 @@ package org.apache.doris.nereids.pattern;
import org.apache.doris.nereids.memo.Group;
import org.apache.doris.nereids.memo.GroupExpression;
import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.trees.plans.GroupPlan;
import org.apache.doris.nereids.trees.plans.Plan;
import com.google.common.collect.ImmutableList;
@ -54,7 +55,6 @@ public class GroupExpressionMatching implements Iterable<Plan> {
public static class GroupExpressionIterator implements Iterator<Plan> {
private final List<Plan> results = Lists.newArrayList();
private int resultIndex = 0;
private int resultsSize;
/**
* Constructor.
@ -69,19 +69,21 @@ public class GroupExpressionMatching implements Iterable<Plan> {
int childrenGroupArity = groupExpression.arity();
int patternArity = pattern.arity();
// (logicalFilter(), multi()) match (logicalFilter()),
// but (logicalFilter(), logicalFilter(), multi()) not match (logicalFilter())
boolean extraMulti = patternArity == childrenGroupArity + 1
&& (pattern.hasMultiChild() || pattern.hasMultiGroupChild());
if (patternArity > childrenGroupArity && !extraMulti) {
return;
}
if (!(pattern instanceof SubTreePattern)) {
// (logicalFilter(), multi()) match (logicalFilter()),
// but (logicalFilter(), logicalFilter(), multi()) not match (logicalFilter())
boolean extraMulti = patternArity == childrenGroupArity + 1
&& (pattern.hasMultiChild() || pattern.hasMultiGroupChild());
if (patternArity > childrenGroupArity && !extraMulti) {
return;
}
// (multi()) match (logicalFilter(), logicalFilter()),
// but (logicalFilter()) not match (logicalFilter(), logicalFilter())
if (!pattern.isAny() && patternArity < childrenGroupArity
&& !pattern.hasMultiChild() && !pattern.hasMultiGroupChild()) {
return;
// (multi()) match (logicalFilter(), logicalFilter()),
// but (logicalFilter()) not match (logicalFilter(), logicalFilter())
if (!pattern.isAny() && patternArity < childrenGroupArity
&& !pattern.hasMultiChild() && !pattern.hasMultiGroupChild()) {
return;
}
}
// Pattern.GROUP / Pattern.MULTI / Pattern.MULTI_GROUP can not match GroupExpression
@ -91,7 +93,7 @@ public class GroupExpressionMatching implements Iterable<Plan> {
// getPlan return the plan with GroupPlan as children
Plan root = groupExpression.getPlan();
if (patternArity == 0) {
if (patternArity == 0 && !(pattern instanceof SubTreePattern)) {
if (pattern.matchPredicates(root)) {
// if no children pattern, we treat all children as GROUP. e.g. Pattern.ANY.
// leaf plan will enter this branch too, e.g. logicalRelation().
@ -101,16 +103,20 @@ public class GroupExpressionMatching implements Iterable<Plan> {
// matching children group, one List<Plan> per child
// first dimension is every child group's plan
// second dimension is all matched plan in one group
List<Plan>[] childrenPlans = new List[childrenGroupArity];
List<List<Plan>> childrenPlans = Lists.newArrayListWithCapacity(childrenGroupArity);
for (int i = 0; i < childrenGroupArity; ++i) {
Group childGroup = groupExpression.child(i);
List<Plan> childrenPlan = matchingChildGroup(pattern, childGroup, i);
if (childrenPlan.isEmpty()) {
// current pattern is match but children patterns not match
return;
if (pattern instanceof SubTreePattern) {
childrenPlan = ImmutableList.of(new GroupPlan(childGroup));
} else {
// current pattern is match but children patterns not match
return;
}
}
childrenPlans[i] = childrenPlan;
childrenPlans.add(childrenPlan);
}
assembleAllCombinationPlanTree(root, pattern, groupExpression, childrenPlans);
} else if (patternArity == 1 && (pattern.hasMultiChild() || pattern.hasMultiGroupChild())) {
@ -121,22 +127,25 @@ public class GroupExpressionMatching implements Iterable<Plan> {
results.add(root);
}
}
this.resultsSize = results.size();
}
private List<Plan> matchingChildGroup(Pattern<? extends Plan> parentPattern,
Group childGroup, int childIndex) {
Pattern<? extends Plan> childPattern;
boolean isLastPattern = childIndex + 1 >= parentPattern.arity();
int patternChildIndex = isLastPattern ? parentPattern.arity() - 1 : childIndex;
if (parentPattern instanceof SubTreePattern) {
childPattern = parentPattern;
} else {
boolean isLastPattern = childIndex + 1 >= parentPattern.arity();
int patternChildIndex = isLastPattern ? parentPattern.arity() - 1 : childIndex;
childPattern = parentPattern.child(patternChildIndex);
// translate MULTI and MULTI_GROUP to ANY and GROUP
if (isLastPattern) {
if (childPattern.isMulti()) {
childPattern = Pattern.ANY;
} else if (childPattern.isMultiGroup()) {
childPattern = Pattern.GROUP;
childPattern = parentPattern.child(patternChildIndex);
// translate MULTI and MULTI_GROUP to ANY and GROUP
if (isLastPattern) {
if (childPattern.isMulti()) {
childPattern = Pattern.ANY;
} else if (childPattern.isMultiGroup()) {
childPattern = Pattern.GROUP;
}
}
}
@ -145,37 +154,40 @@ public class GroupExpressionMatching implements Iterable<Plan> {
}
private void assembleAllCombinationPlanTree(Plan root, Pattern<Plan> rootPattern,
GroupExpression groupExpression, List<Plan>[] childrenPlans) {
int childrenPlansSize = childrenPlans.length;
int[] childrenPlanIndex = new int[childrenPlansSize];
GroupExpression groupExpression,
List<List<Plan>> childrenPlans) {
int[] childrenPlanIndex = new int[childrenPlans.size()];
int offset = 0;
LogicalProperties logicalProperties = groupExpression.getOwnerGroup().getLogicalProperties();
// assemble all combination of plan tree by current root plan and children plan
Optional<GroupExpression> groupExprOption = Optional.of(groupExpression);
Optional<LogicalProperties> logicalPropOption = Optional.of(logicalProperties);
while (offset < childrenPlansSize) {
ImmutableList.Builder<Plan> childrenBuilder = ImmutableList.builderWithExpectedSize(childrenPlansSize);
for (int i = 0; i < childrenPlansSize; i++) {
childrenBuilder.add(childrenPlans[i].get(childrenPlanIndex[i]));
while (offset < childrenPlans.size()) {
ImmutableList.Builder<Plan> childrenBuilder =
ImmutableList.builderWithExpectedSize(childrenPlans.size());
for (int i = 0; i < childrenPlans.size(); i++) {
childrenBuilder.add(childrenPlans.get(i).get(childrenPlanIndex[i]));
}
List<Plan> children = childrenBuilder.build();
// assemble children: replace GroupPlan to real plan,
// withChildren will erase groupExpression, so we must
// withGroupExpression too.
Plan rootWithChildren = root.withGroupExprLogicalPropChildren(groupExprOption,
logicalPropOption, children);
Plan rootWithChildren = root.withGroupExprLogicalPropChildren(Optional.of(groupExpression),
Optional.of(logicalProperties), children);
if (rootPattern.matchPredicates(rootWithChildren)) {
results.add(rootWithChildren);
}
for (offset = 0; offset < childrenPlansSize; offset++) {
offset = 0;
while (true) {
childrenPlanIndex[offset]++;
if (childrenPlanIndex[offset] == childrenPlans[offset].size()) {
// Reset the index when it reaches the size of the current child plan list
if (childrenPlanIndex[offset] == childrenPlans.get(offset).size()) {
childrenPlanIndex[offset] = 0;
offset++;
if (offset == childrenPlans.size()) {
break;
}
} else {
break; // Break the loop when the index is within the size of the current child plan list
break;
}
}
}
@ -183,7 +195,7 @@ public class GroupExpressionMatching implements Iterable<Plan> {
@Override
public boolean hasNext() {
return resultIndex < resultsSize;
return resultIndex < results.size();
}
@Override

View File

@ -45,6 +45,11 @@ public class GroupMatching {
matchingPlans.add(plan);
}
}
for (GroupExpression groupExpression : group.getPhysicalExpressions()) {
for (Plan plan : new GroupExpressionMatching(pattern, groupExpression)) {
matchingPlans.add(plan);
}
}
}
return matchingPlans;
}

View File

@ -38,11 +38,13 @@ import com.google.common.collect.Lists;
public class EnforceMissingPropertiesHelper {
private static final EventProducer ENFORCER_TRACER = new EventProducer(EnforcerEvent.class,
EventChannel.getDefaultChannel().addConsumers(new LogConsumer(EnforcerEvent.class, EventChannel.LOG)));
private final JobContext context;
private final GroupExpression groupExpression;
private Cost curTotalCost;
public EnforceMissingPropertiesHelper(JobContext context, GroupExpression groupExpression,
Cost curTotalCost) {
this.context = context;
this.groupExpression = groupExpression;
this.curTotalCost = curTotalCost;
}

View File

@ -116,10 +116,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
agg.getGroupByExpressions(),
new HashSet<>(agg.getExpressions()));
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan = scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);
@ -166,10 +162,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
requiredExpr
);
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);
@ -215,10 +207,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
collectRequireExprWithAggAndProject(agg.getExpressions(), project.getProjects())
);
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);
@ -277,10 +265,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
requiredExpr
);
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);
@ -338,10 +322,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
requiredExpr
);
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);
@ -389,10 +369,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
nonVirtualGroupByExprs(agg),
new HashSet<>(agg.getExpressions()));
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan = scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);
@ -446,10 +422,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
requiredExpr
);
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);
@ -502,10 +474,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
collectRequireExprWithAggAndProject(agg.getExpressions(), project.getProjects())
);
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);
@ -571,10 +539,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
requiredExpr
);
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);
@ -641,10 +605,6 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
requiredExpr
);
if (result.indexId == scan.getTable().getBaseIndexId()) {
return ctx.root;
}
LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
SlotContext slotContext = generateBaseScanExprToMvExpr(mvPlan);

View File

@ -17,6 +17,10 @@
package org.apache.doris.nereids.trees;
import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator;
import org.apache.doris.nereids.trees.plans.ObjectId;
import org.apache.doris.planner.PlanNodeId;
import com.google.common.collect.ImmutableList;
import java.util.List;
@ -29,6 +33,7 @@ import java.util.List;
*/
public abstract class AbstractTreeNode<NODE_TYPE extends TreeNode<NODE_TYPE>>
implements TreeNode<NODE_TYPE> {
protected final ObjectId id = StatementScopeIdGenerator.newObjectId();
protected final List<NODE_TYPE> children;
// TODO: Maybe we should use a GroupPlan to avoid TreeNode hold the GroupExpression.
// https://github.com/apache/doris/pull/9807#discussion_r884829067
@ -54,4 +59,12 @@ public abstract class AbstractTreeNode<NODE_TYPE extends TreeNode<NODE_TYPE>>
public int arity() {
return children.size();
}
/**
* used for PhysicalPlanTranslator only
* @return PlanNodeId
*/
public PlanNodeId translatePlanNodeId() {
return id.toPlanNodeId();
}
}

View File

@ -37,7 +37,6 @@ import org.apache.doris.nereids.types.coercion.AnyDataType;
import org.apache.doris.nereids.util.Utils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
@ -45,6 +44,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Abstract class for all Expression in Nereids.
@ -247,19 +247,8 @@ public abstract class Expression extends AbstractTreeNode<Expression> implements
return collect(Slot.class::isInstance);
}
/**
* Get all the input slot ids of the expression.
* <p>
* Note that the input slots of subquery's inner plan is not included.
*/
public final Set<ExprId> getInputSlotExprIds() {
ImmutableSet.Builder<ExprId> result = ImmutableSet.builder();
foreach(node -> {
if (node instanceof Slot) {
result.add(((Slot) node).getExprId());
}
});
return result.build();
return getInputSlots().stream().map(NamedExpression::getExprId).collect(Collectors.toSet());
}
public boolean isLiteral() {

View File

@ -24,11 +24,9 @@ import org.apache.doris.nereids.properties.UnboundLogicalProperties;
import org.apache.doris.nereids.trees.AbstractTreeNode;
import org.apache.doris.nereids.trees.expressions.ExprId;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator;
import org.apache.doris.nereids.util.MutableState;
import org.apache.doris.nereids.util.MutableState.EmptyMutableState;
import org.apache.doris.nereids.util.TreeStringUtils;
import org.apache.doris.planner.PlanNodeId;
import org.apache.doris.statistics.Statistics;
import com.google.common.base.Supplier;
@ -47,7 +45,6 @@ import javax.annotation.Nullable;
*/
public abstract class AbstractPlan extends AbstractTreeNode<Plan> implements Plan {
public static final String FRAGMENT_ID = "fragment";
protected final ObjectId id = StatementScopeIdGenerator.newObjectId();
protected final Statistics statistics;
protected final PlanType type;
@ -171,12 +168,4 @@ public abstract class AbstractPlan extends AbstractTreeNode<Plan> implements Pla
public void setMutableState(String key, Object state) {
this.mutableState = this.mutableState.set(key, state);
}
/**
* used for PhysicalPlanTranslator only
* @return PlanNodeId
*/
public PlanNodeId translatePlanNodeId() {
return id.toPlanNodeId();
}
}

View File

@ -43,9 +43,9 @@ import org.apache.doris.statistics.Statistics;
import org.apache.doris.thrift.TRuntimeFilterType;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -113,25 +113,22 @@ public class PhysicalHashJoin<
* Return pair of left used slots and right used slots.
*/
public Pair<List<ExprId>, List<ExprId>> getHashConjunctsExprIds() {
int size = hashJoinConjuncts.size();
List<ExprId> exprIds1 = new ArrayList<>(size);
List<ExprId> exprIds2 = new ArrayList<>(size);
List<ExprId> exprIds1 = Lists.newArrayListWithCapacity(hashJoinConjuncts.size());
List<ExprId> exprIds2 = Lists.newArrayListWithCapacity(hashJoinConjuncts.size());
Set<ExprId> leftExprIds = left().getOutputExprIdSet();
Set<ExprId> rightExprIds = right().getOutputExprIdSet();
for (Expression expr : hashJoinConjuncts) {
for (ExprId exprId : expr.getInputSlotExprIds()) {
expr.getInputSlotExprIds().forEach(exprId -> {
if (leftExprIds.contains(exprId)) {
exprIds1.add(exprId);
} else if (rightExprIds.contains(exprId)) {
exprIds2.add(exprId);
} else {
throw new RuntimeException("Invalid ExprId found: " + exprId
+ ". Cannot generate valid equal on clause slot pairs for join.");
throw new RuntimeException("Could not generate valid equal on clause slot pairs for join");
}
}
});
}
return Pair.of(exprIds1, exprIds2);
}

View File

@ -38,7 +38,6 @@ import org.apache.doris.nereids.trees.plans.physical.PhysicalDistribute;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.SessionVariable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@ -67,10 +66,9 @@ public class JoinUtils {
* check if the row count of the left child in the broadcast join is less than a threshold value.
*/
public static boolean checkBroadcastJoinStats(PhysicalHashJoin<? extends Plan, ? extends Plan> join) {
SessionVariable sessionVariable = ConnectContext.get().getSessionVariable();
double memLimit = sessionVariable.getMaxExecMemByte();
double rowsLimit = sessionVariable.getBroadcastRowCountLimit();
double brMemlimit = sessionVariable.getBroadcastHashtableMemLimitPercentage();
double memLimit = ConnectContext.get().getSessionVariable().getMaxExecMemByte();
double rowsLimit = ConnectContext.get().getSessionVariable().getBroadcastRowCountLimit();
double brMemlimit = ConnectContext.get().getSessionVariable().getBroadcastHashtableMemLimitPercentage();
double datasize = join.getGroupExpression().get().child(1).getStatistics().computeSize();
double rowCount = join.getGroupExpression().get().child(1).getStatistics().getRowCount();
return rowCount <= rowsLimit && datasize <= memLimit * brMemlimit;
@ -116,12 +114,12 @@ public class JoinUtils {
* @return true if the equal can be used as hash join condition
*/
public boolean isHashJoinCondition(EqualTo equalTo) {
Set<Slot> equalLeft = equalTo.left().getInputSlots();
Set<Slot> equalLeft = equalTo.left().collect(Slot.class::isInstance);
if (equalLeft.isEmpty()) {
return false;
}
Set<Slot> equalRight = equalTo.right().getInputSlots();
Set<Slot> equalRight = equalTo.right().collect(Slot.class::isInstance);
if (equalRight.isEmpty()) {
return false;
}

View File

@ -55,7 +55,7 @@ public class PlanUtils {
* normalize comparison predicate on a binary plan to its two sides are corresponding to the child's output.
*/
public static ComparisonPredicate maybeCommuteComparisonPredicate(ComparisonPredicate expression, Plan left) {
Set<Slot> slots = expression.left().getInputSlots();
Set<Slot> slots = expression.left().collect(Slot.class::isInstance);
Set<Slot> leftSlots = left.getOutputSet();
Set<Slot> buffer = Sets.newHashSet(slots);
buffer.removeAll(leftSlots);

View File

@ -1253,7 +1253,8 @@ public class SessionVariable implements Serializable, Writable {
public boolean fasterFloatConvert = false;
@VariableMgr.VarAttr(name = IGNORE_RUNTIME_FILTER_IDS,
description = {"the runtime filter id in IGNORE_RUNTIME_FILTER_IDS list will not be generated"})
description = {"在IGNORE_RUNTIME_FILTER_IDS列表中的runtime filter将不会被生成",
"the runtime filter id in IGNORE_RUNTIME_FILTER_IDS list will not be generated"})
public String ignoreRuntimeFilterIds = "";
public static final String IGNORE_RUNTIME_FILTER_IDS = "ignore_runtime_filter_ids";

View File

@ -48,21 +48,21 @@ public class AddColumnsClauseTest {
columns.add(definition);
AddColumnsClause clause = new AddColumnsClause(columns, null, null);
clause.analyze(analyzer);
Assert.assertEquals("ADD COLUMN (`col1` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\", "
+ "`col2` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\")", clause.toString());
Assert.assertEquals("ADD COLUMN (`col1` INT NOT NULL DEFAULT \"0\" COMMENT \"\", "
+ "`col2` INT NOT NULL DEFAULT \"0\" COMMENT \"\")", clause.toString());
clause = new AddColumnsClause(columns, "", null);
clause.analyze(analyzer);
Assert.assertEquals("ADD COLUMN (`col1` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\", "
+ "`col2` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\")",
Assert.assertEquals("ADD COLUMN (`col1` INT NOT NULL DEFAULT \"0\" COMMENT \"\", "
+ "`col2` INT NOT NULL DEFAULT \"0\" COMMENT \"\")",
clause.toString());
Assert.assertNull(clause.getRollupName());
clause = new AddColumnsClause(columns, "testTable", null);
clause.analyze(analyzer);
Assert.assertEquals("ADD COLUMN (`col1` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\", "
+ "`col2` int(11) NOT NULL DEFAULT \"0\" COMMENT \"\") IN `testTable`",
Assert.assertEquals("ADD COLUMN (`col1` INT NOT NULL DEFAULT \"0\" COMMENT \"\", "
+ "`col2` INT NOT NULL DEFAULT \"0\" COMMENT \"\") IN `testTable`",
clause.toString());
Assert.assertNull(clause.getProperties());
Assert.assertEquals("testTable", clause.getRollupName());

View File

@ -61,7 +61,7 @@ public class ColumnDefTest {
ColumnDef column = new ColumnDef("col", intCol);
column.analyze(true);
Assert.assertEquals("`col` int(11) NOT NULL COMMENT \"\"", column.toString());
Assert.assertEquals("`col` INT NOT NULL COMMENT \"\"", column.toString());
Assert.assertEquals("col", column.getName());
Assert.assertEquals(PrimitiveType.INT, column.getType().getPrimitiveType());
Assert.assertNull(column.getAggregateType());
@ -72,14 +72,14 @@ public class ColumnDefTest {
column.analyze(true);
Assert.assertNull(column.getAggregateType());
Assert.assertEquals("10", column.getDefaultValue());
Assert.assertEquals("`col` int(11) NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql());
Assert.assertEquals("`col` INT NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql());
// agg
column = new ColumnDef("col", floatCol, false, AggregateType.SUM, false, new DefaultValue(true, "10"), "");
column.analyze(true);
Assert.assertEquals("10", column.getDefaultValue());
Assert.assertEquals(AggregateType.SUM, column.getAggregateType());
Assert.assertEquals("`col` float SUM NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql());
Assert.assertEquals("`col` FLOAT SUM NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql());
}
@Test
@ -89,14 +89,14 @@ public class ColumnDefTest {
ColumnDef column = new ColumnDef("col", intCol, false, AggregateType.REPLACE_IF_NOT_NULL, false, DefaultValue.NOT_SET, "");
column.analyze(true);
Assert.assertEquals(AggregateType.REPLACE_IF_NOT_NULL, column.getAggregateType());
Assert.assertEquals("`col` int(11) REPLACE_IF_NOT_NULL NULL DEFAULT \"null\" COMMENT \"\"", column.toSql());
Assert.assertEquals("`col` INT REPLACE_IF_NOT_NULL NULL DEFAULT \"null\" COMMENT \"\"", column.toSql());
} // CHECKSTYLE IGNORE THIS LINE
{ // CHECKSTYLE IGNORE THIS LINE
// not allow null
ColumnDef column = new ColumnDef("col", intCol, false, AggregateType.REPLACE_IF_NOT_NULL, false, new DefaultValue(true, "10"), "");
column.analyze(true);
Assert.assertEquals(AggregateType.REPLACE_IF_NOT_NULL, column.getAggregateType());
Assert.assertEquals("`col` int(11) REPLACE_IF_NOT_NULL NULL DEFAULT \"10\" COMMENT \"\"", column.toSql());
Assert.assertEquals("`col` INT REPLACE_IF_NOT_NULL NULL DEFAULT \"10\" COMMENT \"\"", column.toSql());
} // CHECKSTYLE IGNORE THIS LINE
}

View File

@ -83,7 +83,7 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
+ "as select * from `test`.`decimal_table`";
createTableAsSelect(selectFromDecimal);
Assertions.assertEquals("CREATE TABLE `select_decimal_table` (\n"
+ " `userId` varchar(255) NOT NULL,\n"
+ " `userId` VARCHAR(255) NOT NULL,\n"
+ " `amount_decimal` "
+ "DECIMAL" + "(10, 2) NOT NULL\n"
+ ") ENGINE=OLAP\n"
@ -160,8 +160,8 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableAsSelect(selectFromVarchar);
ShowResultSet showResultSet = showCreateTableByName("select_varchar");
Assertions.assertEquals("CREATE TABLE `select_varchar` (\n"
+ " `userId` varchar(255) NOT NULL,\n"
+ " `username` varchar(255) NOT NULL\n"
+ " `userId` VARCHAR(255) NOT NULL,\n"
+ " `username` VARCHAR(255) NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`userId`)\n"
+ "COMMENT 'OLAP'\n"
@ -186,7 +186,7 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
ShowResultSet showResultSet1 = showCreateTableByName("select_function_1");
Assertions.assertEquals(
"CREATE TABLE `select_function_1` (\n"
+ " `__count_0` bigint(20) NULL\n"
+ " `__count_0` BIGINT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`__count_0`)\n"
+ "COMMENT 'OLAP'\n"
@ -209,11 +209,11 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
ShowResultSet showResultSet2 = showCreateTableByName("select_function_2");
Assertions.assertEquals(
"CREATE TABLE `select_function_2` (\n"
+ " `__sum_0` bigint(20) NULL,\n"
+ " `__sum_1` bigint(20) NULL,\n"
+ " `__sum_2` bigint(20) NULL,\n"
+ " `__count_3` bigint(20) NULL,\n"
+ " `__count_4` bigint(20) NULL\n"
+ " `__sum_0` BIGINT NULL,\n"
+ " `__sum_1` BIGINT NULL,\n"
+ " `__sum_2` BIGINT NULL,\n"
+ " `__count_3` BIGINT NULL,\n"
+ " `__count_4` BIGINT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`__sum_0`, `__sum_1`, `__sum_2`)\n"
+ "COMMENT 'OLAP'\n"
@ -237,7 +237,7 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableAsSelect(selectAlias1);
ShowResultSet showResultSet1 = showCreateTableByName("select_alias_1");
Assertions.assertEquals("CREATE TABLE `select_alias_1` (\n"
+ " `amount` bigint(20) NULL\n"
+ " `amount` BIGINT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`amount`)\n"
+ "COMMENT 'OLAP'\n"
@ -256,8 +256,8 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableAsSelect(selectAlias2);
ShowResultSet showResultSet2 = showCreateTableByName("select_alias_2");
Assertions.assertEquals("CREATE TABLE `select_alias_2` (\n"
+ " `alias_name` varchar(255) NOT NULL,\n"
+ " `username` varchar(255) NOT NULL\n"
+ " `alias_name` VARCHAR(255) NOT NULL,\n"
+ " `username` VARCHAR(255) NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`alias_name`)\n"
+ "COMMENT 'OLAP'\n"
@ -282,9 +282,9 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableAsSelect(selectFromJoin);
ShowResultSet showResultSet = showCreateTableByName("select_join");
Assertions.assertEquals("CREATE TABLE `select_join` (\n"
+ " `userId` varchar(255) NOT NULL,\n"
+ " `username` varchar(255) NOT NULL,\n"
+ " `status` int(11) NOT NULL\n"
+ " `userId` VARCHAR(255) NOT NULL,\n"
+ " `username` VARCHAR(255) NOT NULL,\n"
+ " `status` INT NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`userId`)\n"
+ "COMMENT 'OLAP'\n"
@ -305,10 +305,10 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableAsSelect(selectFromJoin1);
ShowResultSet showResultSet1 = showCreateTableByName("select_join1");
Assertions.assertEquals("CREATE TABLE `select_join1` (\n"
+ " `userId1` varchar(255) NOT NULL,\n"
+ " `userId2` varchar(255) NOT NULL,\n"
+ " `username` varchar(255) NOT NULL,\n"
+ " `status` int(11) NOT NULL\n"
+ " `userId1` VARCHAR(255) NOT NULL,\n"
+ " `userId2` VARCHAR(255) NOT NULL,\n"
+ " `username` VARCHAR(255) NOT NULL,\n"
+ " `status` INT NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`userId1`)\n"
+ "COMMENT 'OLAP'\n"
@ -334,9 +334,9 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableAsSelect(selectFromName);
ShowResultSet showResultSet = showCreateTableByName("select_name");
Assertions.assertEquals("CREATE TABLE `select_name` (\n"
+ " `user` varchar(255) NOT NULL,\n"
+ " `testname` varchar(255) NOT NULL,\n"
+ " `userstatus` int(11) NOT NULL\n"
+ " `user` VARCHAR(255) NOT NULL,\n"
+ " `testname` VARCHAR(255) NOT NULL,\n"
+ " `userstatus` INT NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`user`)\n"
+ "COMMENT 'OLAP'\n"
@ -361,7 +361,7 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
ShowResultSet showResultSet = showCreateTableByName("select_union");
Assertions.assertEquals(
"CREATE TABLE `select_union` (\n"
+ " `userId` varchar(255) NULL\n"
+ " `userId` VARCHAR(255) NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`userId`)\n"
+ "COMMENT 'OLAP'\n"
@ -385,7 +385,7 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
ShowResultSet showResultSet = showCreateTableByName("select_cte");
Assertions.assertEquals(
"CREATE TABLE `select_cte` (\n"
+ " `userId` varchar(255) NOT NULL\n"
+ " `userId` VARCHAR(255) NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`userId`)\n"
+ "COMMENT 'OLAP'\n"
@ -405,7 +405,7 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableAsSelect(selectFromCteAndUnion);
ShowResultSet showResultSet1 = showCreateTableByName("select_cte_union");
Assertions.assertEquals("CREATE TABLE `select_cte_union` (\n"
+ " `id` tinyint(4) NULL\n"
+ " `id` TINYINT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`id`)\n"
+ "COMMENT 'OLAP'\n"
@ -429,8 +429,8 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableAsSelect(selectFromPartition);
ShowResultSet showResultSet = showCreateTableByName("selectPartition");
Assertions.assertEquals("CREATE TABLE `selectPartition` (\n"
+ " `userId` varchar(255) NOT NULL,\n"
+ " `username` varchar(255) NOT NULL\n"
+ " `userId` VARCHAR(255) NOT NULL,\n"
+ " `username` VARCHAR(255) NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`userId`)\n"
+ "COMMENT 'OLAP'\n"
@ -456,8 +456,8 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableAsSelect(createSql);
ShowResultSet showResultSet = showCreateTableByName("test_default_timestamp");
Assertions.assertEquals("CREATE TABLE `test_default_timestamp` (\n"
+ " `userId` varchar(255) NOT NULL,\n"
+ " `date` datetime"
+ " `userId` VARCHAR(255) NOT NULL,\n"
+ " `date` DATETIME"
+ " NULL DEFAULT CURRENT_TIMESTAMP\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`userId`)\n"
@ -483,7 +483,7 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
ShowResultSet showResultSet = showCreateTableByName("test_agg_value");
Assertions.assertEquals(
"CREATE TABLE `test_agg_value` (\n"
+ " `username` varchar(255) NOT NULL\n"
+ " `username` VARCHAR(255) NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`username`)\n"
+ "COMMENT 'OLAP'\n"
@ -508,8 +508,8 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
ShowResultSet showResultSet = showCreateTableByName("test_use_key_type");
Assertions.assertEquals(
"CREATE TABLE `test_use_key_type` (\n"
+ " `userId` varchar(255) NOT NULL,\n"
+ " `username` varchar(255) NOT NULL\n"
+ " `userId` VARCHAR(255) NOT NULL,\n"
+ " `username` VARCHAR(255) NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "UNIQUE KEY(`userId`)\n"
+ "COMMENT 'OLAP'\n"
@ -558,8 +558,8 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createStmts.add(createTableStmts.get(0));
if (tbl.getName().equals("qs1")) {
Assert.assertEquals("CREATE TABLE `qs1` (\n"
+ " `k1` int(11) NULL,\n"
+ " `k2` int(11) NULL\n"
+ " `k1` INT NULL,\n"
+ " `k2` INT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`k1`, `k2`)\n"
+ "COMMENT 'OLAP'\n"
@ -576,8 +576,8 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
createTableStmts.get(0));
} else {
Assert.assertEquals("CREATE TABLE `qs2` (\n"
+ " `k1` int(11) NULL,\n"
+ " `k2` int(11) NULL\n"
+ " `k1` INT NULL,\n"
+ " `k2` INT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`k1`, `k2`)\n"
+ "COMMENT 'OLAP'\n"
@ -607,9 +607,9 @@ public class CreateTableAsSelectStmtTest extends TestWithFeService {
String showStr = showResultSet.getResultRows().get(0).get(1);
Assertions.assertEquals(
"CREATE TABLE `varchar_len1` (\n"
+ " `__literal_0` varchar(*) NULL,\n"
+ " `__concat_1` varchar(*) NULL,\n"
+ " `userId` varchar(255) NOT NULL\n"
+ " `__literal_0` VARCHAR(*) NULL,\n"
+ " `__concat_1` VARCHAR(*) NULL,\n"
+ " `userId` VARCHAR(255) NOT NULL\n"
+ ") ENGINE=OLAP\n"
+ "DUPLICATE KEY(`__literal_0`)\n"
+ "COMMENT 'OLAP'\n"

View File

@ -337,7 +337,7 @@ public class CreateTableStmtTest {
null, null, "");
expectedEx.expect(AnalysisException.class);
expectedEx.expectMessage(
"Aggregate type `col3` hll NONE NOT NULL COMMENT \"\" is not compatible with primitive type hll");
"Aggregate type `col3` HLL NONE NOT NULL COMMENT \"\" is not compatible with primitive type HLL");
stmt.analyze(analyzer);
}
@ -419,8 +419,8 @@ public class CreateTableStmtTest {
stmt.analyze(analyzer);
Assert.assertEquals(
"CREATE EXTERNAL TABLE `testCluster:db1`.`table1` (\n" + " `id` int(11) NOT NULL COMMENT \"\",\n"
+ " `name` int(11) NULL COMMENT \"\"\n" + ") ENGINE = hudi\n"
"CREATE EXTERNAL TABLE `testCluster:db1`.`table1` (\n" + " `id` INT NOT NULL COMMENT \"\",\n"
+ " `name` INT NULL COMMENT \"\"\n" + ") ENGINE = hudi\n"
+ "PROPERTIES (\"hudi.database\" = \"doris\",\n"
+ "\"hudi.hive.metastore.uris\" = \"thrift://127.0.0.1:9087\",\n"
+ "\"hudi.table\" = \"test\")", stmt.toString());
@ -455,8 +455,8 @@ public class CreateTableStmtTest {
properties, null, "", null);
String createTableSql = "CREATE TABLE IF NOT EXISTS `demo`.`testTosql1` (\n"
+ " `a` bigint(20) NOT NULL COMMENT \"\",\n"
+ " `b` int(11) NOT NULL COMMENT \"\"\n"
+ " `a` BIGINT NOT NULL COMMENT \"\",\n"
+ " `b` INT NOT NULL COMMENT \"\"\n"
+ ") ENGINE = olap\n"
+ "AGGREGATE KEY(`a`)\n"
+ "PROPERTIES (\"replication_num\" = \"1\")";
@ -484,14 +484,14 @@ public class CreateTableStmtTest {
tableName, columnDefs, engineName, keysDesc, null, null,
properties, null, "", null);
createTableSql = "CREATE TABLE `demo`.`testTosql2` (\n"
+ " `a` bigint(20) NOT NULL COMMENT \"\",\n"
+ " `b` int(11) NOT NULL COMMENT \"\",\n"
+ " `c` text NULL COMMENT \"\",\n"
+ " `d` double NULL COMMENT \"\",\n"
+ " `e` decimalv3(38, 0) NOT NULL COMMENT \"\",\n"
+ " `f` date NOT NULL COMMENT \"\",\n"
+ " `g` smallint(6) NOT NULL COMMENT \"\",\n"
+ " `h` boolean NOT NULL COMMENT \"\"\n"
+ " `a` BIGINT NOT NULL COMMENT \"\",\n"
+ " `b` INT NOT NULL COMMENT \"\",\n"
+ " `c` TEXT NULL COMMENT \"\",\n"
+ " `d` DOUBLE NULL COMMENT \"\",\n"
+ " `e` DECIMALV3(38, 0) NOT NULL COMMENT \"\",\n"
+ " `f` DATE NOT NULL COMMENT \"\",\n"
+ " `g` SMALLINT NOT NULL COMMENT \"\",\n"
+ " `h` BOOLEAN NOT NULL COMMENT \"\"\n"
+ ") ENGINE = olap\n"
+ "DUPLICATE KEY(`a`, `d`, `f`)\n"
+ "PROPERTIES (\"replication_num\" = \"10\")";

View File

@ -48,7 +48,7 @@ public class ShowCreateTableStmtTest extends TestWithFeService {
String sql = "show create table table1";
ShowResultSet showResultSet = showCreateTable(sql);
String showSql = showResultSet.getResultRows().get(0).get(1);
Assertions.assertTrue(showSql.contains("`k1` int(11) NULL COMMENT 'test column k1'"));
Assertions.assertTrue(showSql.contains("`k1` INT NULL COMMENT 'test column k1'"));
Assertions.assertTrue(showSql.contains("COMMENT 'test table1'"));
}

View File

@ -48,7 +48,7 @@ public class ColumnTypeTest {
type.analyze(null);
Assert.assertEquals(PrimitiveType.INT, type.getType().getPrimitiveType());
Assert.assertEquals("int(11)", type.toSql());
Assert.assertEquals("INT", type.toSql());
// equal type
TypeDef type2 = TypeDef.create(PrimitiveType.INT);
@ -69,9 +69,9 @@ public class ColumnTypeTest {
public void testCharType() throws AnalysisException {
TypeDef type = TypeDef.createVarchar(10);
type.analyze(null);
Assert.assertEquals("varchar(10)", type.toString());
Assert.assertEquals("VARCHAR(10)", type.toString());
Assert.assertEquals(PrimitiveType.VARCHAR, type.getType().getPrimitiveType());
Assert.assertEquals(10, ((ScalarType) type.getType()).getLength());
Assert.assertEquals(10, type.getType().getLength());
// equal type
TypeDef type2 = TypeDef.createVarchar(10);
@ -91,10 +91,10 @@ public class ColumnTypeTest {
TypeDef type = TypeDef.createDecimal(12, 5);
type.analyze(null);
if (Config.enable_decimal_conversion) {
Assert.assertEquals("decimalv3(12, 5)", type.toString());
Assert.assertEquals("DECIMALV3(12, 5)", type.toString());
Assert.assertEquals(PrimitiveType.DECIMAL64, type.getType().getPrimitiveType());
} else {
Assert.assertEquals("decimal(12, 5)", type.toString());
Assert.assertEquals("DECIMAL(12, 5)", type.toString());
Assert.assertEquals(PrimitiveType.DECIMALV2, type.getType().getPrimitiveType());
}
Assert.assertEquals(12, ((ScalarType) type.getType()).getScalarPrecision());
@ -119,7 +119,7 @@ public class ColumnTypeTest {
public void testDatetimeV2() throws AnalysisException {
TypeDef type = TypeDef.createDatetimeV2(3);
type.analyze(null);
Assert.assertEquals("datetimev2(3)", type.toString());
Assert.assertEquals("DATETIMEV2(3)", type.toString());
Assert.assertEquals(PrimitiveType.DATETIMEV2, type.getType().getPrimitiveType());
Assert.assertEquals(ScalarType.DATETIME_PRECISION, ((ScalarType) type.getType()).getScalarPrecision());
Assert.assertEquals(3, ((ScalarType) type.getType()).getScalarScale());
@ -160,7 +160,7 @@ public class ColumnTypeTest {
public void testTimeV2() throws AnalysisException {
TypeDef type = TypeDef.createTimeV2(3);
type.analyze(null);
Assert.assertEquals("time(3)", type.toString());
Assert.assertEquals("TIME(3)", type.toString());
Assert.assertEquals(PrimitiveType.TIMEV2, type.getType().getPrimitiveType());
Assert.assertEquals(ScalarType.DATETIME_PRECISION, ((ScalarType) type.getType()).getScalarPrecision());
Assert.assertEquals(3, ((ScalarType) type.getType()).getScalarScale());

View File

@ -227,25 +227,25 @@ public class EsUtilTest extends EsTestCase {
String name = column.getName();
String type = column.getType().toSql();
if ("test2".equals(name)) {
Assertions.assertEquals("datetimev2(0)", type);
Assertions.assertEquals("DATETIMEV2(0)", type);
}
if ("test3".equals(name)) {
Assertions.assertEquals("datetimev2(0)", type);
Assertions.assertEquals("DATETIMEV2(0)", type);
}
if ("test4".equals(name)) {
Assertions.assertEquals("datev2", type);
Assertions.assertEquals("DATEV2", type);
}
if ("test5".equals(name)) {
Assertions.assertEquals("datetimev2(0)", type);
Assertions.assertEquals("DATETIMEV2(0)", type);
}
if ("test6".equals(name)) {
Assertions.assertEquals("datev2", type);
Assertions.assertEquals("DATEV2", type);
}
if ("test7".equals(name)) {
Assertions.assertEquals("datetimev2(0)", type);
Assertions.assertEquals("DATETIMEV2(0)", type);
}
if ("test8".equals(name)) {
Assertions.assertEquals("bigint(20)", type);
Assertions.assertEquals("BIGINT", type);
}
}
}
@ -255,8 +255,8 @@ public class EsUtilTest extends EsTestCase {
ObjectNode testFieldAlias = EsUtil.getRootSchema(
EsUtil.getMapping(loadJsonFromFile("data/es/test_field_alias.json")), null, new ArrayList<>());
List<Column> parseColumns = EsUtil.genColumnsFromEs("test_field_alias", null, testFieldAlias, true, new ArrayList<>());
Assertions.assertEquals("datetimev2(0)", parseColumns.get(2).getType().toSql());
Assertions.assertEquals("text", parseColumns.get(4).getType().toSql());
Assertions.assertEquals("DATETIMEV2(0)", parseColumns.get(2).getType().toSql());
Assertions.assertEquals("TEXT", parseColumns.get(4).getType().toSql());
}
@Test

View File

@ -34,6 +34,7 @@ public class TokenManagerTest {
@Test
public void testTokenCheck() throws UserException {
TokenManager tokenManager = new TokenManager();
tokenManager.start();
String token = tokenManager.acquireToken();
Assert.assertTrue(tokenManager.checkAuthToken(token));
}
@ -41,6 +42,7 @@ public class TokenManagerTest {
@Test
public void testSameToken() throws UserException {
TokenManager tokenManager = new TokenManager();
tokenManager.start();
String token1 = tokenManager.acquireToken();
String token2 = tokenManager.acquireToken();
Assert.assertNotNull(token1);

View File

@ -573,11 +573,11 @@ public class QueryPlanTest extends TestWithFeService {
// disable implicit cast hll/bitmap to string
assertSQLPlanOrErrorMsgContains(
"select length(id2) from test.hll_table;",
"No matching function with signature: length(hll)"
"No matching function with signature: length(HLL)"
);
assertSQLPlanOrErrorMsgContains(
"select length(id2) from test.bitmap_table;",
"No matching function with signature: length(bitmap)"
"No matching function with signature: length(BITMAP)"
);
}

View File

@ -79,7 +79,7 @@ public class TableFunctionPlanTest {
explainString.contains("table function: explode_split(`default_cluster:db1`.`tbl1`.`k2`, ',')"));
Assert.assertTrue(explainString.contains("tuple ids: 0 1"));
Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR"));
}
/* Case2 without output explode column
@ -95,7 +95,7 @@ public class TableFunctionPlanTest {
explainString.contains("table function: explode_split(`default_cluster:db1`.`tbl1`.`k2`, ',')"));
Assert.assertTrue(explainString.contains("tuple ids: 0 1"));
Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR"));
}
/* Case3 group by explode column
@ -116,7 +116,7 @@ public class TableFunctionPlanTest {
explainString.contains("table function: explode_split(`default_cluster:db1`.`tbl1`.`k2`, ',')"));
Assert.assertTrue(explainString.contains("tuple ids: 0 1"));
Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR"));
// group by tuple
Assert.assertTrue(explainString.contains("TupleDescriptor{id=2, tbl=null, byteSize=32}"));
}
@ -135,7 +135,7 @@ public class TableFunctionPlanTest {
Assert.assertTrue(explainString.contains("PREDICATES: `e1` = '1'"));
Assert.assertTrue(explainString.contains("tuple ids: 0 1"));
Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR"));
}
/* Case5 where normal column
@ -151,7 +151,7 @@ public class TableFunctionPlanTest {
explainString.contains("table function: explode_split(`default_cluster:db1`.`tbl1`.`k2`, ',')"));
Assert.assertTrue(explainString.contains("tuple ids: 0 1"));
Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp, byteSize=32}"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=varchar"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e1, colUniqueId=-1, type=VARCHAR"));
Assert.assertTrue(UtFrameUtils.checkPlanResultContainsNode(explainString, 0, "OlapScanNode"));
Assert.assertTrue(explainString.contains("PREDICATES: `k1` = 1"));
}
@ -171,10 +171,10 @@ public class TableFunctionPlanTest {
Assert.assertTrue(explainString.contains("lateral view tuple id: 1 2"));
// lateral view 2 tuple
Assert.assertTrue(explainString.contains("TupleDescriptor{id=1, tbl=tmp2, byteSize=32}"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e2, colUniqueId=-1, type=varchar"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=e2, colUniqueId=-1, type=VARCHAR"));
// lateral view 1 tuple
Assert.assertTrue(explainString.contains("TupleDescriptor{id=2, tbl=tmp1, byteSize=32}"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=2, col=e1, colUniqueId=-1, type=varchar"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=2, col=e1, colUniqueId=-1, type=VARCHAR"));
}
// test explode_split function
@ -188,11 +188,11 @@ public class TableFunctionPlanTest {
public void errorParam() throws Exception {
String sql = "explain select /*+ SET_VAR(enable_nereids_planner=false) */ k1, e1 from db1.tbl1 lateral view explode_split(k2) tmp as e1;";
String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql);
Assert.assertTrue(explainString.contains("No matching function with signature: explode_split(varchar(1))"));
Assert.assertTrue(explainString.contains("No matching function with signature: explode_split(VARCHAR(1))"));
sql = "explain select /*+ SET_VAR(enable_nereids_planner=false) */ k1, e1 from db1.tbl1 lateral view explode_split(k1) tmp as e1;";
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql);
Assert.assertTrue(explainString.contains("No matching function with signature: explode_split(int(11))"));
Assert.assertTrue(explainString.contains("No matching function with signature: explode_split(INT)"));
}
/* Case2 table function in where stmt
@ -203,7 +203,7 @@ public class TableFunctionPlanTest {
String sql = "explain select /*+ SET_VAR(enable_nereids_planner=false) */ k1 from db1.tbl1 where explode_split(k2, \",\");";
String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(ctx, sql);
Assert.assertTrue(explainString,
explainString.contains("No matching function with signature: explode_split(varchar(1), varchar(*))."));
explainString.contains("No matching function with signature: explode_split(VARCHAR(1), VARCHAR(*))."));
}
// test projection
@ -350,8 +350,8 @@ public class TableFunctionPlanTest {
explainString.contains("table function: explode_split(concat(`a`.`k2`, ',', `a`.`k3`), ',')"));
Assert.assertTrue(explainString.contains("lateral view tuple id: 1"));
Assert.assertTrue(explainString.contains("output slot id: 3"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=0, col=k2, colUniqueId=1, type=varchar(1)"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=k3, colUniqueId=2, type=varchar(1)"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=0, col=k2, colUniqueId=1, type=VARCHAR(1)"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=1, col=k3, colUniqueId=2, type=VARCHAR(1)"));
}
// lateral view of subquery
@ -368,7 +368,7 @@ public class TableFunctionPlanTest {
Assert.assertTrue(explainString.contains("lateral view tuple id: 2"));
Assert.assertTrue(explainString.contains("output slot id: 2"));
Assert.assertTrue(explainString.contains("tuple ids: 0 2"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=2, col=e1, colUniqueId=-1, type=varchar"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=2, col=e1, colUniqueId=-1, type=VARCHAR"));
}
/*
@ -384,7 +384,7 @@ public class TableFunctionPlanTest {
Assert.assertTrue(explainString.contains("lateral view tuple id: 3"));
Assert.assertTrue(explainString.contains("output slot id: 3"));
Assert.assertTrue(explainString.contains("tuple ids: 1 3"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=3, col=e1, colUniqueId=-1, type=varchar"));
Assert.assertTrue(explainString.contains("SlotDescriptor{id=3, col=e1, colUniqueId=-1, type=VARCHAR"));
}
/*
@ -403,19 +403,19 @@ public class TableFunctionPlanTest {
Assert.assertTrue(explainString.contains("tuple ids: 1 3"));
String formatString = explainString.replaceAll(" ", "");
Assert.assertTrue(formatString.contains(
"SlotDescriptor{id=0,col=k1,colUniqueId=0,type=int"
"SlotDescriptor{id=0,col=k1,colUniqueId=0,type=INT"
));
Assert.assertTrue(formatString.contains(
"SlotDescriptor{id=1,col=k2,colUniqueId=1,type=varchar(1)"
"SlotDescriptor{id=1,col=k2,colUniqueId=1,type=VARCHAR(1)"
));
Assert.assertTrue(formatString.contains(
"SlotDescriptor{id=2,col=k1,colUniqueId=0,type=int"
"SlotDescriptor{id=2,col=k1,colUniqueId=0,type=INT"
));
Assert.assertTrue(formatString.contains(
"SlotDescriptor{id=3,col=null,colUniqueId=null,type=varchar"
"SlotDescriptor{id=3,col=null,colUniqueId=null,type=VARCHAR"
));
Assert.assertTrue(formatString.contains(
"SlotDescriptor{id=6,col=e1,colUniqueId=-1,type=varchar"
"SlotDescriptor{id=6,col=e1,colUniqueId=-1,type=VARCHAR"
));
}