Search in sources :

Example 21 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class TestBootstrapLoader method testBootstrapLoaderWithUpgrades.

@Test
public void testBootstrapLoaderWithUpgrades() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    String bootstrapFile = RESOURCE_BASE + "mock-plugin-upgrade.json";
    builder.configBuilder().put(ExecConstants.UPGRADE_STORAGE_PLUGINS_FILE, bootstrapFile);
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        PluginBootstrapLoader loader = new PluginBootstrapLoaderImpl(context);
        StoragePlugins plugins = loader.bootstrapPlugins();
        // dfs: removed psv
        StoragePluginConfig pluginConfig = plugins.getConfig("dfs");
        assertNotNull(pluginConfig);
        FileSystemConfig dfs = (FileSystemConfig) pluginConfig;
        assertNull(dfs.getFormats().get("psv"));
        assertNotNull(dfs.getFormats().get("csv"));
        // local added
        assertNotNull(plugins.getConfig("local"));
        // S3, bsv added
        pluginConfig = plugins.getConfig("s3");
        assertNotNull(pluginConfig);
        FileSystemConfig s3 = (FileSystemConfig) pluginConfig;
        assertNotNull(s3.getFormats().get("bsv"));
        // cp, left unchanged (not in upgrade file)
        assertNotNull(plugins.getConfig("cp"));
    }
}
Also used : StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Example 22 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class TestBootstrapLoader method testBootstrapUpgrades.

@Test
public void testBootstrapUpgrades() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    String bootstrapFile = RESOURCE_BASE + "mock-plugin-upgrade.json";
    builder.configBuilder().put(ExecConstants.UPGRADE_STORAGE_PLUGINS_FILE, bootstrapFile);
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        PluginBootstrapLoader loader = new PluginBootstrapLoaderImpl(context);
        StoragePlugins plugins = loader.updatedPlugins();
        assertNotNull(plugins);
        // dfs: removed psv
        StoragePluginConfig pluginConfig = plugins.getConfig("dfs");
        assertNotNull(pluginConfig);
        FileSystemConfig dfs = (FileSystemConfig) pluginConfig;
        assertNull(dfs.getFormats().get("psv"));
        assertNotNull(dfs.getFormats().get("csv"));
        // local added
        assertNotNull(plugins.getConfig("local"));
        // S3, bsv added
        pluginConfig = plugins.getConfig("s3");
        assertNotNull(pluginConfig);
        FileSystemConfig s3 = (FileSystemConfig) pluginConfig;
        assertNotNull(s3.getFormats().get("bsv"));
        // cp, left unchanged (not in upgrade file)
        assertNull(plugins.getConfig("cp"));
    }
}
Also used : StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Example 23 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class TestClassicLocator method testClassList.

@Test
public void testClassList() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    // builder.configBuilder().put(ClassPathScanner.IMPLEMENTATIONS_SCAN_CACHE, false);
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        ConnectorLocator locator = new ClassicConnectorLocator(context);
        locator.init();
        Set<Class<? extends StoragePluginConfig>> result = locator.configClasses();
        // Sanity check of known good class
        assertTrue(result.contains(FileSystemConfig.class));
        // System plugins do not appear
        assertFalse(result.contains(SystemTablePluginConfig.class));
        // Abstract classes do not appear
        assertFalse(result.contains(StoragePluginConfig.class));
        assertFalse(result.contains(AbstractSecuredStoragePluginConfig.class));
        // The private plugin class does not appear
        assertFalse(result.contains(StoragePluginFixtureConfig.class));
        // No intrinsic plugins
        assertNull(locator.get("dfs"));
        assertNull(locator.intrinsicPlugins());
        // Storable
        assertTrue(locator.storable());
        // Lookup by config
        assertSame(FileSystemPlugin.class, locator.connectorClassFor(FileSystemConfig.class));
        assertNull(locator.connectorClassFor(StoragePluginFixtureConfig.class));
        // No-op
        locator.close();
    }
}
Also used : SystemTablePluginConfig(org.apache.drill.exec.store.sys.SystemTablePluginConfig) AbstractSecuredStoragePluginConfig(org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) AbstractSecuredStoragePluginConfig(org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig) Test(org.junit.Test)

Example 24 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class JdbcDataTest method testProjectPlan.

/**
 * Checks the logical plan.
 */
@Test
public void testProjectPlan() throws Exception {
    LogicalPlan plan = withModel(MODEL, "DONUTS").sql("select _MAP['ppu'] as ppu from donuts").logicalPlan();
    PlanProperties planProperties = plan.getProperties();
    Assert.assertEquals("optiq", planProperties.generator.type);
    Assert.assertEquals("na", planProperties.generator.info);
    Assert.assertEquals(1, planProperties.version);
    Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
    StoragePluginConfig config = seConfigs.get("donuts-json");
    // Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
    config = seConfigs.get("queue");
    // Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
    Scan scan = findOnlyOperator(plan, Scan.class);
    Assert.assertEquals("donuts-json", scan.getStorageEngine());
    Project project = findOnlyOperator(plan, Project.class);
    Assert.assertEquals(1, project.getSelections().size());
    Assert.assertEquals(Scan.class, project.getInput().getClass());
    Store store = findOnlyOperator(plan, Store.class);
    Assert.assertEquals("queue", store.getStorageEngine());
    Assert.assertEquals("output sink", store.getMemo());
    Assert.assertEquals(Project.class, store.getInput().getClass());
}
Also used : Project(org.apache.drill.common.logical.data.Project) PlanProperties(org.apache.drill.common.logical.PlanProperties) Store(org.apache.drill.common.logical.data.Store) LogicalPlan(org.apache.drill.common.logical.LogicalPlan) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) Scan(org.apache.drill.common.logical.data.Scan) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 25 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class JdbcDataTest method testProjectFilterSubqueryPlan.

@Test
public void testProjectFilterSubqueryPlan() throws Exception {
    LogicalPlan plan = withModel(MODEL, "DONUTS").sql("select d['name'] as name, d['xx'] as xx from (\n" + " select _MAP['donuts'] as d from donuts)\n" + "where cast(d['ppu'] as double) > 0.6").logicalPlan();
    PlanProperties planProperties = plan.getProperties();
    Assert.assertEquals("optiq", planProperties.generator.type);
    Assert.assertEquals("na", planProperties.generator.info);
    Assert.assertEquals(1, planProperties.version);
    Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
    StoragePluginConfig config = seConfigs.get("donuts-json");
    // Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
    config = seConfigs.get("queue");
    // Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
    Scan scan = findOnlyOperator(plan, Scan.class);
    Assert.assertEquals("donuts-json", scan.getStorageEngine());
    Filter filter = findOnlyOperator(plan, Filter.class);
    Assert.assertTrue(filter.getInput() instanceof Scan);
    Project[] projects = Iterables.toArray(findOperator(plan, Project.class), Project.class);
    Assert.assertEquals(2, projects.length);
    Assert.assertEquals(1, projects[0].getSelections().size());
    Assert.assertEquals(Filter.class, projects[0].getInput().getClass());
    Assert.assertEquals(2, projects[1].getSelections().size());
    Assert.assertEquals(Project.class, projects[1].getInput().getClass());
    Store store = findOnlyOperator(plan, Store.class);
    Assert.assertEquals("queue", store.getStorageEngine());
    Assert.assertEquals("output sink", store.getMemo());
    Assert.assertEquals(Project.class, store.getInput().getClass());
}
Also used : Project(org.apache.drill.common.logical.data.Project) PlanProperties(org.apache.drill.common.logical.PlanProperties) Filter(org.apache.drill.common.logical.data.Filter) Store(org.apache.drill.common.logical.data.Store) LogicalPlan(org.apache.drill.common.logical.LogicalPlan) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) Scan(org.apache.drill.common.logical.data.Scan) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Aggregations

StoragePluginConfig (org.apache.drill.common.logical.StoragePluginConfig)28 Test (org.junit.Test)15 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)12 StoragePlugins (org.apache.drill.exec.planner.logical.StoragePlugins)9 OperatorFixture (org.apache.drill.test.OperatorFixture)6 BaseTest (org.apache.drill.test.BaseTest)5 ClusterFixture (org.apache.drill.test.ClusterFixture)5 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)5 HashMap (java.util.HashMap)4 JdbcTest (org.apache.drill.categories.JdbcTest)4 LogicalPlan (org.apache.drill.common.logical.LogicalPlan)4 PlanProperties (org.apache.drill.common.logical.PlanProperties)4 Project (org.apache.drill.common.logical.data.Project)4 Scan (org.apache.drill.common.logical.data.Scan)4 Store (org.apache.drill.common.logical.data.Store)4 InfoSchemaStoragePlugin (org.apache.drill.exec.store.ischema.InfoSchemaStoragePlugin)4 IOException (java.io.IOException)3 Map (java.util.Map)3 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)3 PluginException (org.apache.drill.exec.store.StoragePluginRegistry.PluginException)3