[fe-package]reject illegal import (#11311)

This commit is contained in:
morrySnow
2022-07-29 14:22:23 +08:00
committed by GitHub
parent 6c2337483b
commit 642499265c
20 changed files with 209 additions and 183 deletions

View File

@ -164,6 +164,9 @@ under the License.
<property name="customImportOrderRules" value="SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
<property name="tokens" value="IMPORT, STATIC_IMPORT, PACKAGE_DEF"/>
</module>
<module name="ImportControl">
<property name="file" value="check/checkstyle/import-control.xml"/>
</module>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="EmptyStatement"/>

View File

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE import-control PUBLIC
"-//Checkstyle//DTD ImportControl Configuration 1.4//EN"
"https://checkstyle.org/dtds/import_control_1_4.dtd">
<import-control pkg="org.apache.doris" strategyOnMismatch="allowed">
<disallow pkg="com.clearspring.analytics.util" />
<subpackage name="nereids">
<allow pkg="org.junit.jupiter"/>
<disallow pkg="org.junit"/>
</subpackage>
</import-control>

View File

@ -22,7 +22,7 @@ import org.apache.doris.catalog.TableIf;
import org.apache.doris.datasource.ExternalDataSource;
import org.apache.doris.datasource.HMSExternalDataSource;
import com.clearspring.analytics.util.Lists;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.logging.log4j.LogManager;
@ -41,8 +41,8 @@ public class HMSExternalDatabase extends ExternalDatabase<HMSExternalTable> {
private static final Logger LOG = LogManager.getLogger(HMSExternalDatabase.class);
// Cache of table name to table id.
private Map<String, Long> tableNameToId = Maps.newConcurrentMap();
private Map<Long, HMSExternalTable> idToTbl = Maps.newHashMap();
private final Map<String, Long> tableNameToId = Maps.newConcurrentMap();
private final Map<Long, HMSExternalTable> idToTbl = Maps.newHashMap();
private boolean initialized = false;
/**

View File

@ -22,10 +22,10 @@ import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.util.ListComparator;
import org.apache.doris.datasource.DataSourceIf;
import com.clearspring.analytics.util.Lists;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Collections;

View File

@ -21,7 +21,7 @@ import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.expressions.SlotReference;
import com.clearspring.analytics.util.Lists;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.Collection;

View File

@ -44,11 +44,10 @@ import org.apache.doris.statistics.TableStats;
import com.google.common.base.Supplier;
import mockit.Expectations;
import mockit.Mocked;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@ -76,8 +75,8 @@ public class DeriveStatsJobTest {
plannerContext.getJobPool().pop().execute();
}
StatsDeriveResult statistics = memo.getRoot().getStatistics();
Assert.assertNotNull(statistics);
Assert.assertEquals(10, statistics.getRowCount());
Assertions.assertNotNull(statistics);
Assertions.assertEquals(10, statistics.getRowCount());
}
private LogicalOlapScan constructOlapSCan() {
@ -106,14 +105,13 @@ public class DeriveStatsJobTest {
}};
Table table1 = new Table(tableId1, tableName1, TableType.OLAP, Collections.emptyList());
LogicalOlapScan logicalOlapScan1 = new LogicalOlapScan(table1, Collections.emptyList()).withLogicalProperties(
return new LogicalOlapScan(table1, Collections.emptyList()).withLogicalProperties(
Optional.of(new LogicalProperties(new Supplier<List<Slot>>() {
@Override
public List<Slot> get() {
return Arrays.asList(slot1);
return Collections.singletonList(slot1);
}
})));
return logicalOlapScan1;
}
private LogicalAggregate constructAgg(Plan child) {
@ -121,7 +119,6 @@ public class DeriveStatsJobTest {
groupByExprList.add(slot1);
AggregateFunction sum = new Sum(slot1);
Alias alias = new Alias(sum, "a");
LogicalAggregate logicalAggregate = new LogicalAggregate(groupByExprList, Arrays.asList(alias), child);
return logicalAggregate;
return new LogicalAggregate<>(groupByExprList, Collections.singletonList(alias), child);
}
}

View File

@ -26,8 +26,8 @@ import org.apache.doris.nereids.types.StringType;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class MemoTest {
@Test
@ -47,13 +47,13 @@ public class MemoTest {
Group rootGroup = memo.getRoot();
Assert.assertEquals(3, memo.getGroups().size());
Assert.assertEquals(3, memo.getGroupExpressions().size());
Assertions.assertEquals(3, memo.getGroups().size());
Assertions.assertEquals(3, memo.getGroupExpressions().size());
Assert.assertEquals(PlanType.LOGICAL_PROJECT, rootGroup.logicalExpressionsAt(0).getPlan().getType());
Assert.assertEquals(PlanType.LOGICAL_PROJECT,
Assertions.assertEquals(PlanType.LOGICAL_PROJECT, rootGroup.logicalExpressionsAt(0).getPlan().getType());
Assertions.assertEquals(PlanType.LOGICAL_PROJECT,
rootGroup.logicalExpressionsAt(0).child(0).logicalExpressionsAt(0).getPlan().getType());
Assert.assertEquals(PlanType.LOGICAL_UNBOUND_RELATION,
Assertions.assertEquals(PlanType.LOGICAL_UNBOUND_RELATION,
rootGroup.logicalExpressionsAt(0).child(0).logicalExpressionsAt(0).child(0).logicalExpressionsAt(0)
.getPlan().getType());
}
@ -85,7 +85,7 @@ public class MemoTest {
relation2
);
memo.copyIn(project2, null, false);
Assert.assertEquals(4, memo.getGroups().size());
Assertions.assertEquals(4, memo.getGroups().size());
LogicalProject project3 = new LogicalProject(
ImmutableList.of(new SlotReference(new ExprId(1), "other", StringType.INSTANCE, true, ImmutableList.of("other"))),
@ -98,24 +98,22 @@ public class MemoTest {
memo.copyIn(relation1, memo.getGroups().get(2), true);
Assert.assertEquals(3, memo.getGroups().size());
Assertions.assertEquals(3, memo.getGroups().size());
Group root = memo.getRoot();
Assert.assertEquals(1, root.getLogicalExpressions().size());
Assert.assertEquals(PlanType.LOGICAL_PROJECT,
root.logicalExpressionsAt(0).getPlan().getType());
Assertions.assertEquals(1, root.getLogicalExpressions().size());
Assertions.assertEquals(PlanType.LOGICAL_PROJECT, root.logicalExpressionsAt(0).getPlan().getType());
GroupExpression rootExpression = root.logicalExpressionsAt(0);
Assert.assertEquals(1, rootExpression.children().size());
Assertions.assertEquals(1, rootExpression.children().size());
//two expressions: relationA and relationB
Assert.assertEquals(2, rootExpression.child(0).getLogicalExpressions().size());
Assertions.assertEquals(2, rootExpression.child(0).getLogicalExpressions().size());
GroupExpression childExpression = rootExpression.child(0).logicalExpressionsAt(0);
Assert.assertEquals(PlanType.LOGICAL_UNBOUND_RELATION,
childExpression.getPlan().getType());
Assertions.assertEquals(PlanType.LOGICAL_UNBOUND_RELATION, childExpression.getPlan().getType());
Group groupProjct3 = memo.getGroups().get(2); //group for project3
Group groupRelation = memo.getGroups().get(0); //group for relation
//group0 is child of group4
Assert.assertEquals(groupRelation, groupProjct3.logicalExpressionsAt(0).child(0));
Assert.assertEquals(1, groupProjct3.getLogicalExpressions().size());
Assert.assertEquals(1, groupProjct3.logicalExpressionsAt(0).children().size());
Assertions.assertEquals(groupRelation, groupProjct3.logicalExpressionsAt(0).child(0));
Assertions.assertEquals(1, groupProjct3.getLogicalExpressions().size());
Assertions.assertEquals(1, groupProjct3.logicalExpressionsAt(0).children().size());
}
}

View File

@ -35,8 +35,8 @@ import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.StringType;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Optional;
@ -92,23 +92,25 @@ public class TestPlanOutput {
Assertions.assertEquals(output.get(0).getDataType(), IntegerType.INSTANCE);
}
@Test(expected = NullPointerException.class)
@Test
public void testPhysicalPlanMustHaveLogicalProperties() {
new PhysicalRelation(PlanType.PHYSICAL_OLAP_SCAN, ImmutableList.of("tbl"), Optional.empty(), null) {
@Override
public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
return null;
}
Assertions.assertThrows(NullPointerException.class, () ->
new PhysicalRelation(PlanType.PHYSICAL_OLAP_SCAN, ImmutableList.of("tbl"), Optional.empty(), null) {
@Override
public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
return null;
}
@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return null;
}
@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return null;
}
@Override
public Table getTable() {
return null;
}
};
@Override
public Table getTable() {
return null;
}
}
);
}
}

View File

@ -34,8 +34,8 @@ import org.apache.doris.nereids.types.BigIntType;
import com.google.common.collect.ImmutableList;
import mockit.Mocked;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Optional;
@ -60,11 +60,11 @@ public class JoinCommuteTest {
Rule rule = new JoinCommute(true).build();
List<Plan> transform = rule.transform(join, plannerContext);
Assert.assertEquals(1, transform.size());
Assertions.assertEquals(1, transform.size());
Plan newJoin = transform.get(0);
Assert.assertEquals(join.child(0), newJoin.child(1));
Assert.assertEquals(join.child(1), newJoin.child(0));
Assertions.assertEquals(join.child(0), newJoin.child(1));
Assertions.assertEquals(join.child(1), newJoin.child(0));
}
}

View File

@ -35,9 +35,9 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import mockit.Mocked;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Optional;
@ -48,7 +48,7 @@ public class JoinLAsscomTest {
private static List<LogicalOlapScan> scans = Lists.newArrayList();
private static List<List<SlotReference>> outputs = Lists.newArrayList();
@BeforeClass
@BeforeAll
public static void init() {
Table t1 = new Table(0L, "t1", Table.TableType.OLAP,
ImmutableList.of(new Column("id", Type.INT, true, AggregateType.NONE, "0", ""),
@ -88,7 +88,7 @@ public class JoinLAsscomTest {
* / \ / \
* A B A C
*/
Assert.assertEquals(3, scans.size());
Assertions.assertEquals(3, scans.size());
LogicalJoin<LogicalOlapScan, LogicalOlapScan> bottomJoin = new LogicalJoin<>(JoinType.INNER_JOIN,
Optional.of(bottomJoinOnCondition), scans.get(0), scans.get(1));
LogicalJoin<LogicalJoin<LogicalOlapScan, LogicalOlapScan>, LogicalOlapScan> topJoin = new LogicalJoin<>(
@ -96,8 +96,8 @@ public class JoinLAsscomTest {
Rule rule = new JoinLAsscom().build();
List<Plan> transform = rule.transform(topJoin, plannerContext);
Assert.assertEquals(1, transform.size());
Assert.assertTrue(transform.get(0) instanceof LogicalJoin);
Assertions.assertEquals(1, transform.size());
Assertions.assertTrue(transform.get(0) instanceof LogicalJoin);
LogicalJoin newTopJoin = (LogicalJoin) transform.get(0);
return new Pair<>(topJoin, newTopJoin);
}
@ -131,10 +131,12 @@ public class JoinLAsscomTest {
LogicalJoin newTopJoin = pair.second;
// Join reorder successfully.
Assert.assertNotEquals(oldJoin, newTopJoin);
Assert.assertEquals("t1", ((LogicalOlapScan) ((LogicalJoin) newTopJoin.left()).left()).getTable().getName());
Assert.assertEquals("t3", ((LogicalOlapScan) ((LogicalJoin) newTopJoin.left()).right()).getTable().getName());
Assert.assertEquals("t2", ((LogicalOlapScan) newTopJoin.right()).getTable().getName());
Assertions.assertNotEquals(oldJoin, newTopJoin);
Assertions.assertEquals("t1",
((LogicalOlapScan) ((LogicalJoin) newTopJoin.left()).left()).getTable().getName());
Assertions.assertEquals("t3",
((LogicalOlapScan) ((LogicalJoin) newTopJoin.left()).right()).getTable().getName());
Assertions.assertEquals("t2", ((LogicalOlapScan) newTopJoin.right()).getTable().getName());
}
@Test
@ -171,6 +173,6 @@ public class JoinLAsscomTest {
// |
// t3
// then, we can LAsscom for this star-join.
Assert.assertEquals(oldJoin, newTopJoin);
Assertions.assertEquals(oldJoin, newTopJoin);
}
}

View File

@ -38,9 +38,9 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import mockit.Mocked;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Optional;
@ -51,7 +51,7 @@ public class JoinProjectLAsscomTest {
private static List<LogicalOlapScan> scans = Lists.newArrayList();
private static List<List<SlotReference>> outputs = Lists.newArrayList();
@BeforeClass
@BeforeAll
public static void init() {
Table t1 = new Table(0L, "t1", Table.TableType.OLAP,
ImmutableList.of(new Column("id", Type.INT, true, AggregateType.NONE, "0", ""),
@ -94,7 +94,7 @@ public class JoinProjectLAsscomTest {
* A B A C
*/
Assert.assertEquals(3, scans.size());
Assertions.assertEquals(3, scans.size());
List<SlotReference> t1 = outputs.get(0);
List<SlotReference> t2 = outputs.get(1);
@ -111,8 +111,8 @@ public class JoinProjectLAsscomTest {
Rule rule = new JoinProjectLAsscom().build();
List<Plan> transform = rule.transform(topJoin, plannerContext);
Assert.assertEquals(1, transform.size());
Assert.assertTrue(transform.get(0) instanceof LogicalJoin);
Assertions.assertEquals(1, transform.size());
Assertions.assertTrue(transform.get(0) instanceof LogicalJoin);
LogicalJoin newTopJoin = (LogicalJoin) transform.get(0);
return new Pair<>(topJoin, newTopJoin);
}
@ -134,14 +134,13 @@ public class JoinProjectLAsscomTest {
LogicalJoin newTopJoin = pair.second;
// Join reorder successfully.
Assert.assertNotEquals(oldJoin, newTopJoin);
Assert.assertEquals("t1.id",
((Alias) ((LogicalProject) newTopJoin.left()).getProjects().get(0)).getName());
Assert.assertEquals("name",
Assertions.assertNotEquals(oldJoin, newTopJoin);
Assertions.assertEquals("t1.id", ((Alias) ((LogicalProject) newTopJoin.left()).getProjects().get(0)).getName());
Assertions.assertEquals("name",
((SlotReference) ((LogicalProject) newTopJoin.left()).getProjects().get(1)).getName());
Assert.assertEquals("t2.id",
Assertions.assertEquals("t2.id",
((Alias) ((LogicalProject) newTopJoin.right()).getProjects().get(0)).getName());
Assert.assertEquals("name",
Assertions.assertEquals("name",
((SlotReference) ((LogicalProject) newTopJoin.left()).getProjects().get(1)).getName());
}

View File

@ -26,8 +26,8 @@ import org.apache.doris.nereids.rules.expression.rewrite.rules.SimplifyNotExprRu
import org.apache.doris.nereids.trees.expressions.Expression;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* all expr rewrite rule test case.

View File

@ -27,8 +27,8 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
import com.google.common.collect.Lists;
import mockit.Mocked;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.List;
@ -38,8 +38,8 @@ public class LogicalProjectToPhysicalProjectTest {
Plan plan = new LogicalProject(Lists.newArrayList(), new GroupPlan(group));
Rule rule = new LogicalProjectToPhysicalProject().build();
List<Plan> transform = rule.transform(plan, plannerContext);
Assert.assertEquals(1, transform.size());
Assertions.assertEquals(1, transform.size());
Plan implPlan = transform.get(0);
Assert.assertEquals(PlanType.PHYSICAL_PROJECT, implPlan.getType());
Assertions.assertEquals(PlanType.PHYSICAL_PROJECT, implPlan.getType());
}
}

View File

@ -18,7 +18,6 @@
package org.apache.doris.nereids.rules.rewrite.logical;
import org.apache.doris.catalog.AggregateType;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.Table;
@ -46,8 +45,8 @@ import org.apache.doris.qe.ConnectContext;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.List;
@ -101,19 +100,19 @@ public class PushDownPredicateThroughAggregationTest {
.getLogicalExpression().child(0)
.getLogicalExpression();
aggregation = groupExpression.getPlan();
Assert.assertTrue(aggregation instanceof LogicalAggregate);
Assertions.assertTrue(aggregation instanceof LogicalAggregate);
groupExpression = groupExpression.child(0).getLogicalExpression();
Plan bottomFilter = groupExpression.getPlan();
Assert.assertTrue(bottomFilter instanceof LogicalFilter);
Assertions.assertTrue(bottomFilter instanceof LogicalFilter);
Expression greater = ((LogicalFilter<?>) bottomFilter).getPredicates();
Assert.assertTrue(greater instanceof GreaterThan);
Assert.assertTrue(greater.child(0) instanceof Slot);
Assert.assertEquals("gender", ((Slot) greater.child(0)).getName());
Assertions.assertTrue(greater instanceof GreaterThan);
Assertions.assertTrue(greater.child(0) instanceof Slot);
Assertions.assertEquals("gender", ((Slot) greater.child(0)).getName());
groupExpression = groupExpression.child(0).getLogicalExpression();
Plan scan2 = groupExpression.getPlan();
Assert.assertTrue(scan2 instanceof LogicalOlapScan);
Assertions.assertTrue(scan2 instanceof LogicalOlapScan);
}
/**
@ -174,30 +173,30 @@ public class PushDownPredicateThroughAggregationTest {
Group rootGroup = memo.getRoot();
GroupExpression groupExpression = rootGroup.getLogicalExpression().child(0).getLogicalExpression();
Plan upperFilter = groupExpression.getPlan();
Assert.assertTrue(upperFilter instanceof LogicalFilter);
Assertions.assertTrue(upperFilter instanceof LogicalFilter);
Expression upperPredicates = ((LogicalFilter<?>) upperFilter).getPredicates();
Assert.assertTrue(upperPredicates instanceof EqualTo);
Assert.assertTrue(upperPredicates.child(0) instanceof Slot);
Assertions.assertTrue(upperPredicates instanceof EqualTo);
Assertions.assertTrue(upperPredicates.child(0) instanceof Slot);
groupExpression = groupExpression.child(0).getLogicalExpression();
aggregation = groupExpression.getPlan();
Assert.assertTrue(aggregation instanceof LogicalAggregate);
Assertions.assertTrue(aggregation instanceof LogicalAggregate);
groupExpression = groupExpression.child(0).getLogicalExpression();
Plan bottomFilter = groupExpression.getPlan();
Assert.assertTrue(bottomFilter instanceof LogicalFilter);
Assertions.assertTrue(bottomFilter instanceof LogicalFilter);
Expression bottomPredicates = ((LogicalFilter<?>) bottomFilter).getPredicates();
Assert.assertTrue(bottomPredicates instanceof And);
Assert.assertEquals(2, bottomPredicates.children().size());
Assertions.assertTrue(bottomPredicates instanceof And);
Assertions.assertEquals(2, bottomPredicates.children().size());
Expression greater = bottomPredicates.child(0);
Assert.assertTrue(greater instanceof GreaterThan);
Assert.assertTrue(greater.child(0) instanceof Slot);
Assert.assertEquals("gender", ((Slot) greater.child(0)).getName());
Assertions.assertTrue(greater instanceof GreaterThan);
Assertions.assertTrue(greater.child(0) instanceof Slot);
Assertions.assertEquals("gender", ((Slot) greater.child(0)).getName());
Expression less = bottomPredicates.child(1);
Assert.assertTrue(less instanceof LessThanEqual);
Assert.assertTrue(less.child(0) instanceof Add);
Assertions.assertTrue(less instanceof LessThanEqual);
Assertions.assertTrue(less.child(0) instanceof Add);
groupExpression = groupExpression.child(0).getLogicalExpression();
Plan scan2 = groupExpression.getPlan();
Assert.assertTrue(scan2 instanceof LogicalOlapScan);
Assertions.assertTrue(scan2 instanceof LogicalOlapScan);
}
private Memo rewrite(Plan plan) {

View File

@ -49,8 +49,8 @@ import org.apache.doris.statistics.TableStats;
import com.google.common.base.Supplier;
import mockit.Expectations;
import mockit.Mocked;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
@ -105,7 +105,7 @@ public class StatsCalculatorTest {
groupExpression.setOwnerGroup(ownerGroup);
StatsCalculator statsCalculator = new StatsCalculator(groupExpression);
statsCalculator.estimate();
Assert.assertEquals(groupExpression.getOwnerGroup().getStatistics().getRowCount(), 10);
Assertions.assertEquals(groupExpression.getOwnerGroup().getStatistics().getRowCount(), 10);
}
@Test
@ -149,7 +149,7 @@ public class StatsCalculatorTest {
groupExpression.setOwnerGroup(ownerGroup);
StatsCalculator statsCalculator = new StatsCalculator(groupExpression);
statsCalculator.estimate();
Assert.assertEquals((long) (10000 * 0.1 * 0.05), ownerGroup.getStatistics().getRowCount(), 0.001);
Assertions.assertEquals((long) (10000 * 0.1 * 0.05), ownerGroup.getStatistics().getRowCount(), 0.001);
LogicalFilter logicalFilterOr = new LogicalFilter(or, groupPlan);
GroupExpression groupExpressionOr = new GroupExpression(logicalFilterOr);
@ -158,7 +158,7 @@ public class StatsCalculatorTest {
groupExpressionOr.setOwnerGroup(ownerGroupOr);
StatsCalculator statsCalculator2 = new StatsCalculator(groupExpressionOr);
statsCalculator2.estimate();
Assert.assertEquals((long) (10000 * (0.1 + 0.05 - 0.1 * 0.05)),
Assertions.assertEquals((long) (10000 * (0.1 + 0.05 - 0.1 * 0.05)),
ownerGroupOr.getStatistics().getRowCount(), 0.001);
}
@ -190,10 +190,10 @@ public class StatsCalculatorTest {
EqualTo equalTo = new EqualTo(slot1, slot2);
StatsDeriveResult semiJoinStats = JoinEstimation.estimate(leftStats,
rightStats, equalTo, JoinType.LEFT_SEMI_JOIN);
Assert.assertEquals(leftRowCount, semiJoinStats.getRowCount());
Assertions.assertEquals(leftRowCount, semiJoinStats.getRowCount());
StatsDeriveResult innerJoinStats = JoinEstimation.estimate(leftStats,
rightStats, equalTo, JoinType.INNER_JOIN);
Assert.assertEquals(2500000, innerJoinStats.getRowCount());
Assertions.assertEquals(2500000, innerJoinStats.getRowCount());
}
@Test
@ -237,8 +237,8 @@ public class StatsCalculatorTest {
StatsCalculator statsCalculator = new StatsCalculator(groupExpression);
statsCalculator.estimate();
StatsDeriveResult stats = ownerGroup.getStatistics();
Assert.assertEquals(1, stats.getSlotToColumnStats().size());
Assert.assertNotNull(stats.getSlotToColumnStats().get(slot1));
Assertions.assertEquals(1, stats.getSlotToColumnStats().size());
Assertions.assertNotNull(stats.getSlotToColumnStats().get(slot1));
}
}

View File

@ -18,16 +18,14 @@
package org.apache.doris.nereids.trees.expressions;
import org.apache.doris.nereids.parser.NereidsParser;
import org.apache.doris.nereids.trees.TreeNode;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class ExpressionParserTest {
private static final NereidsParser PARSER = new NereidsParser();
private void assertSql(String sql) throws Exception {
TreeNode treeNode = PARSER.parseSingle(sql);
System.out.println(treeNode.toString());
private void assertSql(String sql) {
PARSER.parseSingle(sql);
}
private void assertExpr(String expr) {
@ -36,7 +34,7 @@ public class ExpressionParserTest {
}
@Test
public void testSqlBetweenPredicate() throws Exception {
public void testSqlBetweenPredicate() {
String sql = "select * from test1 where d1 between 1 and 2";
assertSql(sql);
}
@ -48,10 +46,9 @@ public class ExpressionParserTest {
}
@Test
public void testSqlAnd() throws Exception {
public void testSqlAnd() {
String sql = "select * from test1 where a > 1 and b > 1";
TreeNode treeNode = PARSER.parseSingle(sql);
System.out.println(treeNode);
PARSER.parseSingle(sql);
}
@Test
@ -97,7 +94,7 @@ public class ExpressionParserTest {
}
@Test
public void testSqlFunction() throws Exception {
public void testSqlFunction() {
String sum = "select sum(a) from test1";
assertSql(sum);
@ -112,7 +109,7 @@ public class ExpressionParserTest {
}
@Test
public void testGroupByClause() throws Exception {
public void testGroupByClause() {
String groupBy = "select a from test group by a";
assertSql(groupBy);
@ -129,7 +126,7 @@ public class ExpressionParserTest {
}
@Test
public void testSortClause() throws Exception {
public void testSortClause() {
String sort = "select a from test order by c, d";
assertSql(sort);
@ -139,7 +136,7 @@ public class ExpressionParserTest {
}
@Test
public void testCaseWhen() throws Exception {
public void testCaseWhen() {
String caseWhen = "select case a when 1 then 2 else 3 end from test";
assertSql(caseWhen);
@ -148,7 +145,7 @@ public class ExpressionParserTest {
}
@Test
public void testInSubquery() throws Exception {
public void testInSubquery() {
String in = "select * from test where a in (select * from test1 where a = 0)";
assertSql(in);
@ -163,7 +160,7 @@ public class ExpressionParserTest {
}
@Test
public void testExist() throws Exception {
public void testExist() {
String exist = "select * from test where exists (select * from test where a = 1)";
assertSql(exist);
@ -208,7 +205,7 @@ public class ExpressionParserTest {
}
@Test
public void testExtract() throws Exception {
public void testExtract() {
String extract = "SELECT EXTRACT(YEAR FROM TIMESTAMP '2022-02-21 00:00:00') AS year FROM TEST;";
assertSql(extract);
@ -220,7 +217,7 @@ public class ExpressionParserTest {
}
@Test
public void testCast() throws Exception {
public void testCast() {
String cast = "SELECT CAST(A AS STRING) FROM TEST;";
assertSql(cast);

View File

@ -44,8 +44,8 @@ import org.apache.doris.nereids.types.BigIntType;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import mockit.Mocked;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Optional;
@ -61,7 +61,7 @@ public class PlanEqualsTest {
);
LogicalAggregate one = new LogicalAggregate(groupByExprList, outputExpressionList, child);
Assert.assertEquals(one, one);
Assertions.assertEquals(one, one);
List<Expression> groupByExprList1 = Lists.newArrayList();
List<NamedExpression> outputExpressionList1 = ImmutableList.of(
@ -69,18 +69,18 @@ public class PlanEqualsTest {
);
LogicalAggregate two = new LogicalAggregate(groupByExprList1, outputExpressionList1, child);
Assert.assertNotEquals(one, two);
Assertions.assertNotEquals(one, two);
}
@Test
public void testLogicalFilter(@Mocked Plan child) {
Expression predicate = new EqualTo(Literal.of(1), Literal.of(2));
LogicalFilter logicalFilter = new LogicalFilter(predicate, child);
Assert.assertEquals(logicalFilter, logicalFilter);
Assertions.assertEquals(logicalFilter, logicalFilter);
Expression predicate1 = new EqualTo(Literal.of(1), Literal.of(1));
LogicalFilter logicalFilter1 = new LogicalFilter(predicate1, child);
Assert.assertNotEquals(logicalFilter, logicalFilter1);
Assertions.assertNotEquals(logicalFilter, logicalFilter1);
}
@Test
@ -90,7 +90,7 @@ public class PlanEqualsTest {
new SlotReference("b", new BigIntType(), true, Lists.newArrayList())
);
LogicalJoin innerJoin = new LogicalJoin(JoinType.INNER_JOIN, Optional.of(condition), left, right);
Assert.assertEquals(innerJoin, innerJoin);
Assertions.assertEquals(innerJoin, innerJoin);
// Notice: condition1 != condition, so following is `assertNotEquals`.
// Because SlotReference.exprId is UUID.
@ -99,23 +99,23 @@ public class PlanEqualsTest {
new SlotReference("b", new BigIntType(), true, Lists.newArrayList())
);
LogicalJoin innerJoin1 = new LogicalJoin(JoinType.INNER_JOIN, Optional.of(condition1), left, right);
Assert.assertNotEquals(innerJoin, innerJoin1);
Assertions.assertNotEquals(innerJoin, innerJoin1);
Expression condition2 = new EqualTo(
new SlotReference("a", new BigIntType(), false, Lists.newArrayList()),
new SlotReference("b", new BigIntType(), true, Lists.newArrayList())
);
LogicalJoin innerJoin2 = new LogicalJoin(JoinType.INNER_JOIN, Optional.of(condition2), left, right);
Assert.assertNotEquals(innerJoin, innerJoin2);
Assertions.assertNotEquals(innerJoin, innerJoin2);
}
@Test
public void testLogicalOlapScan() {
LogicalOlapScan olapScan = new LogicalOlapScan(new Table(TableType.OLAP), Lists.newArrayList());
Assert.assertEquals(olapScan, olapScan);
Assertions.assertEquals(olapScan, olapScan);
LogicalOlapScan olapScan1 = new LogicalOlapScan(new Table(TableType.OLAP), Lists.newArrayList());
Assert.assertEquals(olapScan, olapScan1);
Assertions.assertEquals(olapScan, olapScan1);
}
@Test
@ -124,18 +124,18 @@ public class PlanEqualsTest {
SlotReference aSlot = new SlotReference("a", new BigIntType(), true, Lists.newArrayList());
List<NamedExpression> projects = ImmutableList.of(aSlot);
LogicalProject logicalProject = new LogicalProject(projects, child);
Assert.assertEquals(logicalProject, logicalProject);
Assertions.assertEquals(logicalProject, logicalProject);
LogicalProject logicalProjectWithSameSlot = new LogicalProject(ImmutableList.of(aSlot), child);
Assert.assertEquals(logicalProject, logicalProjectWithSameSlot);
Assertions.assertEquals(logicalProject, logicalProjectWithSameSlot);
SlotReference a1Slot = new SlotReference("a", new BigIntType(), true, Lists.newArrayList());
LogicalProject a1LogicalProject = new LogicalProject(ImmutableList.of(a1Slot), child);
Assert.assertNotEquals(logicalProject, a1LogicalProject);
Assertions.assertNotEquals(logicalProject, a1LogicalProject);
SlotReference bSlot = new SlotReference("b", new BigIntType(), true, Lists.newArrayList());
LogicalProject bLogicalProject1 = new LogicalProject(ImmutableList.of(bSlot), child);
Assert.assertNotEquals(logicalProject, bLogicalProject1);
Assertions.assertNotEquals(logicalProject, bLogicalProject1);
}
@Test
@ -143,11 +143,11 @@ public class PlanEqualsTest {
// TODO: Depend on List<OrderKey> Equals
List<OrderKey> orderKeyList = Lists.newArrayList();
LogicalSort logicalSort = new LogicalSort(orderKeyList, child);
Assert.assertEquals(logicalSort, logicalSort);
Assertions.assertEquals(logicalSort, logicalSort);
List<OrderKey> orderKeyListClone = Lists.newArrayList();
LogicalSort logicalSortClone = new LogicalSort(orderKeyListClone, child);
Assert.assertEquals(logicalSort, logicalSortClone);
Assertions.assertEquals(logicalSort, logicalSortClone);
}
/* *************************** Physical *************************** */
@ -162,7 +162,7 @@ public class PlanEqualsTest {
PhysicalAggregate physicalAggregate = new PhysicalAggregate(groupByExprList, outputExpressionList,
partitionExprList, aggPhase, usingStream, logicalProperties, child);
Assert.assertEquals(physicalAggregate, physicalAggregate);
Assertions.assertEquals(physicalAggregate, physicalAggregate);
}
@Test
@ -170,7 +170,7 @@ public class PlanEqualsTest {
Expression predicate = new EqualTo(Literal.of(1), Literal.of(2));
PhysicalFilter physicalFilter = new PhysicalFilter(predicate, logicalProperties, child);
Assert.assertEquals(physicalFilter, physicalFilter);
Assertions.assertEquals(physicalFilter, physicalFilter);
}
@Test
@ -180,7 +180,7 @@ public class PlanEqualsTest {
PhysicalHashJoin innerJoin = new PhysicalHashJoin(JoinType.INNER_JOIN, Optional.of(expression),
logicalProperties, left,
right);
Assert.assertEquals(innerJoin, innerJoin);
Assertions.assertEquals(innerJoin, innerJoin);
}
@Test
@ -189,7 +189,7 @@ public class PlanEqualsTest {
PhysicalOlapScan olapScan = new PhysicalOlapScan(olapTable, qualifier, Optional.empty(), logicalProperties);
Assert.assertEquals(olapScan, olapScan);
Assertions.assertEquals(olapScan, olapScan);
}
@Test
@ -199,15 +199,15 @@ public class PlanEqualsTest {
SlotReference aSlot = new SlotReference("a", new BigIntType(), true, Lists.newArrayList());
List<NamedExpression> projects = ImmutableList.of(aSlot);
PhysicalProject physicalProject = new PhysicalProject(projects, logicalProperties, child);
Assert.assertEquals(physicalProject, physicalProject);
Assertions.assertEquals(physicalProject, physicalProject);
PhysicalProject physicalProjectWithSameSlot = new PhysicalProject(ImmutableList.of(aSlot), logicalProperties,
child);
Assert.assertEquals(physicalProject, physicalProjectWithSameSlot);
Assertions.assertEquals(physicalProject, physicalProjectWithSameSlot);
SlotReference a1Slot = new SlotReference("a", new BigIntType(), true, Lists.newArrayList());
PhysicalProject a1PhysicalProject = new PhysicalProject(ImmutableList.of(a1Slot), logicalProperties, child);
Assert.assertNotEquals(physicalProject, a1PhysicalProject);
Assertions.assertNotEquals(physicalProject, a1PhysicalProject);
}
@Test
@ -216,11 +216,11 @@ public class PlanEqualsTest {
List<OrderKey> orderKeyList = Lists.newArrayList();
PhysicalHeapSort physicalHeapSort = new PhysicalHeapSort(orderKeyList, -1, 0, logicalProperties, child);
Assert.assertEquals(physicalHeapSort, physicalHeapSort);
Assertions.assertEquals(physicalHeapSort, physicalHeapSort);
List<OrderKey> orderKeyListClone = Lists.newArrayList();
PhysicalHeapSort physicalHeapSortClone = new PhysicalHeapSort(orderKeyListClone, -1, 0, logicalProperties,
child);
Assert.assertEquals(physicalHeapSort, physicalHeapSortClone);
Assertions.assertEquals(physicalHeapSort, physicalHeapSortClone);
}
}

View File

@ -17,48 +17,49 @@
package org.apache.doris.nereids.types;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class DataTypeTest {
@Test
public void testDataTypeEquals() {
BigIntType bigIntType1 = new BigIntType();
BigIntType bigIntType2 = new BigIntType();
Assert.assertEquals(bigIntType1, bigIntType2);
Assert.assertEquals(bigIntType1.hashCode(), bigIntType2.hashCode());
Assertions.assertEquals(bigIntType1, bigIntType2);
Assertions.assertEquals(bigIntType1.hashCode(), bigIntType2.hashCode());
BooleanType booleanType1 = new BooleanType();
BooleanType booleanType2 = new BooleanType();
Assert.assertEquals(booleanType1, booleanType2);
Assert.assertEquals(booleanType1.hashCode(), booleanType2.hashCode());
Assertions.assertEquals(booleanType1, booleanType2);
Assertions.assertEquals(booleanType1.hashCode(), booleanType2.hashCode());
DoubleType doubleType1 = new DoubleType();
DoubleType doubleType2 = new DoubleType();
Assert.assertEquals(doubleType1, doubleType2);
Assert.assertEquals(doubleType1.hashCode(), doubleType2.hashCode());
Assertions.assertEquals(doubleType1, doubleType2);
Assertions.assertEquals(doubleType1.hashCode(), doubleType2.hashCode());
IntegerType integerType1 = new IntegerType();
IntegerType integerType2 = new IntegerType();
Assert.assertEquals(integerType1, integerType2);
Assert.assertEquals(integerType1.hashCode(), integerType2.hashCode());
Assertions.assertEquals(integerType1, integerType2);
Assertions.assertEquals(integerType1.hashCode(), integerType2.hashCode());
NullType nullType1 = new NullType();
NullType nullType2 = new NullType();
Assert.assertEquals(nullType1, nullType2);
Assert.assertEquals(nullType1.hashCode(), nullType2.hashCode());
Assertions.assertEquals(nullType1, nullType2);
Assertions.assertEquals(nullType1.hashCode(), nullType2.hashCode());
StringType stringType1 = new StringType();
StringType stringType2 = new StringType();
Assert.assertEquals(stringType1, stringType2);
Assert.assertEquals(stringType1.hashCode(), stringType2.hashCode());
Assertions.assertEquals(stringType1, stringType2);
Assertions.assertEquals(stringType1.hashCode(), stringType2.hashCode());
VarcharType varcharType1 = new VarcharType(32);
VarcharType varcharType2 = new VarcharType(32);
Assert.assertEquals(varcharType1, varcharType2);
Assert.assertEquals(varcharType1.hashCode(), varcharType2.hashCode());
Assertions.assertEquals(varcharType1, varcharType2);
Assertions.assertEquals(varcharType1.hashCode(), varcharType2.hashCode());
VarcharType varcharType3 = new VarcharType(64);
Assert.assertNotEquals(varcharType1, varcharType3);
Assert.assertNotEquals(varcharType1.hashCode(), varcharType3.hashCode());
Assertions.assertNotEquals(varcharType1, varcharType3);
Assertions.assertNotEquals(varcharType1.hashCode(), varcharType3.hashCode());
}
}

View File

@ -15,11 +15,7 @@
// specific language governing permissions and limitations
// under the License.
package plugin;
import org.apache.doris.plugin.Plugin;
import org.apache.doris.plugin.PluginContext;
import org.apache.doris.plugin.PluginInfo;
package org.apache.doris.plugin;
import java.io.IOException;
import java.util.HashMap;

View File

@ -58,9 +58,9 @@ import org.apache.doris.utframe.MockedFrontend.EnvVarNotSetException;
import org.apache.doris.utframe.MockedFrontend.FeStartException;
import org.apache.doris.utframe.MockedFrontend.NotInitException;
import com.clearspring.analytics.util.Lists;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.AfterAll;