[fix](tvf) To fix the bug that requires adding backticks on "frontends()" in order to query the frontends TVF. (#21338)
This commit is contained in:
@ -7624,6 +7624,8 @@ keyword ::=
|
||||
{: RESULT = id; :}
|
||||
| KW_FEATURE:id
|
||||
{: RESULT = id; :}
|
||||
| KW_FRONTENDS:id
|
||||
{: RESULT = id; :}
|
||||
| KW_MAP:id
|
||||
{: RESULT = id; :}
|
||||
| KW_VARCHAR:id
|
||||
|
||||
@ -32,14 +32,14 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Implement of table valued function
|
||||
* backends().
|
||||
* frontends().
|
||||
*/
|
||||
public class FrontendsTableValuedFunction extends MetadataTableValuedFunction {
|
||||
public static final String NAME = "frontends";
|
||||
|
||||
private static final ImmutableList<Column> SCHEMA = ImmutableList.of(
|
||||
new Column("Name", ScalarType.createStringType()),
|
||||
new Column("HOST", ScalarType.createStringType()),
|
||||
new Column("Host", ScalarType.createStringType()),
|
||||
new Column("EditLogPort", ScalarType.createStringType()),
|
||||
new Column("HttpPort", ScalarType.createStringType()),
|
||||
new Column("QueryPort", ScalarType.createStringType()),
|
||||
|
||||
@ -25,4 +25,26 @@ suite("test_frontends_tvf") {
|
||||
table = sql """ select Name from `frontends`();"""
|
||||
assertTrue(table.size() > 0)
|
||||
assertTrue(table[0].size == 1)
|
||||
|
||||
// case insensitive
|
||||
table = sql """ select name, host, editlogport, httpport, alive from frontends();"""
|
||||
assertTrue(table.size() > 0)
|
||||
assertTrue(table[0].size == 5)
|
||||
assertEquals("true", table[0][4])
|
||||
|
||||
// test aliase columns
|
||||
table = sql """ select name as n, host as h, alive as a, editlogport as e from frontends(); """
|
||||
assertTrue(table.size() > 0)
|
||||
assertTrue(table[0].size == 4)
|
||||
assertEquals("true", table[0][2])
|
||||
|
||||
// test changing position of columns
|
||||
def res = sql """ select count(*) from frontends() where alive = 'true'; """
|
||||
assertTrue(res[0][0] > 0)
|
||||
|
||||
sql """ select Name, Host, EditLogPort
|
||||
HttpPort, QueryPort, RpcPort, `Role`, IsMaster, ClusterId
|
||||
`Join`, Alive, ReplayedJournalId, LastHeartbeat
|
||||
IsHelper, ErrMsg, Version, CurrentConnected from frontends();
|
||||
"""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user