Search in sources :

Example 11 with DruidSchemaCatalog

use of org.apache.druid.sql.calcite.schema.DruidSchemaCatalog 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)

Example 12 with DruidSchemaCatalog

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

the class DruidStatementTest method setUp.

@Before
public void setUp() throws Exception {
    walker = CalciteTests.createMockWalker(conglomerate, temporaryFolder.newFolder());
    final PlannerConfig plannerConfig = new PlannerConfig();
    final DruidOperatorTable operatorTable = CalciteTests.createOperatorTable();
    final ExprMacroTable macroTable = CalciteTests.createExprMacroTable();
    DruidSchemaCatalog rootSchema = CalciteTests.createMockRootSchema(conglomerate, walker, plannerConfig, AuthTestUtils.TEST_AUTHORIZER_MAPPER);
    final PlannerFactory plannerFactory = new PlannerFactory(rootSchema, CalciteTests.createMockQueryMakerFactory(walker, conglomerate), operatorTable, macroTable, plannerConfig, AuthTestUtils.TEST_AUTHORIZER_MAPPER, CalciteTests.getJsonMapper(), CalciteTests.DRUID_SCHEMA_NAME);
    this.sqlLifecycleFactory = CalciteTests.createSqlLifecycleFactory(plannerFactory);
}
Also used : PlannerConfig(org.apache.druid.sql.calcite.planner.PlannerConfig) DruidSchemaCatalog(org.apache.druid.sql.calcite.schema.DruidSchemaCatalog) PlannerFactory(org.apache.druid.sql.calcite.planner.PlannerFactory) DruidOperatorTable(org.apache.druid.sql.calcite.planner.DruidOperatorTable) ExprMacroTable(org.apache.druid.math.expr.ExprMacroTable) Before(org.junit.Before)

Aggregations

DruidSchemaCatalog (org.apache.druid.sql.calcite.schema.DruidSchemaCatalog)12 PlannerConfig (org.apache.druid.sql.calcite.planner.PlannerConfig)10 PlannerFactory (org.apache.druid.sql.calcite.planner.PlannerFactory)9 ExprMacroTable (org.apache.druid.math.expr.ExprMacroTable)5 DruidOperatorTable (org.apache.druid.sql.calcite.planner.DruidOperatorTable)5 QueryRunnerFactoryConglomerate (org.apache.druid.query.QueryRunnerFactoryConglomerate)4 GeneratorSchemaInfo (org.apache.druid.segment.generator.GeneratorSchemaInfo)4 SegmentGenerator (org.apache.druid.segment.generator.SegmentGenerator)4 SpecificSegmentsQuerySegmentWalker (org.apache.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker)4 DataSegment (org.apache.druid.timeline.DataSegment)4 LinearShardSpec (org.apache.druid.timeline.partition.LinearShardSpec)4 InetSocketAddress (java.net.InetSocketAddress)3 AbstractAvaticaHandler (org.apache.calcite.avatica.server.AbstractAvaticaHandler)3 QueryableIndex (org.apache.druid.segment.QueryableIndex)3 ServerConfig (org.apache.druid.server.initialization.ServerConfig)3 Before (org.junit.Before)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2