nizhikov commented on a change in pull request #6916: IGNITE-12213: Sql objects
system views.
URL: https://github.com/apache/ignite/pull/6916#discussion_r331011769
##########
File path:
modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/metric/SqlViewExporterSpiTest.java
##########
@@ -332,6 +339,162 @@ public void testTransactions() throws Exception {
assertTrue(res);
}
+ /** */
+ @Test
+ public void testSchemas() throws Exception {
+ try (IgniteEx g = startGrid(new
IgniteConfiguration().setSqlSchemas("MY_SCHEMA", "ANOTHER_SCHEMA"))) {
+ SystemView<SqlSchemaView> schemasSysView =
g.context().systemView().view(SQL_SCHEMA_VIEW);
+
+ Set<String> schemaFromSysView = new HashSet<>();
+
+ schemasSysView.forEach(v -> schemaFromSysView.add(v.name()));
+
+ HashSet<String> expSchemas = new HashSet<>(asList("MY_SCHEMA",
"ANOTHER_SCHEMA", "SYS", "PUBLIC"));
+
+ assertEquals(schemaFromSysView, expSchemas);
+
+ List<List<?>> schemas = execute(g, "SELECT * FROM SYS.SCHEMAS");
+
+ schemaFromSysView.clear();
+ schemas.forEach(s -> schemaFromSysView.add(s.get(0).toString()));
+
+ assertEquals(schemaFromSysView, expSchemas);
+ }
+ }
+
+ /** */
+ @Test
+ public void testViews() throws Exception {
+ Set<String> expViews = new HashSet<>(asList(
+ "METRICS",
+ "SERVICES",
+ "CACHE_GROUPS",
+ "CACHES",
+ "TASKS",
+ "LOCAL_SQL_QUERY_HISTORY",
+ "NODES",
+ "SCHEMAS",
+ "NODE_METRICS",
+ "BASELINE_NODES",
+ "INDEXES",
+ "LOCAL_CACHE_GROUPS_IO",
+ "LOCAL_SQL_RUNNING_QUERIES",
+ "NODE_ATTRIBUTES",
+ "TABLES",
+ "CLIENT_CONNECTIONS",
+ "VIEWS",
+ "TABLE_COLUMNS",
+ "VIEW_COLUMNS",
+ "TRANSACTIONS"
+ ));
+
+ Set<String> actViews = new HashSet<>();
+
+ List<List<?>> res = execute(ignite, "SELECT * FROM SYS.VIEWS");
+
+ for (List<?> row : res)
+ actViews.add(row.get(0).toString());
+
+ assertEquals(expViews, actViews);
+ }
+
+ /** */
+ @Test
+ public void testTable() throws Exception {
+ assertTrue(execute(ignite, "SELECT * FROM SYS.TABLES").isEmpty());
+
+ execute(ignite, "CREATE TABLE T1(ID LONG PRIMARY KEY, NAME VARCHAR)");
+
+ List<List<?>> res = execute(ignite, "SELECT * FROM SYS.TABLES");
+
+ assertEquals(1, res.size());
+
+ List tbl = res.get(0);
+
+ int cacheId = cacheId("SQL_PUBLIC_T1");
+ String cacheName = "SQL_PUBLIC_T1";
+
+ assertEquals("T1", tbl.get(0)); //TABLE_NAME
Review comment:
Fixed
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services