-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix](Nereids) fix new coordinator compute a wrong scanRangeNum (#43850)
fix new coordinator compute a wrong scanRangeNum, introduced by #41730 This bug will show a wrong progress in s3 load: ``` Progress: 0.00%(73/2147483647) ```
- Loading branch information
Showing
3 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
fe/fe-core/src/test/java/org/apache/doris/qe/NereidsCoordinatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// 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. | ||
|
||
package org.apache.doris.qe; | ||
|
||
import org.apache.doris.catalog.EnvFactory; | ||
import org.apache.doris.common.FeConstants; | ||
import org.apache.doris.nereids.NereidsPlanner; | ||
import org.apache.doris.nereids.util.PlanChecker; | ||
import org.apache.doris.thrift.TUniqueId; | ||
import org.apache.doris.utframe.TestWithFeService; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.UUID; | ||
|
||
public class NereidsCoordinatorTest extends TestWithFeService { | ||
@BeforeAll | ||
public void init() throws Exception { | ||
FeConstants.runningUnitTest = true; | ||
|
||
createDatabase("test"); | ||
useDatabase("test"); | ||
|
||
createTable("create table tbl(id int) distributed by hash(id) buckets 10 properties('replication_num' = '1');"); | ||
} | ||
|
||
@Test | ||
public void testNereidsCoordinatorScanRangeNum() throws IOException { | ||
NereidsPlanner planner = plan("select * from test.tbl"); | ||
NereidsCoordinator coordinator = (NereidsCoordinator) EnvFactory.getInstance() | ||
.createCoordinator(connectContext, null, planner, null); | ||
int scanRangeNum = coordinator.getScanRangeNum(); | ||
Assertions.assertEquals(10, scanRangeNum); | ||
} | ||
|
||
@Test | ||
public void testNereidsCoordinatorScanRangeNum2() throws IOException { | ||
NereidsPlanner planner = plan("select * from information_schema.columns"); | ||
NereidsCoordinator coordinator = (NereidsCoordinator) EnvFactory.getInstance() | ||
.createCoordinator(connectContext, null, planner, null); | ||
int scanRangeNum = coordinator.getScanRangeNum(); | ||
Assertions.assertEquals(0, scanRangeNum); | ||
} | ||
|
||
private NereidsPlanner plan(String sql) throws IOException { | ||
ConnectContext connectContext = createDefaultCtx(); | ||
connectContext.getSessionVariable().setDisableNereidsRules("PRUNE_EMPTY_PARTITION,OLAP_SCAN_TABLET_PRUNE"); | ||
connectContext.setThreadLocalInfo(); | ||
|
||
UUID uuid = UUID.randomUUID(); | ||
connectContext.setQueryId(new TUniqueId(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits())); | ||
NereidsPlanner planner = PlanChecker.from(connectContext).plan(sql); | ||
return planner; | ||
} | ||
} |