mirror of https://github.com/apache/druid.git
move more to non-static
This commit is contained in:
parent
f6cc540368
commit
78b75d3e8e
|
@ -43,6 +43,7 @@ import org.apache.druid.sql.calcite.schema.NamedDruidSchema;
|
||||||
import org.apache.druid.sql.calcite.schema.NamedViewSchema;
|
import org.apache.druid.sql.calcite.schema.NamedViewSchema;
|
||||||
import org.apache.druid.sql.calcite.schema.ViewSchema;
|
import org.apache.druid.sql.calcite.schema.ViewSchema;
|
||||||
import org.apache.druid.sql.calcite.util.CalciteTests;
|
import org.apache.druid.sql.calcite.util.CalciteTests;
|
||||||
|
import org.apache.druid.sql.hook.DruidHookDispatcher;
|
||||||
import org.easymock.EasyMock;
|
import org.easymock.EasyMock;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -75,7 +76,8 @@ public class ResultsContextSerdeTest
|
||||||
"druid",
|
"druid",
|
||||||
new CalciteRulesManager(ImmutableSet.of()),
|
new CalciteRulesManager(ImmutableSet.of()),
|
||||||
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
||||||
AuthConfig.newBuilder().build()
|
AuthConfig.newBuilder().build(),
|
||||||
|
new DruidHookDispatcher()
|
||||||
);
|
);
|
||||||
final NativeSqlEngine engine = CalciteTests.createMockSqlEngine(
|
final NativeSqlEngine engine = CalciteTests.createMockSqlEngine(
|
||||||
EasyMock.createMock(QuerySegmentWalker.class),
|
EasyMock.createMock(QuerySegmentWalker.class),
|
||||||
|
|
|
@ -55,6 +55,7 @@ import org.apache.druid.sql.calcite.rule.ReverseLookupRule;
|
||||||
import org.apache.druid.sql.calcite.run.EngineFeature;
|
import org.apache.druid.sql.calcite.run.EngineFeature;
|
||||||
import org.apache.druid.sql.calcite.run.QueryMaker;
|
import org.apache.druid.sql.calcite.run.QueryMaker;
|
||||||
import org.apache.druid.sql.calcite.run.SqlEngine;
|
import org.apache.druid.sql.calcite.run.SqlEngine;
|
||||||
|
import org.apache.druid.sql.hook.DruidHook.HookKey;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.joda.time.Interval;
|
import org.joda.time.Interval;
|
||||||
|
@ -668,4 +669,9 @@ public class PlannerContext
|
||||||
|
|
||||||
return lookupCache.getLookup(lookupName);
|
return lookupCache.getLookup(lookupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T> void dispatchHook(HookKey<T> key, T object)
|
||||||
|
{
|
||||||
|
plannerToolbox.getHookDispatcher().dispatch(key, object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ public class PlannerFactory extends PlannerToolbox
|
||||||
.setConformance(DruidConformance.instance())
|
.setConformance(DruidConformance.instance())
|
||||||
.setParserFactory(new DruidSqlParserImplFactory()) // Custom SQL parser factory
|
.setParserFactory(new DruidSqlParserImplFactory()) // Custom SQL parser factory
|
||||||
.build();
|
.build();
|
||||||
private final DruidHookDispatcher hookDispatcher;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PlannerFactory(
|
public PlannerFactory(
|
||||||
|
@ -95,9 +94,9 @@ public class PlannerFactory extends PlannerToolbox
|
||||||
druidSchemaName,
|
druidSchemaName,
|
||||||
calciteRuleManager,
|
calciteRuleManager,
|
||||||
authorizerMapper,
|
authorizerMapper,
|
||||||
authConfig
|
authConfig,
|
||||||
|
hookDispatcher
|
||||||
);
|
);
|
||||||
this.hookDispatcher = hookDispatcher;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +116,7 @@ public class PlannerFactory extends PlannerToolbox
|
||||||
queryContext,
|
queryContext,
|
||||||
hook
|
hook
|
||||||
);
|
);
|
||||||
hookDispatcher.dispatch(DruidHook.SQL, sql);
|
context.dispatchHook(DruidHook.SQL, sql);
|
||||||
|
|
||||||
return new DruidPlanner(buildFrameworkConfig(context), context, engine, hook);
|
return new DruidPlanner(buildFrameworkConfig(context), context, engine, hook);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.druid.segment.join.JoinableFactoryWrapper;
|
||||||
import org.apache.druid.server.security.AuthConfig;
|
import org.apache.druid.server.security.AuthConfig;
|
||||||
import org.apache.druid.server.security.AuthorizerMapper;
|
import org.apache.druid.server.security.AuthorizerMapper;
|
||||||
import org.apache.druid.sql.calcite.schema.DruidSchemaCatalog;
|
import org.apache.druid.sql.calcite.schema.DruidSchemaCatalog;
|
||||||
|
import org.apache.druid.sql.hook.DruidHookDispatcher;
|
||||||
|
|
||||||
public class PlannerToolbox
|
public class PlannerToolbox
|
||||||
{
|
{
|
||||||
|
@ -40,6 +41,7 @@ public class PlannerToolbox
|
||||||
protected final CalciteRulesManager calciteRuleManager;
|
protected final CalciteRulesManager calciteRuleManager;
|
||||||
protected final AuthorizerMapper authorizerMapper;
|
protected final AuthorizerMapper authorizerMapper;
|
||||||
protected final AuthConfig authConfig;
|
protected final AuthConfig authConfig;
|
||||||
|
protected final DruidHookDispatcher hookDispatcher;
|
||||||
|
|
||||||
public PlannerToolbox(
|
public PlannerToolbox(
|
||||||
final DruidOperatorTable operatorTable,
|
final DruidOperatorTable operatorTable,
|
||||||
|
@ -52,7 +54,8 @@ public class PlannerToolbox
|
||||||
final String druidSchemaName,
|
final String druidSchemaName,
|
||||||
final CalciteRulesManager calciteRuleManager,
|
final CalciteRulesManager calciteRuleManager,
|
||||||
final AuthorizerMapper authorizerMapper,
|
final AuthorizerMapper authorizerMapper,
|
||||||
final AuthConfig authConfig
|
final AuthConfig authConfig,
|
||||||
|
final DruidHookDispatcher hookDispatcher
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.operatorTable = operatorTable;
|
this.operatorTable = operatorTable;
|
||||||
|
@ -66,6 +69,7 @@ public class PlannerToolbox
|
||||||
this.calciteRuleManager = calciteRuleManager;
|
this.calciteRuleManager = calciteRuleManager;
|
||||||
this.authorizerMapper = authorizerMapper;
|
this.authorizerMapper = authorizerMapper;
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
|
this.hookDispatcher = hookDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DruidOperatorTable operatorTable()
|
public DruidOperatorTable operatorTable()
|
||||||
|
@ -117,4 +121,9 @@ public class PlannerToolbox
|
||||||
{
|
{
|
||||||
return authConfig;
|
return authConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DruidHookDispatcher getHookDispatcher()
|
||||||
|
{
|
||||||
|
return hookDispatcher;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -563,7 +563,8 @@ public abstract class QueryHandler extends SqlStatementHandler.BaseStatementHand
|
||||||
.plus(DruidLogicalConvention.instance()),
|
.plus(DruidLogicalConvention.instance()),
|
||||||
newRoot
|
newRoot
|
||||||
);
|
);
|
||||||
DruidHook.dispatch(DruidHook.DRUID_PLAN, newRoot);
|
|
||||||
|
plannerContext.dispatchHook(DruidHook.DRUID_PLAN, newRoot);
|
||||||
|
|
||||||
DruidQueryGenerator generator = new DruidQueryGenerator(plannerContext, (DruidLogicalNode) newRoot, rexBuilder);
|
DruidQueryGenerator generator = new DruidQueryGenerator(plannerContext, (DruidLogicalNode) newRoot, rexBuilder);
|
||||||
DruidQuery baseQuery = generator.buildQuery();
|
DruidQuery baseQuery = generator.buildQuery();
|
||||||
|
|
|
@ -62,6 +62,7 @@ import org.apache.druid.sql.calcite.schema.ViewSchema;
|
||||||
import org.apache.druid.sql.calcite.table.RowSignatures;
|
import org.apache.druid.sql.calcite.table.RowSignatures;
|
||||||
import org.apache.druid.sql.calcite.util.CalciteTestBase;
|
import org.apache.druid.sql.calcite.util.CalciteTestBase;
|
||||||
import org.apache.druid.sql.calcite.util.CalciteTests;
|
import org.apache.druid.sql.calcite.util.CalciteTests;
|
||||||
|
import org.apache.druid.sql.hook.DruidHookDispatcher;
|
||||||
import org.easymock.EasyMock;
|
import org.easymock.EasyMock;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
|
@ -97,7 +98,8 @@ public class ExpressionTestHelper
|
||||||
"druid",
|
"druid",
|
||||||
new CalciteRulesManager(ImmutableSet.of()),
|
new CalciteRulesManager(ImmutableSet.of()),
|
||||||
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
||||||
AuthConfig.newBuilder().build()
|
AuthConfig.newBuilder().build(),
|
||||||
|
new DruidHookDispatcher()
|
||||||
);
|
);
|
||||||
public static final PlannerContext PLANNER_CONTEXT = PlannerContext.create(
|
public static final PlannerContext PLANNER_CONTEXT = PlannerContext.create(
|
||||||
PLANNER_TOOLBOX,
|
PLANNER_TOOLBOX,
|
||||||
|
@ -336,7 +338,7 @@ public class ExpressionTestHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprEval<?> result = PLANNER_CONTEXT.parseExpression(expression.getExpression())
|
ExprEval<?> result = PLANNER_CONTEXT.parseExpression(expression.getExpression())
|
||||||
|
|
||||||
.eval(expressionBindings);
|
.eval(expressionBindings);
|
||||||
|
|
||||||
Assert.assertEquals("Result for: " + rexNode, expectedResult, result.value());
|
Assert.assertEquals("Result for: " + rexNode, expectedResult, result.value());
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.druid.sql.calcite.schema.NamedDruidSchema;
|
||||||
import org.apache.druid.sql.calcite.schema.NamedViewSchema;
|
import org.apache.druid.sql.calcite.schema.NamedViewSchema;
|
||||||
import org.apache.druid.sql.calcite.schema.ViewSchema;
|
import org.apache.druid.sql.calcite.schema.ViewSchema;
|
||||||
import org.apache.druid.sql.calcite.util.CalciteTests;
|
import org.apache.druid.sql.calcite.util.CalciteTests;
|
||||||
|
import org.apache.druid.sql.hook.DruidHookDispatcher;
|
||||||
import org.easymock.EasyMock;
|
import org.easymock.EasyMock;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -71,7 +72,8 @@ public class ExternalTableScanRuleTest
|
||||||
"druid",
|
"druid",
|
||||||
new CalciteRulesManager(ImmutableSet.of()),
|
new CalciteRulesManager(ImmutableSet.of()),
|
||||||
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
||||||
AuthConfig.newBuilder().build()
|
AuthConfig.newBuilder().build(),
|
||||||
|
new DruidHookDispatcher()
|
||||||
);
|
);
|
||||||
final PlannerContext plannerContext = PlannerContext.create(
|
final PlannerContext plannerContext = PlannerContext.create(
|
||||||
toolbox,
|
toolbox,
|
||||||
|
|
|
@ -50,6 +50,7 @@ import org.apache.druid.sql.calcite.schema.DruidSchemaName;
|
||||||
import org.apache.druid.sql.calcite.schema.NamedSchema;
|
import org.apache.druid.sql.calcite.schema.NamedSchema;
|
||||||
import org.apache.druid.sql.calcite.util.CalciteTestBase;
|
import org.apache.druid.sql.calcite.util.CalciteTestBase;
|
||||||
import org.apache.druid.sql.calcite.util.CalciteTests;
|
import org.apache.druid.sql.calcite.util.CalciteTests;
|
||||||
|
import org.apache.druid.sql.hook.DruidHookDispatcher;
|
||||||
import org.easymock.EasyMock;
|
import org.easymock.EasyMock;
|
||||||
import org.easymock.EasyMockExtension;
|
import org.easymock.EasyMockExtension;
|
||||||
import org.easymock.Mock;
|
import org.easymock.Mock;
|
||||||
|
@ -192,7 +193,8 @@ public class CalcitePlannerModuleTest extends CalciteTestBase
|
||||||
"druid",
|
"druid",
|
||||||
new CalciteRulesManager(ImmutableSet.of()),
|
new CalciteRulesManager(ImmutableSet.of()),
|
||||||
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
||||||
AuthConfig.newBuilder().build()
|
AuthConfig.newBuilder().build(),
|
||||||
|
new DruidHookDispatcher()
|
||||||
);
|
);
|
||||||
|
|
||||||
PlannerContext context = PlannerContext.create(
|
PlannerContext context = PlannerContext.create(
|
||||||
|
@ -224,7 +226,8 @@ public class CalcitePlannerModuleTest extends CalciteTestBase
|
||||||
"druid",
|
"druid",
|
||||||
new CalciteRulesManager(ImmutableSet.of()),
|
new CalciteRulesManager(ImmutableSet.of()),
|
||||||
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
||||||
AuthConfig.newBuilder().build()
|
AuthConfig.newBuilder().build(),
|
||||||
|
new DruidHookDispatcher()
|
||||||
);
|
);
|
||||||
|
|
||||||
PlannerContext contextWithBloat = PlannerContext.create(
|
PlannerContext contextWithBloat = PlannerContext.create(
|
||||||
|
|
|
@ -54,6 +54,7 @@ import org.apache.druid.sql.calcite.schema.ViewSchema;
|
||||||
import org.apache.druid.sql.calcite.table.RowSignatures;
|
import org.apache.druid.sql.calcite.table.RowSignatures;
|
||||||
import org.apache.druid.sql.calcite.util.CalciteTestBase;
|
import org.apache.druid.sql.calcite.util.CalciteTestBase;
|
||||||
import org.apache.druid.sql.calcite.util.CalciteTests;
|
import org.apache.druid.sql.calcite.util.CalciteTests;
|
||||||
|
import org.apache.druid.sql.hook.DruidHookDispatcher;
|
||||||
import org.apache.druid.testing.InitializedNullHandlingTest;
|
import org.apache.druid.testing.InitializedNullHandlingTest;
|
||||||
import org.easymock.EasyMock;
|
import org.easymock.EasyMock;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -100,7 +101,8 @@ public class DruidRexExecutorTest extends InitializedNullHandlingTest
|
||||||
"druid",
|
"druid",
|
||||||
new CalciteRulesManager(ImmutableSet.of()),
|
new CalciteRulesManager(ImmutableSet.of()),
|
||||||
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
CalciteTests.TEST_AUTHORIZER_MAPPER,
|
||||||
AuthConfig.newBuilder().build()
|
AuthConfig.newBuilder().build(),
|
||||||
|
new DruidHookDispatcher()
|
||||||
);
|
);
|
||||||
private static final PlannerContext PLANNER_CONTEXT = PlannerContext.create(
|
private static final PlannerContext PLANNER_CONTEXT = PlannerContext.create(
|
||||||
PLANNER_TOOLBOX,
|
PLANNER_TOOLBOX,
|
||||||
|
|
Loading…
Reference in New Issue