use of org.apache.calcite.schema.SchemaPlus in project druid by druid-io.
the class SqlResourceTest method setUp.
@Before
public void setUp() throws Exception {
Calcites.setSystemProperties();
walker = CalciteTests.createMockWalker(temporaryFolder.newFolder());
final PlannerConfig plannerConfig = new PlannerConfig();
final SchemaPlus rootSchema = Calcites.createRootSchema(CalciteTests.createMockSchema(walker, plannerConfig));
final DruidOperatorTable operatorTable = CalciteTests.createOperatorTable();
resource = new SqlResource(JSON_MAPPER, new PlannerFactory(rootSchema, walker, operatorTable, plannerConfig));
}
use of org.apache.calcite.schema.SchemaPlus in project druid by druid-io.
the class QuantileSqlAggregatorTest method setUp.
@Before
public void setUp() throws Exception {
Calcites.setSystemProperties();
// Note: this is needed in order to properly register the serde for Histogram.
new ApproximateHistogramDruidModule().configure(null);
final QueryableIndex index = IndexBuilder.create().tmpDir(temporaryFolder.newFolder()).indexMerger(TestHelper.getTestIndexMergerV9()).schema(new IncrementalIndexSchema.Builder().withMetrics(new AggregatorFactory[] { new CountAggregatorFactory("cnt"), new DoubleSumAggregatorFactory("m1", "m1"), new ApproximateHistogramAggregatorFactory("hist_m1", "m1", null, null, null, null) }).withRollup(false).build()).rows(CalciteTests.ROWS1).buildMMappedIndex();
walker = new SpecificSegmentsQuerySegmentWalker(CalciteTests.queryRunnerFactoryConglomerate()).add(DataSegment.builder().dataSource(DATA_SOURCE).interval(index.getDataInterval()).version("1").shardSpec(new LinearShardSpec(0)).build(), index);
final PlannerConfig plannerConfig = new PlannerConfig();
final SchemaPlus rootSchema = Calcites.createRootSchema(CalciteTests.createMockSchema(walker, plannerConfig));
final DruidOperatorTable operatorTable = new DruidOperatorTable(ImmutableSet.<SqlAggregator>of(new QuantileSqlAggregator()), ImmutableSet.<SqlExtractionOperator>of());
plannerFactory = new PlannerFactory(rootSchema, walker, operatorTable, plannerConfig);
}
use of org.apache.calcite.schema.SchemaPlus in project drill by apache.
the class PlanningBase method testSqlPlan.
protected void testSqlPlan(String sqlCommands) throws Exception {
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);
systemOptions.init();
@SuppressWarnings("resource") final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(systemOptions).build();
final SessionOptionManager sessionOptions = (SessionOptionManager) userSession.getOptions();
final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions);
final ExecutionControls executionControls = new ExecutionControls(queryOptions, DrillbitEndpoint.getDefaultInstance());
new NonStrictExpectations() {
{
dbContext.getMetrics();
result = new MetricRegistry();
dbContext.getAllocator();
result = allocator;
dbContext.getConfig();
result = config;
dbContext.getOptionManager();
result = systemOptions;
dbContext.getStoreProvider();
result = provider;
dbContext.getClasspathScan();
result = scanResult;
dbContext.getLpPersistence();
result = 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 = SimpleCalciteSchema.createRootSchema(false);
registry.getSchemaFactory().registerSchemas(SchemaConfig.newBuilder("foo", context).build(), root);
new NonStrictExpectations() {
{
context.getNewDefaultSchema();
result = root;
context.getLpPersistence();
result = new LogicalPlanPersistence(config, ClassPathScanner.fromPrescan(config));
context.getStorage();
result = registry;
context.getFunctionRegistry();
result = functionRegistry;
context.getSession();
result = UserSession.Builder.newBuilder().setSupportComplexTypes(true).build();
context.getCurrentEndpoint();
result = DrillbitEndpoint.getDefaultInstance();
context.getActiveEndpoints();
result = ImmutableList.of(DrillbitEndpoint.getDefaultInstance());
context.getPlannerSettings();
result = new PlannerSettings(queryOptions, functionRegistry);
context.getOptions();
result = queryOptions;
context.getConfig();
result = config;
context.getDrillOperatorTable();
result = table;
context.getAllocator();
result = allocator;
context.getExecutionControls();
result = executionControls;
dbContext.getLpPersistence();
result = logicalPlanPersistence;
}
};
for (final String sql : sqlStrings) {
if (sql.trim().isEmpty()) {
continue;
}
@SuppressWarnings("unused") final PhysicalPlan p = DrillSqlWorker.getPlan(context, sql);
}
}
use of org.apache.calcite.schema.SchemaPlus in project drill by apache.
the class HBaseSchemaFactory method registerSchemas.
@Override
public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) throws IOException {
HBaseSchema schema = new HBaseSchema(schemaName);
SchemaPlus hPlus = parent.add(schemaName, schema);
schema.setHolder(hPlus);
}
use of org.apache.calcite.schema.SchemaPlus in project drill by apache.
the class FileSystemSchemaFactory method registerSchemas.
@Override
public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) throws IOException {
FileSystemSchema schema = new FileSystemSchema(schemaName, schemaConfig);
SchemaPlus plusOfThis = parent.add(schema.getName(), schema);
schema.setPlus(plusOfThis);
}
Aggregations