@@ -54,7 +54,30 @@ public class SysTablesTests extends ESTestCase {
5454 //
5555 // catalog enumeration
5656 //
57- public void testSysTablesCatalogEnumeration () throws Exception {
57+ public void testSysTablesCatalogEnumerationWithEmptyType () throws Exception {
58+ executeCommand ("SYS TABLES CATALOG LIKE '%' LIKE '' TYPE ''" , r -> {
59+ assertEquals (1 , r .size ());
60+ assertEquals (CLUSTER_NAME , r .column (0 ));
61+ // everything else should be null
62+ for (int i = 1 ; i < 10 ; i ++) {
63+ assertNull (r .column (i ));
64+ }
65+ }, index );
66+ }
67+
68+ public void testSysTablesCatalogAllTypes () throws Exception {
69+ executeCommand ("SYS TABLES CATALOG LIKE '%' LIKE '' TYPE '%'" , r -> {
70+ assertEquals (1 , r .size ());
71+ assertEquals (CLUSTER_NAME , r .column (0 ));
72+ // everything else should be null
73+ for (int i = 1 ; i < 10 ; i ++) {
74+ assertNull (r .column (i ));
75+ }
76+ }, new IndexInfo [0 ]);
77+ }
78+
79+ // when types are null, consider them equivalent to '' for compatibility reasons
80+ public void testSysTablesCatalogNoTypes () throws Exception {
5881 executeCommand ("SYS TABLES CATALOG LIKE '%' LIKE ''" , r -> {
5982 assertEquals (1 , r .size ());
6083 assertEquals (CLUSTER_NAME , r .column (0 ));
@@ -65,24 +88,18 @@ public void testSysTablesCatalogEnumeration() throws Exception {
6588 }, index );
6689 }
6790
91+
6892 //
6993 // table types enumeration
7094 //
95+
96+ // missing type means pattern
7197 public void testSysTablesTypesEnumerationWoString () throws Exception {
7298 executeCommand ("SYS TABLES CATALOG LIKE '' LIKE '' " , r -> {
7399 assertEquals (2 , r .size ());
74100 assertEquals ("BASE TABLE" , r .column (3 ));
75101 assertTrue (r .advanceRow ());
76102 assertEquals ("VIEW" , r .column (3 ));
77- }, new IndexInfo [0 ]);
78- }
79-
80- public void testSysTablesEnumerateTypes () throws Exception {
81- executeCommand ("SYS TABLES CATALOG LIKE '' LIKE '' TYPE '%'" , r -> {
82- assertEquals (2 , r .size ());
83- assertEquals ("BASE TABLE" , r .column (3 ));
84- assertTrue (r .advanceRow ());
85- assertEquals ("VIEW" , r .column (3 ));
86103 }, alias , index );
87104 }
88105
@@ -107,6 +124,13 @@ public void testSysTablesTypesEnumeration() throws Exception {
107124 }, new IndexInfo [0 ]);
108125 }
109126
127+ // when a type is specified, apply filtering
128+ public void testSysTablesTypesEnumerationAllCatalogsAndSpecifiedView () throws Exception {
129+ executeCommand ("SYS TABLES CATALOG LIKE '%' LIKE '' TYPE 'VIEW'" , r -> {
130+ assertEquals (0 , r .size ());
131+ }, new IndexInfo [0 ]);
132+ }
133+
110134 public void testSysTablesDifferentCatalog () throws Exception {
111135 executeCommand ("SYS TABLES CATALOG LIKE 'foo'" , r -> {
112136 assertEquals (0 , r .size ());
@@ -262,6 +286,12 @@ public void testSysTablesWithCatalogOnlyAliases() throws Exception {
262286 }, alias );
263287 }
264288
289+ public void testSysTablesWithEmptyCatalogOnlyAliases () throws Exception {
290+ executeCommand ("SYS TABLES CATALOG LIKE '' LIKE 'test' TYPE 'VIEW'" , r -> {
291+ assertEquals (0 , r .size ());
292+ }, alias );
293+ }
294+
265295 public void testSysTablesWithInvalidType () throws Exception {
266296 executeCommand ("SYS TABLES LIKE 'test' TYPE 'QUE HORA ES'" , r -> {
267297 assertEquals (0 , r .size ());
0 commit comments