DruidViewMacro: Remove unused escalator field. (#11931)

* DruidViewMacro: Remove unused escalator field.

* Remove additional unused fields.
This commit is contained in:
Gian Merlino 2021-11-19 16:06:29 -08:00 committed by GitHub
parent f260bbed23
commit b3502c3e50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 22 deletions

View File

@ -28,7 +28,6 @@ import org.apache.calcite.schema.FunctionParameter;
import org.apache.calcite.schema.TableMacro;
import org.apache.calcite.schema.TranslatableTable;
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.PlannerFactory;
import org.apache.druid.sql.calcite.schema.DruidSchemaName;
@ -38,20 +37,17 @@ import java.util.List;
public class DruidViewMacro implements TableMacro
{
private final PlannerFactory plannerFactory;
private final Escalator escalator;
private final String viewSql;
private final String druidSchemaName;
@Inject
public DruidViewMacro(
@Assisted final PlannerFactory plannerFactory,
@Assisted final Escalator escalator,
@Assisted final String viewSql,
@DruidSchemaName String druidSchemaName
)
{
this.plannerFactory = plannerFactory;
this.escalator = escalator;
this.viewSql = viewSql;
this.druidSchemaName = druidSchemaName;
}

View File

@ -19,7 +19,6 @@
package org.apache.druid.sql.calcite.view;
import org.apache.druid.server.security.Escalator;
import org.apache.druid.sql.calcite.planner.PlannerFactory;
/**
@ -30,5 +29,5 @@ public interface DruidViewMacroFactory
/**
* Creates an instance of {@link DruidViewMacro}
*/
DruidViewMacro create(PlannerFactory plannerFactory, Escalator escalator, String viewSql);
DruidViewMacro create(PlannerFactory plannerFactory, String viewSql);
}

View File

@ -23,7 +23,6 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import org.apache.calcite.schema.TableMacro;
import org.apache.druid.java.util.common.ISE;
import org.apache.druid.server.security.Escalator;
import org.apache.druid.sql.calcite.planner.PlannerFactory;
import java.util.Map;
@ -37,26 +36,20 @@ import java.util.concurrent.ConcurrentMap;
public class InProcessViewManager implements ViewManager
{
private final ConcurrentMap<String, DruidViewMacro> views;
private final Escalator escalator;
private final DruidViewMacroFactory druidViewMacroFactory;
@Inject
@VisibleForTesting
public InProcessViewManager(
final Escalator escalator,
final DruidViewMacroFactory druidViewMacroFactory
)
public InProcessViewManager(final DruidViewMacroFactory druidViewMacroFactory)
{
this.views = new ConcurrentHashMap<>();
this.escalator = escalator;
this.druidViewMacroFactory = druidViewMacroFactory;
}
@Override
public void createView(final PlannerFactory plannerFactory, final String viewName, final String viewSql)
{
final TableMacro oldValue =
views.putIfAbsent(viewName, druidViewMacroFactory.create(plannerFactory, escalator, viewSql));
final TableMacro oldValue = views.putIfAbsent(viewName, druidViewMacroFactory.create(plannerFactory, viewSql));
if (oldValue != null) {
throw new ISE("View[%s] already exists", viewName);
}
@ -65,8 +58,7 @@ public class InProcessViewManager implements ViewManager
@Override
public void alterView(final PlannerFactory plannerFactory, final String viewName, final String viewSql)
{
final TableMacro oldValue =
views.replace(viewName, druidViewMacroFactory.create(plannerFactory, escalator, viewSql));
final TableMacro oldValue = views.replace(viewName, druidViewMacroFactory.create(plannerFactory, viewSql));
if (oldValue != null) {
throw new ISE("View[%s] does not exist", viewName);
}

View File

@ -972,8 +972,7 @@ public class BaseCalciteQueryTest extends CalciteTestBase
ObjectMapper objectMapper
)
{
final InProcessViewManager viewManager =
new InProcessViewManager(CalciteTests.TEST_AUTHENTICATOR_ESCALATOR, CalciteTests.DRUID_VIEW_MACRO_FACTORY);
final InProcessViewManager viewManager = new InProcessViewManager(CalciteTests.DRUID_VIEW_MACRO_FACTORY);
DruidSchemaCatalog rootSchema = CalciteTests.createMockRootSchema(
conglomerate,
walker,

View File

@ -19,7 +19,6 @@
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.view.DruidViewMacro;
import org.apache.druid.sql.calcite.view.DruidViewMacroFactory;
@ -29,10 +28,9 @@ public class TestDruidViewMacroFactory implements DruidViewMacroFactory
@Override
public DruidViewMacro create(
PlannerFactory plannerFactory,
Escalator escalator,
String viewSql
)
{
return new DruidViewMacro(plannerFactory, escalator, viewSql, CalciteTests.DRUID_SCHEMA_NAME);
return new DruidViewMacro(plannerFactory, viewSql, CalciteTests.DRUID_SCHEMA_NAME);
}
}