Skip to content

Commit

Permalink
Implement pushdown of dynamic filters in phoenix connector
Browse files Browse the repository at this point in the history
  • Loading branch information
raunaqmorarka committed Aug 4, 2022
1 parent 29bff60 commit 4b2c5b7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions plugin/trino-phoenix5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
<artifactId>modernizer-maven-annotations</artifactId>
</dependency>

<dependency>
<groupId>org.weakref</groupId>
<artifactId>jmxutils</artifactId>
</dependency>

<!-- used by tests but also needed transitively -->
<dependency>
<groupId>io.airlift</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@
import io.trino.plugin.jdbc.DecimalModule;
import io.trino.plugin.jdbc.DefaultQueryBuilder;
import io.trino.plugin.jdbc.DriverConnectionFactory;
import io.trino.plugin.jdbc.DynamicFilteringStats;
import io.trino.plugin.jdbc.ForBaseJdbc;
import io.trino.plugin.jdbc.ForJdbcDynamicFiltering;
import io.trino.plugin.jdbc.ForLazyConnectionFactory;
import io.trino.plugin.jdbc.ForRecordCursor;
import io.trino.plugin.jdbc.JdbcClient;
import io.trino.plugin.jdbc.JdbcDiagnosticModule;
import io.trino.plugin.jdbc.JdbcDynamicFilteringConfig;
import io.trino.plugin.jdbc.JdbcDynamicFilteringSessionProperties;
import io.trino.plugin.jdbc.JdbcDynamicFilteringSplitManager;
import io.trino.plugin.jdbc.JdbcMetadataConfig;
import io.trino.plugin.jdbc.JdbcMetadataSessionProperties;
import io.trino.plugin.jdbc.JdbcPageSinkProvider;
Expand Down Expand Up @@ -73,14 +78,24 @@
import static io.trino.plugin.jdbc.JdbcModule.bindTablePropertiesProvider;
import static io.trino.plugin.phoenix5.ConfigurationInstantiator.newEmptyConfiguration;
import static io.trino.plugin.phoenix5.PhoenixErrorCode.PHOENIX_CONFIG_ERROR;
import static java.util.Objects.requireNonNull;
import static org.weakref.jmx.guice.ExportBinder.newExporter;

public class PhoenixClientModule
extends AbstractConfigurationAwareModule
{
private final String catalogName;

public PhoenixClientModule(String catalogName)
{
this.catalogName = requireNonNull(catalogName, "catalogName is null");
}

@Override
protected void setup(Binder binder)
{
binder.bind(ConnectorSplitManager.class).annotatedWith(ForClassLoaderSafe.class).to(PhoenixSplitManager.class).in(Scopes.SINGLETON);
binder.bind(ConnectorSplitManager.class).annotatedWith(ForJdbcDynamicFiltering.class).to(PhoenixSplitManager.class).in(Scopes.SINGLETON);
binder.bind(ConnectorSplitManager.class).annotatedWith(ForClassLoaderSafe.class).to(JdbcDynamicFilteringSplitManager.class).in(Scopes.SINGLETON);
binder.bind(ConnectorSplitManager.class).to(ClassLoaderSafeConnectorSplitManager.class).in(Scopes.SINGLETON);
binder.bind(ConnectorRecordSetProvider.class).annotatedWith(ForClassLoaderSafe.class).to(JdbcRecordSetProvider.class).in(Scopes.SINGLETON);
binder.bind(ConnectorRecordSetProvider.class).to(ClassLoaderSafeConnectorRecordSetProvider.class).in(Scopes.SINGLETON);
Expand All @@ -94,9 +109,15 @@ protected void setup(Binder binder)
bindSessionPropertiesProvider(binder, JdbcMetadataSessionProperties.class);
bindSessionPropertiesProvider(binder, JdbcWriteSessionProperties.class);
bindSessionPropertiesProvider(binder, PhoenixSessionProperties.class);
bindSessionPropertiesProvider(binder, JdbcDynamicFilteringSessionProperties.class);

binder.bind(DynamicFilteringStats.class).in(Scopes.SINGLETON);
newExporter(binder).export(DynamicFilteringStats.class)
.as(generator -> generator.generatedNameOf(DynamicFilteringStats.class, catalogName));

configBinder(binder).bindConfig(JdbcMetadataConfig.class);
configBinder(binder).bindConfig(JdbcWriteConfig.class);
configBinder(binder).bindConfig(JdbcDynamicFilteringConfig.class);

binder.bind(PhoenixClient.class).in(Scopes.SINGLETON);
binder.bind(JdbcClient.class).annotatedWith(ForBaseJdbc.class).to(Key.get(PhoenixClient.class)).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Connector create(String catalogName, Map<String, String> requiredConfig,
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(
new JsonModule(),
new PhoenixClientModule(),
new PhoenixClientModule(catalogName),
binder -> {
binder.bind(CatalogName.class).toInstance(new CatalogName(catalogName));
binder.bind(ClassLoader.class).toInstance(PhoenixConnectorFactory.class.getClassLoader());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
case SUPPORTS_LIMIT_PUSHDOWN:
case SUPPORTS_TOPN_PUSHDOWN:
case SUPPORTS_AGGREGATION_PUSHDOWN:
case SUPPORTS_DYNAMIC_FILTER_PUSHDOWN:
return false;

case SUPPORTS_CREATE_TABLE_WITH_TABLE_COMMENT:
Expand Down

0 comments on commit 4b2c5b7

Please sign in to comment.