[chore](show) support statement to show views from table (#32358)
MySQL [test]> show views; +----------------+ | Tables_in_test | +----------------+ | t1_view | | t2_view | +----------------+ 2 rows in set (0.00 sec) MySQL [test]> show views like '%t1%'; +----------------+ | Tables_in_test | +----------------+ | t1_view | +----------------+ 1 row in set (0.01 sec) MySQL [test]> show views where create_time > '2024-03-18'; +----------------+ | Tables_in_test | +----------------+ | t2_view | +----------------+ 1 row in set (0.02 sec)
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.doris.analysis;
|
||||
|
||||
import org.apache.doris.catalog.TableIf.TableType;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.mysql.privilege.AccessControllerManager;
|
||||
import org.apache.doris.mysql.privilege.MockedAuth;
|
||||
@ -68,6 +69,28 @@ public class ShowTableStmtTest {
|
||||
Assert.assertEquals("Table_type", stmt.getMetaData().getColumn(1).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowViews() throws AnalysisException {
|
||||
ShowTableStmt stmt = new ShowTableStmt("", null, false, TableType.VIEW,
|
||||
null, null);
|
||||
stmt.analyze(analyzer);
|
||||
Assert.assertEquals("SHOW VIEWS FROM internal.testDb", stmt.toString());
|
||||
Assert.assertEquals("testDb", stmt.getDb());
|
||||
Assert.assertEquals(TableType.VIEW, stmt.getType());
|
||||
Assert.assertFalse(stmt.isVerbose());
|
||||
Assert.assertEquals(1, stmt.getMetaData().getColumnCount());
|
||||
Assert.assertEquals("Tables_in_testDb", stmt.getMetaData().getColumn(0).getName());
|
||||
|
||||
stmt = new ShowTableStmt("abc", null, true, TableType.VIEW, "bcd", null);
|
||||
stmt.analyze(analyzer);
|
||||
Assert.assertEquals("bcd", stmt.getPattern());
|
||||
Assert.assertEquals("SHOW FULL VIEWS FROM internal.abc LIKE 'bcd'", stmt.toString());
|
||||
Assert.assertEquals(4, stmt.getMetaData().getColumnCount());
|
||||
Assert.assertEquals("Tables_in_abc", stmt.getMetaData().getColumn(0).getName());
|
||||
Assert.assertEquals("Table_type", stmt.getMetaData().getColumn(1).getName());
|
||||
Assert.assertEquals(TableType.VIEW, stmt.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoDb() {
|
||||
ShowTableStmt stmt = new ShowTableStmt("", null, false, null);
|
||||
|
||||
@ -324,6 +324,16 @@ public class ShowExecutorTest {
|
||||
Assert.assertFalse(resultSet.next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowViews() throws AnalysisException {
|
||||
ShowTableStmt stmt = new ShowTableStmt("testDb", null, false, TableType.VIEW,
|
||||
null, null);
|
||||
ShowExecutor executor = new ShowExecutor(ctx, stmt);
|
||||
ShowResultSet resultSet = executor.execute();
|
||||
|
||||
Assert.assertFalse(resultSet.next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowTableFromCatalog() throws AnalysisException {
|
||||
ShowTableStmt stmt = new ShowTableStmt("testDb", "internal", false, null);
|
||||
|
||||
Reference in New Issue
Block a user