Search in sources :

Example 1 with SqlSchemaView

use of org.apache.ignite.spi.systemview.view.SqlSchemaView in project ignite by apache.

the class SqlViewExporterSpiTest method testSchemas.

/**
 */
@Test
public void testSchemas() throws Exception {
    try (IgniteEx g = startGrid(new IgniteConfiguration().setSqlConfiguration(new SqlConfiguration().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.schemaName()));
        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);
    }
}
Also used : SqlConfiguration(org.apache.ignite.configuration.SqlConfiguration) SqlSchemaView(org.apache.ignite.spi.systemview.view.SqlSchemaView) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AbstractExporterSpiTest(org.apache.ignite.internal.metric.AbstractExporterSpiTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 SqlConfiguration (org.apache.ignite.configuration.SqlConfiguration)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 AbstractExporterSpiTest (org.apache.ignite.internal.metric.AbstractExporterSpiTest)1 SqlSchemaView (org.apache.ignite.spi.systemview.view.SqlSchemaView)1 Test (org.junit.Test)1