Search in sources :

Example 1 with NoopDruidSchemaManager

use of org.apache.druid.sql.calcite.schema.NoopDruidSchemaManager in project druid by druid-io.

the class BaseCalciteQueryTest method getSqlLifecycleFactory.

public SqlLifecycleFactory getSqlLifecycleFactory(PlannerConfig plannerConfig, DruidOperatorTable operatorTable, ExprMacroTable macroTable, AuthorizerMapper authorizerMapper, ObjectMapper objectMapper) {
    final InProcessViewManager viewManager = new InProcessViewManager(CalciteTests.DRUID_VIEW_MACRO_FACTORY);
    DruidSchemaCatalog rootSchema = CalciteTests.createMockRootSchema(conglomerate, walker, plannerConfig, viewManager, new NoopDruidSchemaManager(), authorizerMapper);
    final PlannerFactory plannerFactory = new PlannerFactory(rootSchema, new TestQueryMakerFactory(CalciteTests.createMockQueryLifecycleFactory(walker, conglomerate), objectMapper), operatorTable, macroTable, plannerConfig, authorizerMapper, objectMapper, CalciteTests.DRUID_SCHEMA_NAME);
    final SqlLifecycleFactory sqlLifecycleFactory = CalciteTests.createSqlLifecycleFactory(plannerFactory);
    viewManager.createView(plannerFactory, "aview", "SELECT SUBSTRING(dim1, 1, 1) AS dim1_firstchar FROM foo WHERE dim2 = 'a'");
    viewManager.createView(plannerFactory, "bview", "SELECT COUNT(*) FROM druid.foo\n" + "WHERE __time >= CURRENT_TIMESTAMP + INTERVAL '1' DAY AND __time < TIMESTAMP '2002-01-01 00:00:00'");
    viewManager.createView(plannerFactory, "cview", "SELECT SUBSTRING(bar.dim1, 1, 1) AS dim1_firstchar, bar.dim2 as dim2, dnf.l2 as l2\n" + "FROM (SELECT * from foo WHERE dim2 = 'a') as bar INNER JOIN druid.numfoo dnf ON bar.dim2 = dnf.dim2");
    viewManager.createView(plannerFactory, "dview", "SELECT SUBSTRING(dim1, 1, 1) AS numfoo FROM foo WHERE dim2 = 'a'");
    viewManager.createView(plannerFactory, "forbiddenView", "SELECT __time, SUBSTRING(dim1, 1, 1) AS dim1_firstchar, dim2 FROM foo WHERE dim2 = 'a'");
    viewManager.createView(plannerFactory, "restrictedView", "SELECT __time, dim1, dim2, m1 FROM druid.forbiddenDatasource WHERE dim2 = 'a'");
    viewManager.createView(plannerFactory, "invalidView", "SELECT __time, dim1, dim2, m1 FROM druid.invalidDatasource WHERE dim2 = 'a'");
    return sqlLifecycleFactory;
}
Also used : NoopDruidSchemaManager(org.apache.druid.sql.calcite.schema.NoopDruidSchemaManager) InProcessViewManager(org.apache.druid.sql.calcite.view.InProcessViewManager) DruidSchemaCatalog(org.apache.druid.sql.calcite.schema.DruidSchemaCatalog) PlannerFactory(org.apache.druid.sql.calcite.planner.PlannerFactory) SqlLifecycleFactory(org.apache.druid.sql.SqlLifecycleFactory)

Aggregations

SqlLifecycleFactory (org.apache.druid.sql.SqlLifecycleFactory)1 PlannerFactory (org.apache.druid.sql.calcite.planner.PlannerFactory)1 DruidSchemaCatalog (org.apache.druid.sql.calcite.schema.DruidSchemaCatalog)1 NoopDruidSchemaManager (org.apache.druid.sql.calcite.schema.NoopDruidSchemaManager)1 InProcessViewManager (org.apache.druid.sql.calcite.view.InProcessViewManager)1