Search in sources :

Example 6 with FileSystemConfig

use of org.apache.drill.exec.store.dfs.FileSystemConfig in project drill by apache.

the class TestCTTAS method init.

@BeforeClass
public static void init() throws Exception {
    MockUp<UUID> uuidMockUp = mockRandomUUID(session_id);
    Properties testConfigurations = cloneDefaultTestConfigProperties();
    testConfigurations.put(ExecConstants.DEFAULT_TEMPORARY_WORKSPACE, TEMP_SCHEMA);
    updateTestCluster(1, DrillConfig.create(testConfigurations));
    uuidMockUp.tearDown();
    StoragePluginRegistry pluginRegistry = getDrillbitContext().getStorage();
    FileSystemConfig pluginConfig = (FileSystemConfig) pluginRegistry.getPlugin(test_schema).getConfig();
    pluginConfig.workspaces.put(temp2_wk, new WorkspaceConfig(TestUtilities.createTempDir(), true, null));
    pluginRegistry.createOrUpdate(test_schema, pluginConfig, true);
    fs = FileSystem.get(new Configuration());
    expectedFolderPermission = new FsPermission(StorageStrategy.TEMPORARY.getFolderPermission());
    expectedFilePermission = new FsPermission(StorageStrategy.TEMPORARY.getFilePermission());
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) Configuration(org.apache.hadoop.conf.Configuration) WorkspaceConfig(org.apache.drill.exec.store.dfs.WorkspaceConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) FsPermission(org.apache.hadoop.fs.permission.FsPermission) UUID(java.util.UUID) Properties(java.util.Properties) BeforeClass(org.junit.BeforeClass)

Example 7 with FileSystemConfig

use of org.apache.drill.exec.store.dfs.FileSystemConfig in project drill by apache.

the class TestInfoSchema method describeSchemaOutput.

@Test
public void describeSchemaOutput() throws Exception {
    final List<QueryDataBatch> result = testSqlWithResults("describe schema dfs_test.tmp");
    assertTrue(result.size() == 1);
    final QueryDataBatch batch = result.get(0);
    final RecordBatchLoader loader = new RecordBatchLoader(getDrillbitContext().getAllocator());
    loader.load(batch.getHeader().getDef(), batch.getData());
    // check schema column value
    final VectorWrapper schemaValueVector = loader.getValueAccessorById(NullableVarCharVector.class, loader.getValueVectorId(SchemaPath.getCompoundPath("schema")).getFieldIds());
    String schema = schemaValueVector.getValueVector().getAccessor().getObject(0).toString();
    assertEquals("dfs_test.tmp", schema);
    // check properties column value
    final VectorWrapper propertiesValueVector = loader.getValueAccessorById(NullableVarCharVector.class, loader.getValueVectorId(SchemaPath.getCompoundPath("properties")).getFieldIds());
    String properties = propertiesValueVector.getValueVector().getAccessor().getObject(0).toString();
    final Map configMap = mapper.readValue(properties, Map.class);
    // check some stable properties existence
    assertTrue(configMap.containsKey("connection"));
    assertTrue(configMap.containsKey("config"));
    assertTrue(configMap.containsKey("formats"));
    assertFalse(configMap.containsKey("workspaces"));
    // check some stable properties values
    assertEquals("file", configMap.get("type"));
    final FileSystemConfig testConfig = (FileSystemConfig) bits[0].getContext().getStorage().getPlugin("dfs_test").getConfig();
    final String tmpSchemaLocation = testConfig.workspaces.get("tmp").getLocation();
    assertEquals(tmpSchemaLocation, configMap.get("location"));
    batch.release();
    loader.clear();
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) VectorWrapper(org.apache.drill.exec.record.VectorWrapper) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) Map(java.util.Map) Test(org.junit.Test)

Aggregations

FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)7 WorkspaceConfig (org.apache.drill.exec.store.dfs.WorkspaceConfig)4 StoragePluginRegistry (org.apache.drill.exec.store.StoragePluginRegistry)3 FileSystemPlugin (org.apache.drill.exec.store.dfs.FileSystemPlugin)3 Map (java.util.Map)1 Properties (java.util.Properties)1 UUID (java.util.UUID)1 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)1 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)1 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)1 Configuration (org.apache.hadoop.conf.Configuration)1 FsPermission (org.apache.hadoop.fs.permission.FsPermission)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1