Skip to content

Commit

Permalink
[refactor](rename active query) rename active queries to active query…
Browse files Browse the repository at this point in the history
… stats
  • Loading branch information
Doris-Extras committed Jan 18, 2024
1 parent 41672f2 commit c7dabc9
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
{
"title": "ACTIVE_QUERIES",
"title": "active_query_stats",
"language": "en"
}
---
Expand All @@ -24,28 +24,28 @@ specific language governing permissions and limitations
under the License.
-->

## `active_queries`
## `active_query_stats`

### Name

<version since="dev">

active_queries
active_query_stats

</version>

### description

Table-Value-Function, generate a temporary table named active_queries. This tvf is used to view the information of running queries in doris cluster.
Table-Value-Function, generate a temporary table named active_query_stats. This tvf is used to view the information of running queries in doris cluster.

This function is used in FROM clauses.

#### syntax
`active_queries()`
`active_query_stats()`

active_queries() table schema:
active_query_stats() table schema:
```
mysql [(none)]> desc function active_queries();
mysql [(none)]> desc function active_query_stats();
+------------------------+--------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+--------+------+-------+---------+-------+
Expand All @@ -69,7 +69,7 @@ mysql [(none)]> desc function active_queries();

### example
```
mysql [(none)]>select * from active_queries();
mysql [(none)]>select * from active_query_stats();
+------------+--------+----------------------------------+---------------------+-------------+-----------------+----------------+----------+------------+-------------------+------------------------+----------+------------------+-------+
| BeHost | BePort | QueryId | StartTime | QueryTimeMs | WorkloadGroupId | QueryCpuTimeMs | ScanRows | ScanBytes | BePeakMemoryBytes | CurrentUsedMemoryBytes | Database | FrontendInstance | Sql |
+------------+--------+----------------------------------+---------------------+-------------+-----------------+----------------+----------+------------+-------------------+------------------------+----------+------------------+-------+
Expand All @@ -80,4 +80,4 @@ mysql [(none)]>select * from active_queries();

### keywords

active_queries
active_query_stats
5 changes: 2 additions & 3 deletions docs/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@
"sql-manual/sql-functions/table-functions/workload-group",
"sql-manual/sql-functions/table-functions/catalogs",
"sql-manual/sql-functions/table-functions/frontends_disks",
"sql-manual/sql-functions/table-functions/active_queries",
"sql-manual/sql-functions/table-functions/active_query_stats",
"sql-manual/sql-functions/table-functions/jobs",
"sql-manual/sql-functions/table-functions/mv_infos",
"sql-manual/sql-functions/table-functions/tasks"
Expand Down Expand Up @@ -814,7 +814,6 @@
"sql-manual/sql-functions/ip-functions/inet6-aton",
"sql-manual/sql-functions/ip-functions/ipv6-string-to-num-or-default",
"sql-manual/sql-functions/ip-functions/ipv6-string-to-num-or-null"

]
},
{
Expand Down Expand Up @@ -1382,4 +1381,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
{
"title": "ACTIVE_QUERIES",
"title": "active_query_stats",
"language": "zh-CN"
}
---
Expand All @@ -24,28 +24,28 @@ specific language governing permissions and limitations
under the License.
-->

## `active_queries`
## `active_query_stats`

### Name

<version since="dev">

active_queries
active_query_stats

</version>

### description

表函数,生成active_queries临时表,可以查看当前doris集群中正在运行的 query 信息。
表函数,生成active_query_stats临时表,可以查看当前doris集群中正在运行的 query 信息。

该函数用于from子句中。

#### syntax
`active_queries()`
`active_query_stats()`

active_queries()表结构:
active_query_stats()表结构:
```
mysql [(none)]> desc function active_queries();
mysql [(none)]> desc function active_query_stats();
+------------------------+--------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+--------+------+-------+---------+-------+
Expand All @@ -69,7 +69,7 @@ mysql [(none)]> desc function active_queries();

### example
```
mysql [(none)]>select * from active_queries();
mysql [(none)]>select * from active_query_stats();
+------------+--------+----------------------------------+---------------------+-------------+-----------------+----------------+----------+------------+-------------------+------------------------+----------+------------------+-------+
| BeHost | BePort | QueryId | StartTime | QueryTimeMs | WorkloadGroupId | QueryCpuTimeMs | ScanRows | ScanBytes | BePeakMemoryBytes | CurrentUsedMemoryBytes | Database | FrontendInstance | Sql |
+------------+--------+----------------------------------+---------------------+-------------+-----------------+----------------+----------+------------+-------------------+------------------------+----------+------------------+-------+
Expand All @@ -80,4 +80,4 @@ mysql [(none)]>select * from active_queries();

### keywords

active_queries
active_query_stats
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.doris.catalog;

import org.apache.doris.nereids.trees.expressions.functions.table.ActiveQueries;
import org.apache.doris.nereids.trees.expressions.functions.table.ActiveQueryStats;
import org.apache.doris.nereids.trees.expressions.functions.table.Backends;
import org.apache.doris.nereids.trees.expressions.functions.table.Catalogs;
import org.apache.doris.nereids.trees.expressions.functions.table.Frontends;
Expand Down Expand Up @@ -54,7 +54,7 @@ public class BuiltinTableValuedFunctions implements FunctionHelper {
tableValued(Hdfs.class, "hdfs"),
tableValued(HttpStream.class, "http_stream"),
tableValued(Numbers.class, "numbers"),
tableValued(ActiveQueries.class, "active_queries"),
tableValued(ActiveQueryStats.class, "active_query_stats"),
tableValued(S3.class, "s3"),
tableValued(MvInfos.class, "mv_infos"),
tableValued(Jobs.class, "jobs"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
/**
* queries tvf
*/
public class ActiveQueries extends TableValuedFunction {
public class ActiveQueryStats extends TableValuedFunction {

public ActiveQueries(Properties properties) {
super("active_queries", properties);
public ActiveQueryStats(Properties properties) {
super("active_query_stats", properties);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.doris.nereids.trees.expressions.visitor;

import org.apache.doris.nereids.trees.expressions.functions.table.ActiveQueries;
import org.apache.doris.nereids.trees.expressions.functions.table.ActiveQueryStats;
import org.apache.doris.nereids.trees.expressions.functions.table.Backends;
import org.apache.doris.nereids.trees.expressions.functions.table.Catalogs;
import org.apache.doris.nereids.trees.expressions.functions.table.Frontends;
Expand Down Expand Up @@ -91,7 +91,7 @@ default R visitNumbers(Numbers numbers, C context) {
return visitTableValuedFunction(numbers, context);
}

default R visitQueries(ActiveQueries queries, C context) {
default R visitQueries(ActiveQueryStats queries, C context) {
return visitTableValuedFunction(queries, context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.Map;

public class ActiveQueriesTableValuedFunction extends MetadataTableValuedFunction {
public static final String NAME = "active_queries";
public static final String NAME = "active_query_stats";

private static final ImmutableList<Column> SCHEMA = ImmutableList.of(
new Column("BeHost", ScalarType.createStringType()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ suite("test_queries_tvf","p0,external,tvf,external_docker") {

sql """select * from ${table_name};"""

def res = sql """ select QueryId from active_queries() where `Sql` like "%${table_name}%"; """
def res = sql """ select QueryId from active_query_stats() where `Sql` like "%${table_name}%"; """
logger.info("res = " + res)
assertTrue(res.size() >= 0 && res.size() <= 2);
}
2 changes: 1 addition & 1 deletion regression-test/suites/nereids_function_p0/tvf/tvf.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ suite("nereids_tvf") {
"""

sql """
select QueryId from active_queries() where `Sql` like "%test_queries_tvf%";
select QueryId from active_query_stats() where `Sql` like "%test_queries_tvf%";
"""

sql """
Expand Down

0 comments on commit c7dabc9

Please sign in to comment.