mirror of https://github.com/apache/druid.git
DruidViewMacro: Remove unused escalator field. (#11931)
* DruidViewMacro: Remove unused escalator field. * Remove additional unused fields.
This commit is contained in:
parent
f260bbed23
commit
b3502c3e50
|
@ -28,7 +28,6 @@ import org.apache.calcite.schema.FunctionParameter;
|
||||||
import org.apache.calcite.schema.TableMacro;
|
import org.apache.calcite.schema.TableMacro;
|
||||||
import org.apache.calcite.schema.TranslatableTable;
|
import org.apache.calcite.schema.TranslatableTable;
|
||||||
import org.apache.calcite.schema.impl.ViewTable;
|
import org.apache.calcite.schema.impl.ViewTable;
|
||||||
import org.apache.druid.server.security.Escalator;
|
|
||||||
import org.apache.druid.sql.calcite.planner.DruidPlanner;
|
import org.apache.druid.sql.calcite.planner.DruidPlanner;
|
||||||
import org.apache.druid.sql.calcite.planner.PlannerFactory;
|
import org.apache.druid.sql.calcite.planner.PlannerFactory;
|
||||||
import org.apache.druid.sql.calcite.schema.DruidSchemaName;
|
import org.apache.druid.sql.calcite.schema.DruidSchemaName;
|
||||||
|
@ -38,20 +37,17 @@ import java.util.List;
|
||||||
public class DruidViewMacro implements TableMacro
|
public class DruidViewMacro implements TableMacro
|
||||||
{
|
{
|
||||||
private final PlannerFactory plannerFactory;
|
private final PlannerFactory plannerFactory;
|
||||||
private final Escalator escalator;
|
|
||||||
private final String viewSql;
|
private final String viewSql;
|
||||||
private final String druidSchemaName;
|
private final String druidSchemaName;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DruidViewMacro(
|
public DruidViewMacro(
|
||||||
@Assisted final PlannerFactory plannerFactory,
|
@Assisted final PlannerFactory plannerFactory,
|
||||||
@Assisted final Escalator escalator,
|
|
||||||
@Assisted final String viewSql,
|
@Assisted final String viewSql,
|
||||||
@DruidSchemaName String druidSchemaName
|
@DruidSchemaName String druidSchemaName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.plannerFactory = plannerFactory;
|
this.plannerFactory = plannerFactory;
|
||||||
this.escalator = escalator;
|
|
||||||
this.viewSql = viewSql;
|
this.viewSql = viewSql;
|
||||||
this.druidSchemaName = druidSchemaName;
|
this.druidSchemaName = druidSchemaName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.apache.druid.sql.calcite.view;
|
package org.apache.druid.sql.calcite.view;
|
||||||
|
|
||||||
import org.apache.druid.server.security.Escalator;
|
|
||||||
import org.apache.druid.sql.calcite.planner.PlannerFactory;
|
import org.apache.druid.sql.calcite.planner.PlannerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,5 +29,5 @@ public interface DruidViewMacroFactory
|
||||||
/**
|
/**
|
||||||
* Creates an instance of {@link DruidViewMacro}
|
* Creates an instance of {@link DruidViewMacro}
|
||||||
*/
|
*/
|
||||||
DruidViewMacro create(PlannerFactory plannerFactory, Escalator escalator, String viewSql);
|
DruidViewMacro create(PlannerFactory plannerFactory, String viewSql);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.apache.calcite.schema.TableMacro;
|
import org.apache.calcite.schema.TableMacro;
|
||||||
import org.apache.druid.java.util.common.ISE;
|
import org.apache.druid.java.util.common.ISE;
|
||||||
import org.apache.druid.server.security.Escalator;
|
|
||||||
import org.apache.druid.sql.calcite.planner.PlannerFactory;
|
import org.apache.druid.sql.calcite.planner.PlannerFactory;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -37,26 +36,20 @@ import java.util.concurrent.ConcurrentMap;
|
||||||
public class InProcessViewManager implements ViewManager
|
public class InProcessViewManager implements ViewManager
|
||||||
{
|
{
|
||||||
private final ConcurrentMap<String, DruidViewMacro> views;
|
private final ConcurrentMap<String, DruidViewMacro> views;
|
||||||
private final Escalator escalator;
|
|
||||||
private final DruidViewMacroFactory druidViewMacroFactory;
|
private final DruidViewMacroFactory druidViewMacroFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public InProcessViewManager(
|
public InProcessViewManager(final DruidViewMacroFactory druidViewMacroFactory)
|
||||||
final Escalator escalator,
|
|
||||||
final DruidViewMacroFactory druidViewMacroFactory
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this.views = new ConcurrentHashMap<>();
|
this.views = new ConcurrentHashMap<>();
|
||||||
this.escalator = escalator;
|
|
||||||
this.druidViewMacroFactory = druidViewMacroFactory;
|
this.druidViewMacroFactory = druidViewMacroFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createView(final PlannerFactory plannerFactory, final String viewName, final String viewSql)
|
public void createView(final PlannerFactory plannerFactory, final String viewName, final String viewSql)
|
||||||
{
|
{
|
||||||
final TableMacro oldValue =
|
final TableMacro oldValue = views.putIfAbsent(viewName, druidViewMacroFactory.create(plannerFactory, viewSql));
|
||||||
views.putIfAbsent(viewName, druidViewMacroFactory.create(plannerFactory, escalator, viewSql));
|
|
||||||
if (oldValue != null) {
|
if (oldValue != null) {
|
||||||
throw new ISE("View[%s] already exists", viewName);
|
throw new ISE("View[%s] already exists", viewName);
|
||||||
}
|
}
|
||||||
|
@ -65,8 +58,7 @@ public class InProcessViewManager implements ViewManager
|
||||||
@Override
|
@Override
|
||||||
public void alterView(final PlannerFactory plannerFactory, final String viewName, final String viewSql)
|
public void alterView(final PlannerFactory plannerFactory, final String viewName, final String viewSql)
|
||||||
{
|
{
|
||||||
final TableMacro oldValue =
|
final TableMacro oldValue = views.replace(viewName, druidViewMacroFactory.create(plannerFactory, viewSql));
|
||||||
views.replace(viewName, druidViewMacroFactory.create(plannerFactory, escalator, viewSql));
|
|
||||||
if (oldValue != null) {
|
if (oldValue != null) {
|
||||||
throw new ISE("View[%s] does not exist", viewName);
|
throw new ISE("View[%s] does not exist", viewName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -972,8 +972,7 @@ public class BaseCalciteQueryTest extends CalciteTestBase
|
||||||
ObjectMapper objectMapper
|
ObjectMapper objectMapper
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
final InProcessViewManager viewManager =
|
final InProcessViewManager viewManager = new InProcessViewManager(CalciteTests.DRUID_VIEW_MACRO_FACTORY);
|
||||||
new InProcessViewManager(CalciteTests.TEST_AUTHENTICATOR_ESCALATOR, CalciteTests.DRUID_VIEW_MACRO_FACTORY);
|
|
||||||
DruidSchemaCatalog rootSchema = CalciteTests.createMockRootSchema(
|
DruidSchemaCatalog rootSchema = CalciteTests.createMockRootSchema(
|
||||||
conglomerate,
|
conglomerate,
|
||||||
walker,
|
walker,
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.apache.druid.sql.calcite.util;
|
package org.apache.druid.sql.calcite.util;
|
||||||
|
|
||||||
import org.apache.druid.server.security.Escalator;
|
|
||||||
import org.apache.druid.sql.calcite.planner.PlannerFactory;
|
import org.apache.druid.sql.calcite.planner.PlannerFactory;
|
||||||
import org.apache.druid.sql.calcite.view.DruidViewMacro;
|
import org.apache.druid.sql.calcite.view.DruidViewMacro;
|
||||||
import org.apache.druid.sql.calcite.view.DruidViewMacroFactory;
|
import org.apache.druid.sql.calcite.view.DruidViewMacroFactory;
|
||||||
|
@ -29,10 +28,9 @@ public class TestDruidViewMacroFactory implements DruidViewMacroFactory
|
||||||
@Override
|
@Override
|
||||||
public DruidViewMacro create(
|
public DruidViewMacro create(
|
||||||
PlannerFactory plannerFactory,
|
PlannerFactory plannerFactory,
|
||||||
Escalator escalator,
|
|
||||||
String viewSql
|
String viewSql
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return new DruidViewMacro(plannerFactory, escalator, viewSql, CalciteTests.DRUID_SCHEMA_NAME);
|
return new DruidViewMacro(plannerFactory, viewSql, CalciteTests.DRUID_SCHEMA_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue