use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by axbaretto.
the class BaseTestQuery method openClient.
private static void openClient(Properties properties) throws Exception {
if (properties == null) {
properties = new Properties();
}
allocator = RootAllocatorFactory.newRoot(config);
serviceSet = RemoteServiceSet.getLocalServiceSet();
dfsTestTmpSchemaLocation = TestUtilities.createTempDir();
bits = new Drillbit[drillbitCount];
for (int i = 0; i < drillbitCount; i++) {
bits[i] = new Drillbit(config, serviceSet, classpathScan);
bits[i].run();
final StoragePluginRegistry pluginRegistry = bits[i].getContext().getStorage();
TestUtilities.updateDfsTestTmpSchemaLocation(pluginRegistry, dfsTestTmpSchemaLocation);
TestUtilities.makeDfsTmpSchemaImmutable(pluginRegistry);
}
if (!properties.containsKey(DrillProperties.DRILLBIT_CONNECTION)) {
properties.setProperty(DrillProperties.DRILLBIT_CONNECTION, String.format("localhost:%s", bits[0].getUserPort()));
}
DrillConfig clientConfig = DrillConfig.forClient();
client = QueryTestUtil.createClient(clientConfig, serviceSet, MAX_WIDTH_PER_NODE, properties);
}
use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by axbaretto.
the class PlanningBase method testSqlPlan.
protected void testSqlPlan(String sqlCommands) throws Exception {
final DrillbitContext dbContext = mock(DrillbitContext.class);
final QueryContext context = mock(QueryContext.class);
final String[] sqlStrings = sqlCommands.split(";");
final LocalPersistentStoreProvider provider = new LocalPersistentStoreProvider(config);
provider.start();
final ScanResult scanResult = ClassPathScanner.fromPrescan(config);
final LogicalPlanPersistence logicalPlanPersistence = new LogicalPlanPersistence(config, scanResult);
final SystemOptionManager systemOptions = new SystemOptionManager(logicalPlanPersistence, provider, config);
systemOptions.init();
@SuppressWarnings("resource") final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(systemOptions).build();
final SessionOptionManager sessionOptions = userSession.getOptions();
final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions);
final ExecutionControls executionControls = new ExecutionControls(queryOptions, DrillbitEndpoint.getDefaultInstance());
when(dbContext.getMetrics()).thenReturn(new MetricRegistry());
when(dbContext.getAllocator()).thenReturn(allocator);
when(dbContext.getConfig()).thenReturn(config);
when(dbContext.getOptionManager()).thenReturn(systemOptions);
when(dbContext.getStoreProvider()).thenReturn(provider);
when(dbContext.getClasspathScan()).thenReturn(scanResult);
when(dbContext.getLpPersistence()).thenReturn(logicalPlanPersistence);
final StoragePluginRegistry registry = new StoragePluginRegistryImpl(dbContext);
registry.init();
final FunctionImplementationRegistry functionRegistry = new FunctionImplementationRegistry(config);
final DrillOperatorTable table = new DrillOperatorTable(functionRegistry, systemOptions);
final SchemaPlus root = CalciteSchema.createRootSchema(false, false).plus();
registry.getSchemaFactory().registerSchemas(SchemaConfig.newBuilder("foo", context).build(), root);
when(context.getNewDefaultSchema()).thenReturn(root);
when(context.getLpPersistence()).thenReturn(new LogicalPlanPersistence(config, ClassPathScanner.fromPrescan(config)));
when(context.getStorage()).thenReturn(registry);
when(context.getFunctionRegistry()).thenReturn(functionRegistry);
when(context.getSession()).thenReturn(UserSession.Builder.newBuilder().withOptionManager(sessionOptions).setSupportComplexTypes(true).build());
when(context.getCurrentEndpoint()).thenReturn(DrillbitEndpoint.getDefaultInstance());
when(context.getActiveEndpoints()).thenReturn(ImmutableList.of(DrillbitEndpoint.getDefaultInstance()));
when(context.getPlannerSettings()).thenReturn(new PlannerSettings(queryOptions, functionRegistry));
when(context.getOptions()).thenReturn(queryOptions);
when(context.getConfig()).thenReturn(config);
when(context.getDrillOperatorTable()).thenReturn(table);
when(context.getAllocator()).thenReturn(allocator);
when(context.getExecutionControls()).thenReturn(executionControls);
when(context.getLpPersistence()).thenReturn(logicalPlanPersistence);
for (final String sql : sqlStrings) {
if (sql.trim().isEmpty()) {
continue;
}
@SuppressWarnings("unused") final PhysicalPlan p = DrillSqlWorker.getPlan(context, sql);
}
}
use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by apache.
the class JdbcTestBase method updateSchemaLocations.
private static void updateSchemaLocations(Connection conn) {
if (conn instanceof DrillConnectionImpl) {
StoragePluginRegistry storage = DrillConnectionUtils.getStorage((DrillConnectionImpl) conn);
try {
StoragePluginTestUtils.configureFormatPlugins(storage);
StoragePluginTestUtils.updateSchemaLocation(StoragePluginTestUtils.DFS_PLUGIN_NAME, storage, dirTestWatcher.getDfsTestTmpDir(), StoragePluginTestUtils.TMP_SCHEMA);
StoragePluginTestUtils.updateSchemaLocation(StoragePluginTestUtils.DFS_PLUGIN_NAME, storage, dirTestWatcher.getRootDir(), StoragePluginTestUtils.ROOT_SCHEMA);
StoragePluginTestUtils.updateSchemaLocation(StoragePluginTestUtils.DFS_PLUGIN_NAME, storage, dirTestWatcher.getRootDir(), SchemaFactory.DEFAULT_WS_NAME);
} catch (StoragePluginRegistry.PluginException e) {
throw new RuntimeException(e);
}
}
}
use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by apache.
the class PlanningBase method testSqlPlan.
protected void testSqlPlan(String sqlCommands) throws Exception {
final DrillbitContext dbContext = mock(DrillbitContext.class);
final QueryContext context = mock(QueryContext.class);
final String[] sqlStrings = sqlCommands.split(";");
final LocalPersistentStoreProvider provider = new LocalPersistentStoreProvider(config);
provider.start();
final ScanResult scanResult = ClassPathScanner.fromPrescan(config);
final LogicalPlanPersistence logicalPlanPersistence = new LogicalPlanPersistence(config, scanResult);
final SystemOptionManager systemOptions = new SystemOptionManager(logicalPlanPersistence, provider, config);
systemOptions.init();
final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(systemOptions).build();
final SessionOptionManager sessionOptions = userSession.getOptions();
final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions);
final ExecutionControls executionControls = new ExecutionControls(queryOptions, DrillbitEndpoint.getDefaultInstance());
when(dbContext.getMetrics()).thenReturn(new MetricRegistry());
when(dbContext.getAllocator()).thenReturn(allocator);
when(dbContext.getConfig()).thenReturn(config);
when(dbContext.getOptionManager()).thenReturn(systemOptions);
when(dbContext.getStoreProvider()).thenReturn(provider);
when(dbContext.getClasspathScan()).thenReturn(scanResult);
when(dbContext.getLpPersistence()).thenReturn(logicalPlanPersistence);
final StoragePluginRegistry registry = new StoragePluginRegistryImpl(dbContext);
registry.init();
final FunctionImplementationRegistry functionRegistry = new FunctionImplementationRegistry(config);
final DrillOperatorTable table = new DrillOperatorTable(functionRegistry, systemOptions);
SchemaConfig schemaConfig = SchemaConfig.newBuilder("foo", context).build();
SchemaPlus root = DynamicSchema.createRootSchema(registry, schemaConfig, new AliasRegistryProvider(dbContext));
when(context.getNewDefaultSchema()).thenReturn(root);
when(context.getLpPersistence()).thenReturn(new LogicalPlanPersistence(config, ClassPathScanner.fromPrescan(config)));
when(context.getStorage()).thenReturn(registry);
when(context.getFunctionRegistry()).thenReturn(functionRegistry);
when(context.getSession()).thenReturn(UserSession.Builder.newBuilder().withOptionManager(sessionOptions).setSupportComplexTypes(true).build());
when(context.getCurrentEndpoint()).thenReturn(DrillbitEndpoint.getDefaultInstance());
when(context.getActiveEndpoints()).thenReturn(ImmutableList.of(DrillbitEndpoint.getDefaultInstance()));
when(context.getPlannerSettings()).thenReturn(new PlannerSettings(queryOptions, functionRegistry));
when(context.getOptions()).thenReturn(queryOptions);
when(context.getConfig()).thenReturn(config);
when(context.getDrillOperatorTable()).thenReturn(table);
when(context.getAllocator()).thenReturn(allocator);
when(context.getExecutionControls()).thenReturn(executionControls);
when(context.getLpPersistence()).thenReturn(logicalPlanPersistence);
// mocks for org.apache.drill.TestTpchPlanning#tpch06 test.
// With changes for decimal types, subtract udf for decimals is used.
when(context.getManagedBuffer()).thenReturn(allocator.buffer(4));
when(context.getConstantValueHolder(eq("0.03"), eq(TypeProtos.MinorType.VARDECIMAL), Matchers.<Function<DrillBuf, ValueHolder>>any())).thenReturn(ValueHolderHelper.getVarDecimalHolder(allocator.buffer(4), "0.03"));
when(context.getConstantValueHolder(eq("0.01"), eq(TypeProtos.MinorType.VARDECIMAL), Matchers.<Function<DrillBuf, ValueHolder>>any())).thenReturn(ValueHolderHelper.getVarDecimalHolder(allocator.buffer(4), "0.01"));
when(context.getOption(anyString())).thenCallRealMethod();
for (final String sql : sqlStrings) {
if (sql.trim().isEmpty()) {
continue;
}
@SuppressWarnings("unused") final PhysicalPlan p = DrillSqlWorker.getPlan(context, sql);
}
}
use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by apache.
the class BaseTestImpersonation method addMiniDfsBasedStorage.
protected static void addMiniDfsBasedStorage(final Map<String, WorkspaceConfig> workspaces) throws Exception {
// Create a HDFS based storage plugin based on local storage plugin and add it to plugin registry (connection string
// for mini dfs is varies for each run).
StoragePluginRegistry pluginRegistry = getDrillbitContext().getStorage();
FileSystemConfig lfsPluginConfig = (FileSystemConfig) pluginRegistry.getPlugin("dfs").getConfig();
String connection = dfsConf.get(FileSystem.FS_DEFAULT_NAME_KEY);
createAndAddWorkspace("tmp", "/tmp", (short) 0777, processUser, processUser, workspaces);
FileSystemConfig miniDfsPluginConfig = new FileSystemConfig(connection, null, workspaces, lfsPluginConfig.getFormats(), null);
miniDfsPluginConfig.setEnabled(true);
pluginRegistry.put(MINI_DFS_STORAGE_PLUGIN_NAME, miniDfsPluginConfig);
}
Aggregations