예제 #1
0
  @Test
  public void test(final DrillbitContext bitContext) throws Exception {
    final DrillConfig c = DrillConfig.create();

    new NonStrictExpectations() {
      {
        bitContext.getMetrics();
        result = new MetricRegistry();
        bitContext.getAllocator();
        result = new TopLevelAllocator();
        bitContext.getConfig();
        result = c;
        bitContext.getCache();
        result = new LocalCache();
      }
    };

    bitContext.getCache().run();

    StoragePluginRegistry r = new StoragePluginRegistry(bitContext);
    SchemaPlus plus = Frameworks.createRootSchema();
    r.init();
    r.getSchemaFactory().registerSchemas(null, plus);

    printSchema(plus, 0);
  }
예제 #2
0
 /**
  * Initializes a container then calls user-specified code with a planner.
  *
  * @param action Callback containing user-specified code
  * @return Return value from action
  */
 public static <R> R withPlanner(final PlannerAction<R> action) {
   FrameworkConfig config =
       newConfigBuilder() //
           .defaultSchema(Frameworks.createRootSchema(true))
           .build();
   return withPlanner(action, config);
 }
예제 #3
0
  protected void testSqlPlan(String sqlCommands) throws Exception {
    String[] sqlStrings = sqlCommands.split(";");

    final DistributedCache cache = new LocalCache();
    cache.run();

    final SystemOptionManager opt = new SystemOptionManager(cache);
    opt.init();
    final OptionManager sess = new SessionOptionManager(opt);

    new NonStrictExpectations() {
      {
        dbContext.getMetrics();
        result = new MetricRegistry();
        dbContext.getAllocator();
        result = new TopLevelAllocator();
        dbContext.getConfig();
        result = config;
        dbContext.getOptionManager();
        result = opt;
        dbContext.getCache();
        result = cache;
      }
    };

    final StoragePluginRegistry registry = new StoragePluginRegistry(dbContext);
    registry.init();
    final FunctionImplementationRegistry functionRegistry =
        new FunctionImplementationRegistry(config);
    final SchemaPlus root = Frameworks.createRootSchema(false);
    registry.getSchemaFactory().registerSchemas(new UserSession(null, null, null), root);

    new NonStrictExpectations() {
      {
        context.getNewDefaultSchema();
        result = root;
        context.getStorage();
        result = registry;
        context.getFunctionRegistry();
        result = functionRegistry;
        context.getSession();
        result = new UserSession(null, null, null);
        context.getCurrentEndpoint();
        result = DrillbitEndpoint.getDefaultInstance();
        context.getActiveEndpoints();
        result = ImmutableList.of(DrillbitEndpoint.getDefaultInstance());
        context.getPlannerSettings();
        result = new PlannerSettings(sess);
        context.getOptions();
        result = sess;
        context.getConfig();
        result = config;
        context.getCache();
        result = cache;
      }
    };

    for (String sql : sqlStrings) {
      if (sql.trim().isEmpty()) continue;
      DrillSqlWorker worker = new DrillSqlWorker(context);
      PhysicalPlan p = worker.getPlan(sql);
    }
  }
예제 #4
0
 public PrepareAction() {
   this.config =
       newConfigBuilder() //
           .defaultSchema(Frameworks.createRootSchema(true))
           .build();
 }