This is an automated email from the ASF dual-hosted git repository.
caiconghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new a630e03 [Enhancement](routine_load) Support show routine load
statement with like predicate (#8188)
a630e03 is described below
commit a630e037b9f8982a175e2eab677d5bcf16c5c822
Author: caiconghui <[email protected]>
AuthorDate: Sat Feb 26 10:35:38 2022 +0800
[Enhancement](routine_load) Support show routine load statement with like
predicate (#8188)
* [Enhancement](routine_load) Support show routine load with like predicate
Co-authored-by: caiconghui1 <[email protected]>
---
.../Data Manipulation/SHOW ROUTINE LOAD.md | 9 +++++++--
.../Data Manipulation/SHOW ROUTINE LOAD.md | 7 ++++++-
fe/fe-core/src/main/cup/sql_parser.cup | 12 ++++++------
.../apache/doris/analysis/ShowRoutineLoadStmt.java | 21 ++++++++++++++-------
.../org/apache/doris/common/CaseSensibility.java | 3 ++-
.../doris/common/proc/RoutineLoadsProcDir.java | 2 +-
.../doris/load/routineload/RoutineLoadManager.java | 10 ++++++++--
.../java/org/apache/doris/qe/ShowExecutor.java | 9 +++++++--
.../load/routineload/RoutineLoadManagerTest.java | 22 +++++++++++++++++++---
9 files changed, 70 insertions(+), 25 deletions(-)
diff --git a/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW
ROUTINE LOAD.md b/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW
ROUTINE LOAD.md
index 7541fca..66ffbd6 100644
--- a/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW ROUTINE
LOAD.md
+++ b/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW ROUTINE
LOAD.md
@@ -28,7 +28,7 @@ under the License.
## description
This statement is used to show the running status of the Routine Load job
grammar:
- SHOW [ALL] ROUTINE LOAD [FOR jobName];
+ SHOW [ALL] ROUTINE LOAD [FOR jobName] [LIKE pattern];
Result description:
@@ -76,7 +76,7 @@ ReasonOfStateChanged: Reason of job status change
SHOW ALL ROUTINE LOAD FOR test1;
-2. Show the current running routine import job named test1
+2. Show the current running routine load job named test1
SHOW ROUTINE LOAD FOR test1;
@@ -98,5 +98,10 @@ SHOW ROUTINE LOAD FOR example_db.test1;
SHOW ALL ROUTINE LOAD FOR example_db.test1;
+7. Show the current running routine load jobs under example_db with name match
test1
+
+use example_db;
+SHOW ROUTINE LOAD LIKE "%test1%";
+
## keyword
SHOW,ROUTINE,LOAD
diff --git a/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW
ROUTINE LOAD.md b/docs/zh-CN/sql-reference/sql-statements/Data
Manipulation/SHOW ROUTINE LOAD.md
index 9b6e2e3..051c5a8 100644
--- a/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW ROUTINE
LOAD.md
+++ b/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW ROUTINE
LOAD.md
@@ -28,7 +28,7 @@ under the License.
## description
该语句用于展示 Routine Load 作业运行状态
语法:
- SHOW [ALL] ROUTINE LOAD [FOR jobName];
+ SHOW [ALL] ROUTINE LOAD [FOR jobName] [LIKE pattern];
结果说明:
@@ -98,6 +98,11 @@ ReasonOfStateChanged: 作业状态变更的原因
SHOW ALL ROUTINE LOAD FOR example_db.test1;
+7. 显示 example_db 下,名称匹配 test1 的当前正在运行的例行导入作业
+
+ use example_db;
+ SHOW ROUTINE LOAD LIKE "%test1%";
+
## keyword
SHOW,ROUTINE,LOAD
diff --git a/fe/fe-core/src/main/cup/sql_parser.cup
b/fe/fe-core/src/main/cup/sql_parser.cup
index 5a9953c..a29946f 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -1875,19 +1875,19 @@ stop_routine_load_stmt ::=
show_routine_load_stmt ::=
KW_SHOW KW_ROUTINE KW_LOAD KW_FOR job_label:jobLabel
{:
- RESULT = new ShowRoutineLoadStmt(jobLabel, false);
+ RESULT = new ShowRoutineLoadStmt(jobLabel, false, null);
:}
| KW_SHOW KW_ALL KW_ROUTINE KW_LOAD KW_FOR job_label:jobLabel
{:
- RESULT = new ShowRoutineLoadStmt(jobLabel, true);
+ RESULT = new ShowRoutineLoadStmt(jobLabel, true, null);
:}
- | KW_SHOW KW_ROUTINE KW_LOAD
+ | KW_SHOW KW_ROUTINE KW_LOAD opt_wild_where
{:
- RESULT = new ShowRoutineLoadStmt(null, false);
+ RESULT = new ShowRoutineLoadStmt(null, false, parser.wild);
:}
- | KW_SHOW KW_ALL KW_ROUTINE KW_LOAD
+ | KW_SHOW KW_ALL KW_ROUTINE KW_LOAD opt_wild_where
{:
- RESULT = new ShowRoutineLoadStmt(null, true);
+ RESULT = new ShowRoutineLoadStmt(null, true, parser.wild);
:}
;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowRoutineLoadStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowRoutineLoadStmt.java
index ac270ae..eb63d97 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowRoutineLoadStmt.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowRoutineLoadStmt.java
@@ -36,7 +36,7 @@ import java.util.List;
Show routine load progress by routine load name
syntax:
- SHOW [ALL] ROUTINE LOAD [database.][name]
+ SHOW [ALL] ROUTINE LOAD [FOR JobName] [LIKE pattern]
without ALL: only show job which is not final
with ALL: show all of job include history job
@@ -50,15 +50,17 @@ import java.util.List;
example:
show routine load named test in database1
- SHOW ROUTINE LOAD database1.test;
-
- show routine load in database1
- SHOW ROUTINE LOAD database1;
+ use database1
+ SHOW ROUTINE LOAD for test;
show routine load in database1 include history
use database1;
SHOW ALL ROUTINE LOAD;
+ show routine load in database1 whose name match pattern "%test%"
+ use database1;
+ SHOW ROUTINE LOAD LIKE "%test%";
+
show routine load in all of database
please use show proc
*/
@@ -91,11 +93,12 @@ public class ShowRoutineLoadStmt extends ShowStmt {
private String dbFullName; // optional
private String name; // optional
private boolean includeHistory = false;
+ private String pattern; // optional
-
- public ShowRoutineLoadStmt(LabelName labelName, boolean includeHistory) {
+ public ShowRoutineLoadStmt(LabelName labelName, boolean includeHistory,
String pattern) {
this.labelName = labelName;
this.includeHistory = includeHistory;
+ this.pattern = pattern;
}
public String getDbFullName() {
@@ -110,6 +113,10 @@ public class ShowRoutineLoadStmt extends ShowStmt {
return includeHistory;
}
+ public String getPattern() {
+ return pattern;
+ }
+
@Override
public void analyze(Analyzer analyzer) throws UserException {
super.analyze(analyzer);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/CaseSensibility.java
b/fe/fe-core/src/main/java/org/apache/doris/common/CaseSensibility.java
index 7d80309..ebd7b63 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/CaseSensibility.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/CaseSensibility.java
@@ -30,7 +30,8 @@ public enum CaseSensibility {
LABEL(false),
VARIABLES(true),
RESOURCE(true),
- CONFIG(true);
+ CONFIG(true),
+ ROUTINE_LOAD(true);
private boolean caseSensitive;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/proc/RoutineLoadsProcDir.java
b/fe/fe-core/src/main/java/org/apache/doris/common/proc/RoutineLoadsProcDir.java
index e48cc12..91e4c32 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/common/proc/RoutineLoadsProcDir.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/common/proc/RoutineLoadsProcDir.java
@@ -64,7 +64,7 @@ public class RoutineLoadsProcDir implements ProcDirInterface {
baseProcResult.setNames(TITLE_NAMES);
RoutineLoadManager routineLoadManager =
Catalog.getCurrentCatalog().getRoutineLoadManager();
try {
- List<RoutineLoadJob> routineLoadJobList =
routineLoadManager.getJob(null, null, true);
+ List<RoutineLoadJob> routineLoadJobList =
routineLoadManager.getJob(null, null, true, null);
for (RoutineLoadJob routineLoadJob : routineLoadJobList) {
baseProcResult.addRow(routineLoadJob.getShowStatistic());
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/load/routineload/RoutineLoadManager.java
b/fe/fe-core/src/main/java/org/apache/doris/load/routineload/RoutineLoadManager.java
index ae6d8b3..ed6e2ea 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/load/routineload/RoutineLoadManager.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/load/routineload/RoutineLoadManager.java
@@ -32,6 +32,7 @@ import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.InternalErrorCode;
import org.apache.doris.common.LoadException;
import org.apache.doris.common.MetaNotFoundException;
+import org.apache.doris.common.PatternMatcher;
import org.apache.doris.common.UserException;
import org.apache.doris.common.io.Writable;
import org.apache.doris.common.util.LogBuilder;
@@ -468,7 +469,7 @@ public class RoutineLoadManager implements Writable {
}
public RoutineLoadJob getJob(String dbFullName, String jobName) throws
MetaNotFoundException {
- List<RoutineLoadJob> routineLoadJobList = getJob(dbFullName, jobName,
false);
+ List<RoutineLoadJob> routineLoadJobList = getJob(dbFullName, jobName,
false, null);
if (routineLoadJobList == null || routineLoadJobList.size() == 0) {
return null;
} else {
@@ -483,8 +484,10 @@ public class RoutineLoadManager implements Writable {
if includeHistory is false, filter not running job in result
else return all of result
*/
- public List<RoutineLoadJob> getJob(String dbFullName, String jobName,
boolean includeHistory)
+ public List<RoutineLoadJob> getJob(String dbFullName, String jobName,
boolean includeHistory, PatternMatcher matcher)
throws MetaNotFoundException {
+ Preconditions.checkArgument(jobName == null || matcher == null,
+ "jobName and matcher cannot be not null at the same time");
// return all of routine load job
List<RoutineLoadJob> result;
RESULT:
@@ -521,6 +524,9 @@ public class RoutineLoadManager implements Writable {
if (!includeHistory) {
result = result.stream().filter(entity ->
!entity.getState().isFinalState()).collect(Collectors.toList());
}
+ if (matcher != null) {
+ result = result.stream().filter(entity ->
matcher.match(entity.getName())).collect(Collectors.toList());
+ }
return result;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
index 5c79b20..3d47227 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
@@ -1208,10 +1208,15 @@ public class ShowExecutor {
// if job exists
List<RoutineLoadJob> routineLoadJobList;
try {
+ PatternMatcher matcher = null;
+ if (showRoutineLoadStmt.getPattern() != null) {
+ matcher =
PatternMatcher.createMysqlPattern(showRoutineLoadStmt.getPattern(),
+ CaseSensibility.ROUTINE_LOAD.getCaseSensibility());
+ }
routineLoadJobList =
Catalog.getCurrentCatalog().getRoutineLoadManager()
.getJob(showRoutineLoadStmt.getDbFullName(),
showRoutineLoadStmt.getName(),
- showRoutineLoadStmt.isIncludeHistory());
+ showRoutineLoadStmt.isIncludeHistory(), matcher);
} catch (MetaNotFoundException e) {
LOG.warn(e.getMessage(), e);
throw new AnalysisException(e.getMessage());
@@ -1983,7 +1988,7 @@ public class ShowExecutor {
if (showCreateRoutineLoadStmt.isIncludeHistory()) {
List<RoutineLoadJob> routineLoadJobList = new ArrayList<>();
try {
- routineLoadJobList =
Catalog.getCurrentCatalog().getRoutineLoadManager().getJob(dbName, labelName,
true);
+ routineLoadJobList =
Catalog.getCurrentCatalog().getRoutineLoadManager().getJob(dbName, labelName,
true, null);
} catch (MetaNotFoundException e) {
LOG.warn(new LogBuilder(LogKey.ROUTINE_LOAD_JOB, labelName)
.add("error_msg", "Routine load cannot be found by
this name")
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/load/routineload/RoutineLoadManagerTest.java
b/fe/fe-core/src/test/java/org/apache/doris/load/routineload/RoutineLoadManagerTest.java
index 95f4889..f9d538f 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/load/routineload/RoutineLoadManagerTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/load/routineload/RoutineLoadManagerTest.java
@@ -33,6 +33,7 @@ import org.apache.doris.common.DdlException;
import org.apache.doris.common.InternalErrorCode;
import org.apache.doris.common.LoadException;
import org.apache.doris.common.MetaNotFoundException;
+import org.apache.doris.common.PatternMatcher;
import org.apache.doris.common.UserException;
import org.apache.doris.common.jmockit.Deencapsulation;
import org.apache.doris.load.loadv2.LoadTask;
@@ -495,7 +496,7 @@ public class RoutineLoadManagerTest {
@Test
public void testGetJob(@Injectable RoutineLoadJob routineLoadJob1,
@Injectable RoutineLoadJob routineLoadJob2,
- @Injectable RoutineLoadJob routineLoadJob3) throws
MetaNotFoundException {
+ @Injectable RoutineLoadJob routineLoadJob3) throws
MetaNotFoundException, AnalysisException {
new Expectations() {
{
@@ -508,6 +509,15 @@ public class RoutineLoadManagerTest {
routineLoadJob3.isFinal();
minTimes = 0;
result = true;
+ routineLoadJob1.getName();
+ minTimes = 0;
+ result = "routine_load_job_test1";
+ routineLoadJob2.getName();
+ minTimes = 0;
+ result = "routine_load_job";
+ routineLoadJob3.getName();
+ minTimes = 0;
+ result = "routine_load_job_test2";
}
};
@@ -517,12 +527,18 @@ public class RoutineLoadManagerTest {
idToRoutineLoadJob.put(2L, routineLoadJob2);
idToRoutineLoadJob.put(3L, routineLoadJob3);
Deencapsulation.setField(routineLoadManager, "idToRoutineLoadJob",
idToRoutineLoadJob);
- List<RoutineLoadJob> result = routineLoadManager.getJob(null, null,
true);
+ List<RoutineLoadJob> result = routineLoadManager.getJob(null, null,
true, null);
Assert.assertEquals(3, result.size());
Assert.assertEquals(routineLoadJob2, result.get(0));
Assert.assertEquals(routineLoadJob1, result.get(1));
Assert.assertEquals(routineLoadJob3, result.get(2));
+
+ PatternMatcher matcher = PatternMatcher.createMysqlPattern("%test%",
true);
+ result = routineLoadManager.getJob(null, null, true, matcher);
+ Assert.assertEquals(2, result.size());
+ Assert.assertEquals(routineLoadJob1, result.get(0));
+ Assert.assertEquals(routineLoadJob3, result.get(1));
}
@Test
@@ -561,7 +577,7 @@ public class RoutineLoadManagerTest {
nameToRoutineLoadJob.put("", routineLoadJobList);
dbToNameToRoutineLoadJob.put(1L, nameToRoutineLoadJob);
Deencapsulation.setField(routineLoadManager,
"dbToNameToRoutineLoadJob", dbToNameToRoutineLoadJob);
- List<RoutineLoadJob> result = routineLoadManager.getJob("", "", true);
+ List<RoutineLoadJob> result = routineLoadManager.getJob("", "", true,
null);
Assert.assertEquals(3, result.size());
Assert.assertEquals(routineLoadJob2, result.get(0));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]