diff --git a/docs/src/main/sphinx/connector/phoenix.md b/docs/src/main/sphinx/connector/phoenix.md index 7efdbe2e98c1..de1a9474d8d1 100644 --- a/docs/src/main/sphinx/connector/phoenix.md +++ b/docs/src/main/sphinx/connector/phoenix.md @@ -50,6 +50,7 @@ The following Phoenix-specific configuration properties are available: | `phoenix.connection-url` | Yes | `jdbc:phoenix[:zk_quorum][:zk_port][:zk_hbase_path]`. The `zk_quorum` is a comma separated list of ZooKeeper servers. The `zk_port` is the ZooKeeper port. The `zk_hbase_path` is the HBase root znode path, that is configurable using `hbase-site.xml`. By default the location is `/hbase` | | `phoenix.config.resources` | No | Comma-separated list of configuration files (e.g. `hbase-site.xml`) to use for connection properties. These files must exist on the machines running Trino. | | `phoenix.max-scans-per-split` | No | Maximum number of HBase scans that will be performed in a single split. Default is 20. Lower values will lead to more splits in Trino. Can also be set via session propery `max_scans_per_split`. For details see: [https://phoenix.apache.org/update_statistics.html](https://phoenix.apache.org/update_statistics.html). (This setting has no effect when guideposts are disabled in Phoenix.) | +| `phoenix.scan-page-size` | No | The time limit on the amount of work single RPC request can do before it times out. | ```{include} jdbc-common-configurations.fragment ``` diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java index b0b7d03deaed..d2054c9bbd28 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java @@ -71,6 +71,7 @@ import org.apache.hadoop.fs.Path; import org.apache.phoenix.jdbc.ConnectionInfo; import org.apache.phoenix.jdbc.PhoenixDriver; +import org.apache.phoenix.query.QueryServices; import java.sql.SQLException; import java.util.Map; @@ -209,6 +210,7 @@ public static Properties getConnectionProperties(PhoenixConfig config) ConnectionInfo connectionInfo = ConnectionInfo.create(config.getConnectionUrl(), EMPTY_PROPS, new Properties()); connectionInfo.asProps().asMap().forEach(connectionProperties::setProperty); + connectionProperties.setProperty(QueryServices.PHOENIX_SERVER_PAGE_SIZE_MS, String.valueOf(config.getPageSize())); return connectionProperties; } diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixConfig.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixConfig.java index 3dbb8b1d3e89..6a3ed5c234c1 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixConfig.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixConfig.java @@ -41,6 +41,11 @@ public class PhoenixConfig private int maxScansPerSplit = 20; private boolean reuseConnection = true; + /** + * By default, let Phoenix client derive Page size from HBase RPC timeout configs. + */ + private int pageSize = -1; + @NotNull public String getConnectionUrl() { @@ -94,4 +99,19 @@ public PhoenixConfig setReuseConnection(boolean reuseConnection) this.reuseConnection = reuseConnection; return this; } + + @Min(-1) + @Max(Integer.MAX_VALUE) + public int getPageSize() + { + return pageSize; + } + + @Config("phoenix.scan-page-size") + @ConfigDescription("Phoenix Page size to reflect the time limit on the amount of work single RPC request can do") + public PhoenixConfig setPageSize(int pageSize) + { + this.pageSize = pageSize; + return this; + } } diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConfig.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConfig.java index d32fec958cd4..2fb7bbb5959e 100644 --- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConfig.java +++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConfig.java @@ -35,7 +35,8 @@ public void testDefaults() .setConnectionUrl(null) .setResourceConfigFiles(ImmutableList.of()) .setMaxScansPerSplit(20) - .setReuseConnection(true)); + .setReuseConnection(true) + .setPageSize(-1)); } @Test @@ -49,12 +50,14 @@ public void testExplicitPropertyMappings() .put("phoenix.config.resources", configFile.toString()) .put("phoenix.max-scans-per-split", "1") .put("query.reuse-connection", "false") + .put("phoenix.scan-page-size", "11") .buildOrThrow(); PhoenixConfig expected = new PhoenixConfig() .setConnectionUrl("jdbc:phoenix:localhost:2181:/hbase") .setResourceConfigFiles(ImmutableList.of(configFile.toString())) .setMaxScansPerSplit(1) + .setPageSize(11) .setReuseConnection(false); assertFullMapping(properties, expected);