Skip to content

Commit

Permalink
DruidViewMacro: Remove unused escalator field. (apache#11931)
Browse files Browse the repository at this point in the history
* DruidViewMacro: Remove unused escalator field.

* Remove additional unused fields.
  • Loading branch information
gianm authored Nov 20, 2021
1 parent f260bbe commit b3502c3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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;
Expand All @@ -38,20 +37,17 @@
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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;
Expand All @@ -37,26 +36,20 @@
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);
}
Expand All @@ -65,8 +58,7 @@ public void createView(final PlannerFactory plannerFactory, final String viewNam
@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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,7 @@ public SqlLifecycleFactory getSqlLifecycleFactory(
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

0 comments on commit b3502c3

Please sign in to comment.