diff --git a/docs/en/docs/sql-manual/sql-functions/table-functions/backends.md b/docs/en/docs/sql-manual/sql-functions/table-functions/backends.md index e232296a89..d6dae3bb3d 100644 --- a/docs/en/docs/sql-manual/sql-functions/table-functions/backends.md +++ b/docs/en/docs/sql-manual/sql-functions/table-functions/backends.md @@ -52,8 +52,7 @@ mysql> desc function backends(); +-------------------------+--------+------+-------+---------+-------+ | BackendId | BIGINT | No | false | NULL | NONE | | Cluster | TEXT | No | false | NULL | NONE | -| IP | TEXT | No | false | NULL | NONE | -| HostName | TEXT | No | false | NULL | NONE | +| Host | TEXT | No | false | NULL | NONE | | HeartbeatPort | INT | No | false | NULL | NONE | | BePort | INT | No | false | NULL | NONE | | HttpPort | INT | No | false | NULL | NONE | @@ -77,7 +76,7 @@ mysql> desc function backends(); | HeartbeatFailureCounter | INT | No | false | NULL | NONE | | NodeRole | TEXT | No | false | NULL | NONE | +-------------------------+--------+------+-------+---------+-------+ -26 rows in set (0.04 sec) +25 rows in set (0.04 sec) ``` The information displayed by the `backends` tvf is basically consistent with the information displayed by the `show backends` statement. However, the types of each field in the `backends` tvf are more specific, and you can use the `backends` tvf to perform operations such as filtering and joining. @@ -88,8 +87,7 @@ mysql> select * from backends()\G *************************** 1. row *************************** BackendId: 10022 Cluster: default_cluster - IP: 10.16.10.14 - HostName: 10.16.10.14 + Host: 10.16.10.14 HeartbeatPort: 9159 BePort: 9169 HttpPort: 8149 diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/table-functions/backends.md b/docs/zh-CN/docs/sql-manual/sql-functions/table-functions/backends.md index 846566abbf..95c4c5725f 100644 --- a/docs/zh-CN/docs/sql-manual/sql-functions/table-functions/backends.md +++ b/docs/zh-CN/docs/sql-manual/sql-functions/table-functions/backends.md @@ -51,8 +51,7 @@ mysql> desc function backends(); +-------------------------+--------+------+-------+---------+-------+ | BackendId | BIGINT | No | false | NULL | NONE | | Cluster | TEXT | No | false | NULL | NONE | -| IP | TEXT | No | false | NULL | NONE | -| HostName | TEXT | No | false | NULL | NONE | +| Host | TEXT | No | false | NULL | NONE | | HeartbeatPort | INT | No | false | NULL | NONE | | BePort | INT | No | false | NULL | NONE | | HttpPort | INT | No | false | NULL | NONE | @@ -76,7 +75,7 @@ mysql> desc function backends(); | HeartbeatFailureCounter | INT | No | false | NULL | NONE | | NodeRole | TEXT | No | false | NULL | NONE | +-------------------------+--------+------+-------+---------+-------+ -26 rows in set (0.04 sec) +25 rows in set (0.04 sec) ``` `backends()` tvf展示出来的信息基本与 `show backends` 语句展示出的信息一致,但是`backends()` tvf的各个字段类型更加明确,且可以利用tvf生成的表去做过滤、join等操作。 @@ -87,8 +86,7 @@ mysql> select * from backends()\G *************************** 1. row *************************** BackendId: 10022 Cluster: default_cluster - IP: 10.16.10.14 - HostName: 10.16.10.14 + Host: 10.16.10.14 HeartbeatPort: 9159 BePort: 9169 HttpPort: 8149 diff --git a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/BackendsTableValuedFunction.java b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/BackendsTableValuedFunction.java index 507f0ee93b..1598c144b9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/BackendsTableValuedFunction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/BackendsTableValuedFunction.java @@ -41,30 +41,29 @@ public class BackendsTableValuedFunction extends MetadataTableValuedFunction { private static final ImmutableMap COLUMN_TO_INDEX = new ImmutableMap.Builder() .put("backendid", 0) .put("cluster", 1) - .put("ip", 2) - .put("hostname", 3) - .put("heartbeatport", 4) - .put("beport", 5) - .put("httpport", 6) - .put("brpcport", 7) - .put("laststarttime", 8) - .put("lastheartbeat", 9) - .put("alive", 10) - .put("systemdecommissioned", 11) - .put("clusterdecommissioned", 12) - .put("tabletnum", 13) - .put("datausedcapacity", 14) - .put("availcapacity", 15) - .put("totalcapacity", 16) - .put("usedpct", 17) - .put("maxdiskusedpct", 18) - .put("remoteusedcapacity", 19) - .put("tag", 20) - .put("errmsg", 21) - .put("version", 22) - .put("status", 23) - .put("heartbeatfailurecounter", 24) - .put("noderole", 25) + .put("host", 2) + .put("heartbeatport", 3) + .put("beport", 4) + .put("httpport", 5) + .put("brpcport", 6) + .put("laststarttime", 7) + .put("lastheartbeat", 8) + .put("alive", 9) + .put("systemdecommissioned", 10) + .put("clusterdecommissioned", 11) + .put("tabletnum", 12) + .put("datausedcapacity", 13) + .put("availcapacity", 14) + .put("totalcapacity", 15) + .put("usedpct", 16) + .put("maxdiskusedpct", 17) + .put("remoteusedcapacity", 18) + .put("tag", 19) + .put("errmsg", 20) + .put("version", 21) + .put("status", 22) + .put("heartbeatfailurecounter", 23) + .put("noderole", 24) .build(); public static Integer getColumnIndexFromColumnName(String columnName) { @@ -102,8 +101,7 @@ public class BackendsTableValuedFunction extends MetadataTableValuedFunction { List resColumns = Lists.newArrayList(); resColumns.add(new Column("BackendId", ScalarType.createType(PrimitiveType.BIGINT))); resColumns.add(new Column("Cluster", ScalarType.createStringType())); - resColumns.add(new Column("IP", ScalarType.createStringType())); - resColumns.add(new Column("HostName", ScalarType.createStringType())); + resColumns.add(new Column("Host", ScalarType.createStringType())); resColumns.add(new Column("HeartbeatPort", ScalarType.createType(PrimitiveType.INT))); resColumns.add(new Column("BePort", ScalarType.createType(PrimitiveType.INT))); resColumns.add(new Column("HttpPort", ScalarType.createType(PrimitiveType.INT))); diff --git a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java index 86e1b70bf8..b53b35cde6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java @@ -168,11 +168,6 @@ public class MetadataGenerator { trow.addToColumnValue(new TCell().setLongVal(backendId)); trow.addToColumnValue(new TCell().setStringVal(backend.getOwnerClusterName())); trow.addToColumnValue(new TCell().setStringVal(backend.getHost())); - if (backend.getHost() != null) { - trow.addToColumnValue(new TCell().setStringVal(backend.getHost())); - } else { - trow.addToColumnValue(new TCell().setStringVal(backend.getHost())); - } if (Strings.isNullOrEmpty(backendsParam.cluster_name)) { trow.addToColumnValue(new TCell().setIntVal(backend.getHeartbeatPort())); trow.addToColumnValue(new TCell().setIntVal(backend.getBePort())); diff --git a/regression-test/suites/correctness_p0/table_valued_function/test_backends_tvf.groovy b/regression-test/suites/correctness_p0/table_valued_function/test_backends_tvf.groovy index a13ee3fec5..dc41ce2884 100644 --- a/regression-test/suites/correctness_p0/table_valued_function/test_backends_tvf.groovy +++ b/regression-test/suites/correctness_p0/table_valued_function/test_backends_tvf.groovy @@ -19,30 +19,30 @@ suite("test_backends_tvf") { List> table = sql """ select * from backends(); """ assertTrue(table.size() > 0) // row should > 0 - assertTrue(table[0].size == 26) // column should be 26 + assertTrue(table[0].size == 25) // column should be 25 // filter columns - table = sql """ select BackendId, HostName, Alive, TotalCapacity, Version, NodeRole from backends();""" + table = sql """ select BackendId, Host, Alive, TotalCapacity, Version, NodeRole from backends();""" assertTrue(table.size() > 0) // row should > 0 - assertTrue(table[0].size == 6) // column should be 26 + assertTrue(table[0].size == 6) // column should be 25 assertEquals(true, table[0][2]) // case insensitive - table = sql """ select backendid, Hostname, alive, Totalcapacity, version, nodeRole from backends();""" + table = sql """ select backendid, Host, alive, Totalcapacity, version, nodeRole from backends();""" assertTrue(table.size() > 0) // row should > 0 - assertTrue(table[0].size == 6) // column should be 26 + assertTrue(table[0].size == 6) // column should be 25 assertEquals(true, table[0][2]) // test aliase columns - table = sql """ select backendid as id, Hostname as name, alive, NodeRole as r from backends();""" + table = sql """ select backendid as id, Host as name, alive, NodeRole as r from backends();""" assertTrue(table.size() > 0) // row should > 0 - assertTrue(table[0].size == 4) // column should be 26 + assertTrue(table[0].size == 4) // column should be 25 assertEquals(true, table[0][2]) // test changing position of columns - table = sql """ select Hostname as name, NodeRole as r, alive, ip from backends();""" + table = sql """ select Host as name, NodeRole as r, alive from backends();""" assertTrue(table.size() > 0) // row should > 0 - assertTrue(table[0].size == 4) // column should be 26 + assertTrue(table[0].size == 3) // column should be 25 assertEquals(true, table[0][2]) def res = sql """ select count(*) from backends() where alive = 1; """ @@ -50,4 +50,12 @@ suite("test_backends_tvf") { res = sql """ select count(*) from backends() where alive = true; """ assertTrue(res[0][0] > 0) + + sql """ select BackendId, Cluster, Host, HeartbeatPort, + BePort, HttpPort, BrpcPort, LastStartTime, LastHeartbeat, Alive + SystemDecommissioned, ClusterDecommissioned, TabletNum + DataUsedCapacity, AvailCapacity, TotalCapacity, UsedPct + MaxDiskUsedPct, RemoteUsedCapacity, Tag, ErrMsg, Version, Status + HeartbeatFailureCounter, NodeRole from backends(); + """ } \ No newline at end of file diff --git a/regression-test/suites/nereids_syntax_p0/information_schema.groovy b/regression-test/suites/nereids_syntax_p0/information_schema.groovy index 06ab2d875a..c601e7b06c 100644 --- a/regression-test/suites/nereids_syntax_p0/information_schema.groovy +++ b/regression-test/suites/nereids_syntax_p0/information_schema.groovy @@ -18,7 +18,7 @@ suite("information_schema") { List> table = sql """ select * from backends(); """ assertTrue(table.size() > 0) // row should > 0 - assertTrue(table[0].size == 26) // column should be 26 + assertTrue(table[0].size == 25) // column should be 25 sql "SELECT DATABASE();" sql "select USER();"