ahmedabu98 commented on code in PR #36509:
URL: https://github.com/apache/beam/pull/36509#discussion_r2543108274


##########
sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlCliCatalogTest.java:
##########
@@ -330,4 +332,59 @@ public void 
testCreateWriteDropTableWithOtherCatalogScope() {
     cli.execute("DROP TABLE catalog_1.db_1.person");
     assertNull(metastoreDb1.getTable("person"));
   }
+
+  @Test
+  public void testShowCurrentCatalog() {
+    cli.execute("CREATE CATALOG my_catalog TYPE 'local'");
+    cli.execute("CREATE CATALOG my_very_long_catalog_name TYPE 'local'");
+    ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
+    System.setOut(new PrintStream(outputStreamCaptor));
+    cli.execute("SHOW CURRENT CATALOG");
+    @SuppressWarnings("DefaultCharset")
+    String printOutput = outputStreamCaptor.toString().trim();
+
+    assertEquals("default (type: local)", printOutput);
+  }
+
+  @Test
+  public void testShowCatalogs() {
+    cli.execute("CREATE CATALOG my_catalog TYPE 'local'");
+    cli.execute("CREATE CATALOG my_very_long_catalog_name TYPE 'local'");
+    ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
+    System.setOut(new PrintStream(outputStreamCaptor));
+    cli.execute("SHOW CATALOGS");
+    @SuppressWarnings("DefaultCharset")
+    String printOutput = outputStreamCaptor.toString().trim();
+
+    assertEquals(
+        "+---------------------------------------+\n"
+            + "| Catalog Name                | Type    |\n"
+            + "+---------------------------------------+\n"
+            + "| default                     | local   |\n"
+            + "| my_catalog                  | local   |\n"
+            + "| my_very_long_catalog_name   | local   |\n"
+            + "+---------------------------------------+",
+        printOutput);
+  }
+
+  @Test
+  public void testShowCatalogsWithPattern() {
+    cli.execute("CREATE CATALOG my_catalog TYPE 'local'");
+    cli.execute("CREATE CATALOG my_very_long_catalog_name TYPE 'local'");
+    ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
+    System.setOut(new PrintStream(outputStreamCaptor));
+    cli.execute("SHOW CATALOGS");
+    @SuppressWarnings("DefaultCharset")
+    String printOutput = outputStreamCaptor.toString().trim();
+
+    assertEquals(
+        "+---------------------------------------+\n"
+            + "| Catalog Name                | Type    |\n"
+            + "+---------------------------------------+\n"
+            + "| default                     | local   |\n"
+            + "| my_catalog                  | local   |\n"
+            + "| my_very_long_catalog_name   | local   |\n"
+            + "+---------------------------------------+",
+        printOutput);
+  }

Review Comment:
   good bot



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to