[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16837945#comment-16837945 ] Kunal Khatua commented on DRILL-7048: - LGTM +1 Thanks, [~bbevens] > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.16.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting, ready-to-commit > Fix For: 1.16.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16835203#comment-16835203 ] Bridget Bevens commented on DRILL-7048: --- Hi [~kkhatua], I've updated the following page with info about setMaxRows: https://drill.apache.org/docs/using-the-jdbc-driver/#using-the-drill-driver-class-name Also included it in the Note in this section: https://drill.apache.org/docs/planning-and-execution-options/#drill-web-ui-row-limit-settings Let me know if I need to make any changes. Thanks, Bridget > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.16.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting, ready-to-commit > Fix For: 1.16.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16811340#comment-16811340 ] ASF GitHub Bot commented on DRILL-7048: --- sohami commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.16.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting, ready-to-commit > Fix For: 1.16.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16810147#comment-16810147 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on issue #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#issuecomment-479995516 @vvysotskyi made the changes in the `optionsMaxRows` branch and squashed in the `DRILL-7048` branch. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16810122#comment-16810122 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272283379 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementMaxRowsTest.java ## @@ -0,0 +1,247 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import org.apache.drill.categories.JdbcTest; +import org.apache.drill.exec.ExecConstants; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Random; +import java.util.concurrent.Semaphore; +import java.sql.SQLException; + +/** + * Test for Drill's implementation of Statement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class StatementMaxRowsTest extends JdbcTestBase { Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16810123#comment-16810123 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272283465 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementMaxRowsTest.java ## @@ -0,0 +1,247 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import org.apache.drill.categories.JdbcTest; +import org.apache.drill.exec.ExecConstants; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Random; +import java.util.concurrent.Semaphore; +import java.sql.SQLException; + +/** + * Test for Drill's implementation of Statement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class StatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + @BeforeClass + public static void setUpStatement() throws SQLException { +// (Note: Can't use JdbcTest's connect(...) because JdbcTest closes +// Connection--and other JDBC objects--on test method failure, but this test +// class uses some objects across methods.) +connection = new Driver().connect( "jdbc:drill:zk=local", null ); Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16810118#comment-16810118 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272282495 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + + @BeforeClass + public static void setUpConnection() throws SQLException { +Driver.load(); +Properties properties = new Properties(); +// Increased prepared statement creation timeout so test doesn't timeout on my laptop + properties.setProperty(ExecConstants.bootDefaultFor(ExecConstants.CREATE_PREPARE_STATEMENT_TIMEOUT_MILLIS), "3"); +connection = DriverManager.getConnection( "jdbc:drill:zk=local", properties); +try(Statement stmt = connection.createStatement()) { Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16810120#comment-16810120 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272282783 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + + @BeforeClass + public static void setUpConnection() throws SQLException { +Driver.load(); +Properties properties = new Properties(); +// Increased prepared statement creation timeout so test doesn't timeout on my laptop + properties.setProperty(ExecConstants.bootDefaultFor(ExecConstants.CREATE_PREPARE_STATEMENT_TIMEOUT_MILLIS), "3"); +connection = DriverManager.getConnection( "jdbc:drill:zk=local", properties); +try(Statement stmt = connection.createStatement()) { + stmt.execute(String.format("alter session set `%s` = true", PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY)); +} + } + + @AfterClass + public static void tearDownConnection() throws SQLException { +if (connection != null) { + try (Statement stmt = connection.createStatement()) { +stmt.execute(String.format("alter session set `%s` = false", PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY)); + } +} +connection.close(); Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16810117#comment-16810117 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272282371 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + + @BeforeClass + public static void setUpConnection() throws SQLException { +Driver.load(); +Properties properties = new Properties(); +// Increased prepared statement creation timeout so test doesn't timeout on my laptop Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16810116#comment-16810116 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272282143 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + + @BeforeClass + public static void setUpConnection() throws SQLException { +Driver.load(); +Properties properties = new Properties(); +// Increased prepared statement creation timeout so test doesn't timeout on my laptop + properties.setProperty(ExecConstants.bootDefaultFor(ExecConstants.CREATE_PREPARE_STATEMENT_TIMEOUT_MILLIS), "3"); +connection = DriverManager.getConnection( "jdbc:drill:zk=local", properties); Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16810114#comment-16810114 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272282001 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16810113#comment-16810113 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272281940 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809730#comment-16809730 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272122733 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + + @BeforeClass + public static void setUpConnection() throws SQLException { +Driver.load(); +Properties properties = new Properties(); +// Increased prepared statement creation timeout so test doesn't timeout on my laptop + properties.setProperty(ExecConstants.bootDefaultFor(ExecConstants.CREATE_PREPARE_STATEMENT_TIMEOUT_MILLIS), "3"); +connection = DriverManager.getConnection( "jdbc:drill:zk=local", properties); +try(Statement stmt = connection.createStatement()) { + stmt.execute(String.format("alter session set `%s` = true", PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY)); +} + } + + @AfterClass + public static void tearDownConnection() throws SQLException { +if (connection != null) { + try (Statement stmt = connection.createStatement()) { +stmt.execute(String.format("alter session set `%s` = false", PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY)); + } +} +connection.close(); Review comment: Please move this call inside if statement. Also, since the connection is closed, there is no need to restore session options. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809728#comment-16809728 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272125703 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementMaxRowsTest.java ## @@ -0,0 +1,247 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import org.apache.drill.categories.JdbcTest; +import org.apache.drill.exec.ExecConstants; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Random; +import java.util.concurrent.Semaphore; +import java.sql.SQLException; + +/** + * Test for Drill's implementation of Statement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class StatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + @BeforeClass + public static void setUpStatement() throws SQLException { +// (Note: Can't use JdbcTest's connect(...) because JdbcTest closes +// Connection--and other JDBC objects--on test method failure, but this test +// class uses some objects across methods.) +connection = new Driver().connect( "jdbc:drill:zk=local", null ); Review comment: ```suggestion connection = new Driver().connect("jdbc:drill:zk=local", null); ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809725#comment-16809725 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272122067 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + + @BeforeClass + public static void setUpConnection() throws SQLException { +Driver.load(); +Properties properties = new Properties(); +// Increased prepared statement creation timeout so test doesn't timeout on my laptop Review comment: Please rephrase it to: ```suggestion // Increased prepared statement creation timeout to avoid timeout failures ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809726#comment-16809726 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272121561 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + + @BeforeClass + public static void setUpConnection() throws SQLException { +Driver.load(); +Properties properties = new Properties(); +// Increased prepared statement creation timeout so test doesn't timeout on my laptop + properties.setProperty(ExecConstants.bootDefaultFor(ExecConstants.CREATE_PREPARE_STATEMENT_TIMEOUT_MILLIS), "3"); +connection = DriverManager.getConnection( "jdbc:drill:zk=local", properties); Review comment: ```suggestion connection = DriverManager.getConnection("jdbc:drill:zk=local", properties); ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809729#comment-16809729 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272123223 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementMaxRowsTest.java ## @@ -0,0 +1,247 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import org.apache.drill.categories.JdbcTest; +import org.apache.drill.exec.ExecConstants; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Random; +import java.util.concurrent.Semaphore; +import java.sql.SQLException; + +/** + * Test for Drill's implementation of Statement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class StatementMaxRowsTest extends JdbcTestBase { Review comment: The same as for `PreparedStatementMaxRowsTest.java` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809723#comment-16809723 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272119812 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); Review comment: Please remove this line. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809727#comment-16809727 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272122171 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); + + private static Connection connection; + + + @BeforeClass + public static void setUpConnection() throws SQLException { +Driver.load(); +Properties properties = new Properties(); +// Increased prepared statement creation timeout so test doesn't timeout on my laptop + properties.setProperty(ExecConstants.bootDefaultFor(ExecConstants.CREATE_PREPARE_STATEMENT_TIMEOUT_MILLIS), "3"); +connection = DriverManager.getConnection( "jdbc:drill:zk=local", properties); +try(Statement stmt = connection.createStatement()) { Review comment: ```suggestion try (Statement stmt = connection.createStatement()) { ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. --
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809724#comment-16809724 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r272119927 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementMaxRowsTest.java ## @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.jdbc; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.Semaphore; + +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.categories.JdbcTest; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.junit.experimental.categories.Category; + +/** + * Test for Drill's implementation of PreparedStatement's get/setMaxRows methods + */ +@Category(JdbcTest.class) +public class PreparedStatementMaxRowsTest extends JdbcTestBase { + +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementMaxRowsTest.class); + private static final Random RANDOMIZER = new Random(20150304); + + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + // Lock used by all tests to avoid corrupting test scenario + static final Semaphore maxRowsSysOptionLock = new Semaphore(1); Review comment: please make it private This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809283#comment-16809283 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on issue #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#issuecomment-479664825 Done. This is the reference branch before the squash: https://github.com/kkhatua/drill/commits/optionMaxRows into commit ID `a17fddb27bef647024748ef53aa1b336bc17da79` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16809241#comment-16809241 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r271922480 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -69,6 +78,17 @@ public static void tearDownStatement() throws SQLException { connection.close(); } + @Before Review comment: Ok. I'll move only the `get|setMaxRows` related tests. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16808963#comment-16808963 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r271853531 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -69,6 +78,17 @@ public static void tearDownStatement() throws SQLException { connection.close(); } + @Before Review comment: This will slow down all the tests in this class besides your tests. Also, since connection string is `jdbc:drill:zk=local`, so separate embedded drill instance will be used for every test class and there is no need to lock other test classes. Could you please move all your tests into a separate class and add lock there? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16808053#comment-16808053 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on issue #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#issuecomment-479152740 @vvysotskyi , @ihuzenko I've done the changes and verified the tests. If everything is fine, I'll rebase on the latest master (there are small conflicts due to new commits on master introducing additional system options) I've also included a trim for the values, so an input of `100 ` will be treated as valid. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16808051#comment-16808051 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on issue #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#issuecomment-479152740 @vvysotskyi , @ihuzenko I've done the changes and verified the tests. If everything is fine, I'll rebase on the latest master (there are small conflicts due to new commits on master introducing additional system options) This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16808047#comment-16808047 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r271452501 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { Review comment: As per our chat, I've introduced `@Before` and `@After` methods for synchronizing the `system` level modifications to the options. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16807063#comment-16807063 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r270996130 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java ## @@ -537,8 +537,6 @@ public void testclosedPreparedStmtOfOpenConnMethodsThrowRight() { new ClosedPreparedStatementChecker(PreparedStatement.class, closedPreparedStmtOfOpenConn); -checker.testAllMethods(); Review comment: You're right. It was an accidental change, which is why it went through the tests. I'll restore it. Thanks for catching it. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16806752#comment-16806752 ] ASF GitHub Bot commented on DRILL-7048: --- ihuzenko commented on issue #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#issuecomment-478578390 Hello @kkhatua, generally the PR looks good, only one comment related to test. And interesting thing with UI is that setting auto limit value to "100 " is prohibited because of space sign after number, should we trim all accepted values ? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16806749#comment-16806749 ] ASF GitHub Bot commented on DRILL-7048: --- ihuzenko commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r270863652 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java ## @@ -537,8 +537,6 @@ public void testclosedPreparedStmtOfOpenConnMethodsThrowRight() { new ClosedPreparedStatementChecker(PreparedStatement.class, closedPreparedStmtOfOpenConn); -checker.testAllMethods(); Review comment: Does deletion of the line means that test now checks nothing ? Maybe it's accidental change and needs revert or test method may be safely removed ? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16804624#comment-16804624 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r270291552 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { Review comment: Strangely enough, these tests have never failed... so, I'm presuming the tests run fast enough with a low level of parallelization. I can set the `assert` to check for a non-zero value for the timeout test. Alternatively, I could disable the tests: `testSetMaxRowsHigherThanSystemLimit()` and `testSetMaxRowsLowerThanSystemLimit()` Which one should I do? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16804621#comment-16804621 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r270291552 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { Review comment: Strangely enough, these tests have never failed. I can set the `assert` to check for a non-zero value. Alternatively, I could disable the tests: `testSetMaxRowsHigherThanSystemLimit()` and `testSetMaxRowsLowerThanSystemLimit()` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16804608#comment-16804608 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r270288549 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch (final SQLException e) { +assertThat(e.getMessage(), containsString("illegal maxRows value: " + valueToSet)); Review comment: I would think that a thrown exception is sufficient, but I'll add the check to compare against the value before the `setMaxRows()` is called. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16804156#comment-16804156 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r270130908 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch (final SQLException e) { +assertThat(e.getMessage(), containsString("illegal maxRows value: " + valueToSet)); Review comment: It would be good also to check the value of `pStmt.getMaxRows()` after the failure. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16804146#comment-16804146 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r270129243 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { Review comment: `PreparedStatementTest` contains `testSetQueryTimeoutAsZero()` test which verifies that the result should have 3 rows. This test will be executed without considering the `Semaphore` lock. So for the case when one of your tests changed the value of autoLimit, and before resetting the value this test is executed, it will return fewer rows than it should. So adding these tests may introduce random failures of other tests. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803349#comment-16803349 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269763048 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { Review comment: There are _getter-setter_ method tests that don't rely on what the `SYSTEM` value is, so we don't need to acquire explicit locks. Only when a query is being executed, do we need to ensure that changes to the `SYSTEM` value are synchronized because that is when `QueryContext` will apply a `SESSION` or `SYSTEM` value. Using the lock to synchronize the change, indirectly synchronizes these specific tests as well. We don't have any other control on the parallelism or order of the tests within the 2 suites (`PreparedStatementTest` and `StatementTest`)... so using a common lock across both tests is the safest way to run such tests with an element of randomness (using the `RANDOMIZER` object). This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803347#comment-16803347 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269759078 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java ## @@ -537,7 +547,14 @@ public void testclosedPreparedStmtOfOpenConnMethodsThrowRight() { new ClosedPreparedStatementChecker(PreparedStatement.class, closedPreparedStmtOfOpenConn); -checker.testAllMethods(); +//List of methods now supported +Set methodsToSkip = new LinkedHashSet() {{ Review comment: Ok. These tests were failing because it we had implemented the `setMaxRows()` and `getMaxRows()` methods. These tests, it seems, expected them to throw exceptions. With the `super.setLargeMaxRows()`, this should not be necessary anymore. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803324#comment-16803324 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269753146 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -285,7 +292,7 @@ public void testInvalidSetQueryTimeout() throws SQLException { public void testValidSetQueryTimeout() throws SQLException { try (PreparedStatement stmt = connection.prepareStatement(SYS_VERSION_SQL)) { //Setting positive value - int valueToSet = new Random(20150304).nextInt(59)+1; + int valueToSet = RANDOMIZER.nextInt(59)+1; Review comment: Will check across all the tests. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803323#comment-16803323 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269753040 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803318#comment-16803318 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269751346 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,13 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +super.setLargeMaxRows(maxRowCount); +try (Statement statement = this.connection.createStatement()) { + statement.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); + statement.close(); Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803239#comment-16803239 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269711807 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} + } + + /** + * Test setting maxSize at a value higher than existing query limit + */ + @Test + public void testSetMaxRowsHigherThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(10)+11; //range:[11-20] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(valueToSet > rowCount); +} + } + + /** + * Test setting maxSize at a value lower than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsLowerThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; //range:[6-10] +setSystemMaxRows(sysValueToSet); +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int valueToSet = RANDOMIZER.nextInt(5)+1; //range:[1-5] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} +setSystemMaxRows(0); //RESET + } + + /** + * Test setting maxSize at a value higher than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsHigherThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; //range:[6-10] +setSystemMaxRows(sysValueToSet); +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int valueToSet = RANDOMIZER.nextInt(5)+11; //range:[11-15] Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(5) + 11; // range: [11-15] ```
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803247#comment-16803247 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269719305 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { Review comment: It looks like a hack to release the lock for one value and acquire for others. Except adding locks into tests directly, the more clear way may be to add a boolean flag into method argument whether to acquire or release the lock. Also, I'm wondering whether these tests which change autoLimit does not affect other tests, i.e. when one test sets autoLimit to 3, but another test (which does not contain `setSystemMaxRows()` call, so it is not locked) expects result with 5 rows. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803238#comment-16803238 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269719449 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { +// Acquire lock if Non-Zero Value (i.e. a test is in progress) +if (sysValueToSet != 0) { + maxRowsSysOptionLock.acquireUninterruptibly(); +} +// Setting the value +try (Statement stmt = connection.createStatement()) { + stmt.executeQuery(ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X + sysValueToSet); + ResultSet rs = stmt.getResultSet(); Review comment: Ok, thanks for the clarification. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803240#comment-16803240 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269720137 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -239,4 +246,174 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int maxRowsValue = stmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting negative value + int valueToSet = -10; + try { +stmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + stmt.setMaxRows(valueToSet); + assertEquals( valueToSet, stmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (Statement stmt = connection.createStatement()) { + stmt.setMaxRows(0); + stmt.executeQuery(SYS_OPTIONS_SQL); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(9)+1; // range:[1-9] Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(9) + 1; // range: [1-9] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803225#comment-16803225 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269709745 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,13 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +super.setLargeMaxRows(maxRowCount); +try (Statement statement = this.connection.createStatement()) { + statement.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); + statement.close(); Review comment: Please remove this line, `statement` will be closed automatically since it is used in `try with resources`. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803243#comment-16803243 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269720874 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java ## @@ -537,7 +547,14 @@ public void testclosedPreparedStmtOfOpenConnMethodsThrowRight() { new ClosedPreparedStatementChecker(PreparedStatement.class, closedPreparedStmtOfOpenConn); -checker.testAllMethods(); +//List of methods now supported +Set methodsToSkip = new LinkedHashSet() {{ Review comment: I meant to revert all these changes, they are not needed for now. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803245#comment-16803245 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269720328 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -239,4 +246,174 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int maxRowsValue = stmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting negative value + int valueToSet = -10; + try { +stmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + stmt.setMaxRows(valueToSet); + assertEquals( valueToSet, stmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (Statement stmt = connection.createStatement()) { + stmt.setMaxRows(0); + stmt.executeQuery(SYS_OPTIONS_SQL); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(9)+1; // range:[1-9] + stmt.setMaxRows(valueToSet); + stmt.executeQuery(SYS_OPTIONS_SQL_LIMIT_10); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} + } + + /** + * Test setting maxSize at a value higher than existing query limit + */ + @Test + public void testSetMaxRowsHigherThanQueryLimit() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(10)+11; // range:[11-20] + stmt.setMaxRows(valueToSet); + stmt.executeQuery(SYS_OPTIONS_SQL_LIMIT_10); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(valueToSet > rowCount); +} + } + + /** + * Test setting maxSize at a value lower than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsLowerThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; // range:[6-10] Review comment: ```suggestion int sysValueToSet = RANDOMIZER.nextInt(5) + 6; // range: [6-10] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803231#comment-16803231 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269710761 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { Review comment: ```suggestion } catch (final SQLException e) { ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803233#comment-16803233 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269711273 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(9) + 1; // range: [1-9] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803242#comment-16803242 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269719854 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -239,4 +246,174 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int maxRowsValue = stmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting negative value + int valueToSet = -10; + try { +stmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); Review comment: ```suggestion assertThat(e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ")); ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803230#comment-16803230 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269711070 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(59) + 1; ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803226#comment-16803226 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269710453 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -285,7 +292,7 @@ public void testInvalidSetQueryTimeout() throws SQLException { public void testValidSetQueryTimeout() throws SQLException { try (PreparedStatement stmt = connection.prepareStatement(SYS_VERSION_SQL)) { //Setting positive value - int valueToSet = new Random(20150304).nextInt(59)+1; + int valueToSet = RANDOMIZER.nextInt(59)+1; Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(59) + 1; ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803235#comment-16803235 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269711718 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} + } + + /** + * Test setting maxSize at a value higher than existing query limit + */ + @Test + public void testSetMaxRowsHigherThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(10)+11; //range:[11-20] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(valueToSet > rowCount); +} + } + + /** + * Test setting maxSize at a value lower than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsLowerThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; //range:[6-10] +setSystemMaxRows(sysValueToSet); +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int valueToSet = RANDOMIZER.nextInt(5)+1; //range:[1-5] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} +setSystemMaxRows(0); //RESET + } + + /** + * Test setting maxSize at a value higher than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsHigherThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; //range:[6-10] Review comment: ```suggestion int sysValueToSet = RANDOMIZER.nextInt(5) + 6; // range: [6-10] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803227#comment-16803227 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269710348 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -72,12 +73,18 @@ public class PreparedStatementTest extends JdbcTestBase { private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementTest.class); + private static final Random RANDOMIZER = new Random(20150304); private static final String SYS_VERSION_SQL = "select * from sys.version"; private static final String SYS_RANDOM_SQL = "SELECT cast(random() as varchar) as myStr FROM (VALUES(1)) " + "union SELECT cast(random() as varchar) as myStr FROM (VALUES(1)) " + "union SELECT cast(random() as varchar) as myStr FROM (VALUES(1)) "; + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + //Locks used across StatementTest and PreparedStatementTest + private static Semaphore maxRowsSysOptionLock = StatementTest.maxRowsSysOptionLock; Review comment: Looks like these tests are connected to the same drillbit. In this case, the same `Semaphore` instance should be used. Thanks for the clarification. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803237#comment-16803237 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269719943 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -239,4 +246,174 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int maxRowsValue = stmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting negative value + int valueToSet = -10; + try { +stmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(59) + 1; ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803248#comment-16803248 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269720581 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -239,4 +246,174 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int maxRowsValue = stmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting negative value + int valueToSet = -10; + try { +stmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + stmt.setMaxRows(valueToSet); + assertEquals( valueToSet, stmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (Statement stmt = connection.createStatement()) { + stmt.setMaxRows(0); + stmt.executeQuery(SYS_OPTIONS_SQL); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(9)+1; // range:[1-9] + stmt.setMaxRows(valueToSet); + stmt.executeQuery(SYS_OPTIONS_SQL_LIMIT_10); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} + } + + /** + * Test setting maxSize at a value higher than existing query limit + */ + @Test + public void testSetMaxRowsHigherThanQueryLimit() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(10)+11; // range:[11-20] + stmt.setMaxRows(valueToSet); + stmt.executeQuery(SYS_OPTIONS_SQL_LIMIT_10); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(valueToSet > rowCount); +} + } + + /** + * Test setting maxSize at a value lower than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsLowerThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; // range:[6-10] +setSystemMaxRows(sysValueToSet); +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(5)+1; // range:[1-5] + stmt.setMaxRows(valueToSet); + stmt.executeQuery(SYS_OPTIONS_SQL); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} +setSystemMaxRows(0); // Reset value + } + + /** + * Test setting maxSize at a value higher than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsHigherThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; // range:[6-10] +setSystemMaxRows(sysValueToSet); +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(5)+11; // range:[11-15] Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(5) + 11; // range: [11-15] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803236#comment-16803236 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269711477 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} + } + + /** + * Test setting maxSize at a value higher than existing query limit + */ + @Test + public void testSetMaxRowsHigherThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(10)+11; //range:[11-20] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(valueToSet > rowCount); +} + } + + /** + * Test setting maxSize at a value lower than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsLowerThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; //range:[6-10] Review comment: ```suggestion int sysValueToSet = RANDOMIZER.nextInt(5) + 6; // range: [6-10] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results >
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803229#comment-16803229 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269710983 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); Review comment: ```suggestion assertThat(e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ")); ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803232#comment-16803232 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269711132 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); Review comment: ```suggestion assertEquals(valueToSet, pStmt.getMaxRows()); ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803244#comment-16803244 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269720404 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -239,4 +246,174 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int maxRowsValue = stmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting negative value + int valueToSet = -10; + try { +stmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + stmt.setMaxRows(valueToSet); + assertEquals( valueToSet, stmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (Statement stmt = connection.createStatement()) { + stmt.setMaxRows(0); + stmt.executeQuery(SYS_OPTIONS_SQL); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(9)+1; // range:[1-9] + stmt.setMaxRows(valueToSet); + stmt.executeQuery(SYS_OPTIONS_SQL_LIMIT_10); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} + } + + /** + * Test setting maxSize at a value higher than existing query limit + */ + @Test + public void testSetMaxRowsHigherThanQueryLimit() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(10)+11; // range:[11-20] + stmt.setMaxRows(valueToSet); + stmt.executeQuery(SYS_OPTIONS_SQL_LIMIT_10); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(valueToSet > rowCount); +} + } + + /** + * Test setting maxSize at a value lower than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsLowerThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; // range:[6-10] +setSystemMaxRows(sysValueToSet); +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(5)+1; // range:[1-5] Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(5) + 1; // range: [1-5] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803246#comment-16803246 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269720216 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -239,4 +246,174 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int maxRowsValue = stmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting negative value + int valueToSet = -10; + try { +stmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + stmt.setMaxRows(valueToSet); + assertEquals( valueToSet, stmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (Statement stmt = connection.createStatement()) { + stmt.setMaxRows(0); + stmt.executeQuery(SYS_OPTIONS_SQL); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(9)+1; // range:[1-9] + stmt.setMaxRows(valueToSet); + stmt.executeQuery(SYS_OPTIONS_SQL_LIMIT_10); + ResultSet rs = stmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} + } + + /** + * Test setting maxSize at a value higher than existing query limit + */ + @Test + public void testSetMaxRowsHigherThanQueryLimit() throws SQLException { +try (Statement stmt = connection.createStatement()) { + int valueToSet = RANDOMIZER.nextInt(10)+11; // range:[11-20] Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(10) + 11; // range: [11-20] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803241#comment-16803241 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269711570 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertEquals(valueToSet, rowCount); +} + } + + /** + * Test setting maxSize at a value higher than existing query limit + */ + @Test + public void testSetMaxRowsHigherThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(10)+11; //range:[11-20] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + rs.close(); + assertTrue(valueToSet > rowCount); +} + } + + /** + * Test setting maxSize at a value lower than existing SYSTEM limit + */ + @Test + public void testSetMaxRowsLowerThanSystemLimit() throws SQLException { +int sysValueToSet = RANDOMIZER.nextInt(5)+6; //range:[6-10] +setSystemMaxRows(sysValueToSet); +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int valueToSet = RANDOMIZER.nextInt(5)+1; //range:[1-5] Review comment: ```suggestion int valueToSet = RANDOMIZER.nextInt(5) + 1; // range: [1-5] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16803228#comment-16803228 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269710545 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { Review comment: ```suggestion public void testDefaultGetMaxRows() throws SQLException { ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802131#comment-16802131 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269298181 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try(PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + logger.info("Setting maximum resultset size as {} rows", valueToSet); + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + logger.info("MaxRows was set as {} and query limited to 10 returned a resultSet of {} rows", valueToSet, rowCount); Review comment: I had this when i was writing test cases. So, you're right... these are redundant. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802127#comment-16802127 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269251734 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try(PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + logger.info("Setting maximum resultset size as {} rows", valueToSet); + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + logger.info("MaxRows was set as {} and query limited to 10 returned a resultSet of {} rows", valueToSet, rowCount); Review comment: ~~Same as previous comment regarding `final`~~ This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802121#comment-16802121 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269294222 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,17 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +Statement setMaxStmt = this.connection.createStatement(); +setMaxStmt.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); +setMaxStmt.close(); Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802120#comment-16802120 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269293742 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java ## @@ -107,6 +107,23 @@ public QueryContext(final UserSession session, final DrillbitContext drillbitCon this.table = drillbitContext.getOperatorTable(); } +// Checking for limit on ResultSet rowcount and if user attempting to override the system value +final int sessionMaxRowCount = queryOptions.getOption(ExecConstants.QUERY_MAX_ROWS).num_val.intValue(); Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802084#comment-16802084 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269273829 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,17 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +Statement setMaxStmt = this.connection.createStatement(); +setMaxStmt.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); +setMaxStmt.close(); +this.maxRowCount = maxRowCount; Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802069#comment-16802069 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269263831 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try(PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + logger.info("Setting maximum resultset size as {} rows", valueToSet); + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + logger.info("MaxRows was set as {} and query limited to 10 returned a resultSet of {} rows", valueToSet, rowCount); Review comment: What is the purpose of this message? It will be newer read by dev except for the case when a test failed and logging is enabled. But the real purpose may be when this message is moved into an assertion check, so in the case of test failure, it is printed and in other cases, logging does not happen. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802038#comment-16802038 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269255206 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,17 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +Statement setMaxStmt = this.connection.createStatement(); +setMaxStmt.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); +setMaxStmt.close(); +this.maxRowCount = maxRowCount; Review comment: It is important to check that connection is opened at first, and it is done in the parent method. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802032#comment-16802032 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269253834 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java ## @@ -107,6 +107,23 @@ public QueryContext(final UserSession session, final DrillbitContext drillbitCon this.table = drillbitContext.getOperatorTable(); } +// Checking for limit on ResultSet rowcount and if user attempting to override the system value +final int sessionMaxRowCount = queryOptions.getOption(ExecConstants.QUERY_MAX_ROWS).num_val.intValue(); Review comment: I'm not sure that it was exactly the same case, but in this case `final` is redundant. The scope of variable usage is small, and there is no risk of accidental changing its value. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802031#comment-16802031 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269252724 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java ## @@ -537,7 +547,15 @@ public void testclosedPreparedStmtOfOpenConnMethodsThrowRight() { new ClosedPreparedStatementChecker(PreparedStatement.class, closedPreparedStmtOfOpenConn); -checker.testAllMethods(); +//List of methods now supported +@SuppressWarnings("serial") Review comment: Not sure what you meant by the change. Should I remove the SuppressWarnings? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802027#comment-16802027 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269251734 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try(PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + logger.info("Setting maximum resultset size as {} rows", valueToSet); + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + logger.info("MaxRows was set as {} and query limited to 10 returned a resultSet of {} rows", valueToSet, rowCount); Review comment: Same as previous comment regarding `final` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802022#comment-16802022 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269249958 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,17 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +Statement setMaxStmt = this.connection.createStatement(); +setMaxStmt.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); +setMaxStmt.close(); +this.maxRowCount = maxRowCount; Review comment: Ok, but I think it should be done post-close() because in case of a failure, we dont want to accidentally set through `super` and then worry about rolling back. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802013#comment-16802013 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269246088 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,17 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +Statement setMaxStmt = this.connection.createStatement(); +setMaxStmt.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); +setMaxStmt.close(); +this.maxRowCount = maxRowCount; + } + + @Override + public long getLargeMaxRows() { Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16802007#comment-16802007 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269243737 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java ## @@ -283,6 +300,13 @@ public RemoteFunctionRegistry getRemoteFunctionRegistry() { return drillbitContext.getRemoteFunctionRegistry(); } + /** + * Allows to disable autolimit in case it is not applicable + */ + public void disableAutoLimit() { Review comment: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801993#comment-16801993 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269237610 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -72,12 +73,18 @@ public class PreparedStatementTest extends JdbcTestBase { private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementTest.class); + private static final Random RANDOMIZER = new Random(20150304); private static final String SYS_VERSION_SQL = "select * from sys.version"; private static final String SYS_RANDOM_SQL = "SELECT cast(random() as varchar) as myStr FROM (VALUES(1)) " + "union SELECT cast(random() as varchar) as myStr FROM (VALUES(1)) " + "union SELECT cast(random() as varchar) as myStr FROM (VALUES(1)) "; + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + //Locks used across StatementTest and PreparedStatementTest + private static Semaphore maxRowsSysOptionLock = StatementTest.maxRowsSysOptionLock; Review comment: I tried that, but the unit tests attempt to test with setting up specific SYSTEM values. Without this, there is a race condition where both `StatementTest` and `PreparedStatementTest` attempt to set SYSTEM values... and get different results (resulting in test failures). This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801991#comment-16801991 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269236778 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { Review comment: The unit tests use this method to set and release the lock. It reduces the lock code being repeated across unit tests. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801990#comment-16801990 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269235963 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -239,4 +246,173 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try(Statement stmt = connection.createStatement()) { + int maxRowsValue = stmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting negative value + int valueToSet = -10; + try { +stmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + logger.info("Setting maximum resultset size as {} rows", valueToSet); + stmt.setMaxRows(valueToSet); + assertEquals( valueToSet, stmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (Statement stmt = connection.createStatement()) { + stmt.setMaxRows(0); + stmt.executeQuery(SYS_OPTIONS_SQL); + ResultSet rs = stmt.getResultSet(); Review comment: Ok, but `Statement.close()` also closes the `ResultSet` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801989#comment-16801989 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269235600 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { +// Acquire lock if Non-Zero Value (i.e. a test is in progress) +if (sysValueToSet != 0) { + maxRowsSysOptionLock.acquireUninterruptibly(); +} +// Setting the value +try (Statement stmt = connection.createStatement()) { + stmt.executeQuery(ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X + sysValueToSet); + ResultSet rs = stmt.getResultSet(); Review comment: No. If the query fails, you won't get the resultset object. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801987#comment-16801987 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269235028 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java ## @@ -541,9 +546,9 @@ private void runPreparedStatement(final PreparedStatementHandle preparedStatemen ServerPreparedStatementState.PARSER.parseFrom(preparedStatementHandle.getServerInfo()); } catch (final InvalidProtocolBufferException ex) { throw UserException.parseError(ex) - .message("Failed to parse the prepared statement handle. " + - "Make sure the handle is same as one returned from create prepared statement call.") - .build(logger); + .message("Failed to parse the prepared statement handle. " + Review comment: Ok. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801986#comment-16801986 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269234329 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java ## @@ -143,13 +143,18 @@ public Foreman(final WorkerBee bee, final DrillbitContext drillbitContext, this.closeFuture = initiatingClient.getChannelClosureFuture(); closeFuture.addListener(closeListener); +// Apply AutoLimit on resultSet (Usually received via REST APIs) +final int autoLimit = queryRequest.getAutolimitRowcount(); +if (autoLimit > 0) { + connection.getSession().getOptions().setLocalOption(ExecConstants.QUERY_MAX_ROWS, autoLimit); +} this.queryContext = new QueryContext(connection.getSession(), drillbitContext, queryId); this.queryManager = new QueryManager(queryId, queryRequest, drillbitContext.getStoreProvider(), drillbitContext.getClusterCoordinator(), this); this.queryRM = drillbitContext.getResourceManager().newQueryRM(this); this.fragmentsRunner = new FragmentsRunner(bee, initiatingClient, drillbitContext, this); -this.queryStateProcessor = new QueryStateProcessor(queryIdString, queryManager, drillbitContext, new ForemanResult()); this.profileOption = setProfileOption(queryContext.getOptions()); +this.queryStateProcessor = new QueryStateProcessor(queryIdString, queryManager, drillbitContext, new ForemanResult()); Review comment: Since I was originally changing the ForemanResult, I had reordered to ensure that the `queryContext` was set with the right values before the `queryStateProcessor` is initialized. I'll reorder to the original way, This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801983#comment-16801983 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269232507 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java ## @@ -107,6 +107,23 @@ public QueryContext(final UserSession session, final DrillbitContext drillbitCon this.table = drillbitContext.getOperatorTable(); } +// Checking for limit on ResultSet rowcount and if user attempting to override the system value +final int sessionMaxRowCount = queryOptions.getOption(ExecConstants.QUERY_MAX_ROWS).num_val.intValue(); Review comment: In previous reviews, I've been asked to keep immutable variables as `final`. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801591#comment-16801591 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269027601 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,17 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +Statement setMaxStmt = this.connection.createStatement(); +setMaxStmt.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); +setMaxStmt.close(); +this.maxRowCount = maxRowCount; Review comment: Please remove this line and put into the beginning of the method call `super.setLargeMaxRows(maxRowCount)`, so it will check that connection is open and validate `maxRowCount` value. The same for changes in `DrillStatementImpl`. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801592#comment-16801592 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269032278 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try(PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + int maxRowsValue = pStmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting negative value + int valueToSet = -10; + try { +pStmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + //Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + logger.info("Setting maximum resultset size as {} rows", valueToSet); + pStmt.setMaxRows(valueToSet); + assertEquals( valueToSet, pStmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { + pStmt.setMaxRows(0); + pStmt.execute(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + assertTrue(rowCount > 0); +} + } + + /** + * Test setting maxSize at a value lower than existing query limit + */ + @Test + public void testSetMaxRowsLowerThanQueryLimit() throws SQLException { +try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL_LIMIT_10)) { + int valueToSet = RANDOMIZER.nextInt(9)+1; //range:[1-9] + pStmt.setMaxRows(valueToSet); + pStmt.executeQuery(); + ResultSet rs = pStmt.getResultSet(); + int rowCount = 0; + while (rs.next()) { +rs.getBytes(1); +rowCount++; + } + logger.info("MaxRows was set as {} and query limited to 10 returned a resultSet of {} rows", valueToSet, rowCount); Review comment: Please remove loggers from unit tests, it is redundant. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801588#comment-16801588 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269027913 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,17 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +Statement setMaxStmt = this.connection.createStatement(); +setMaxStmt.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); +setMaxStmt.close(); +this.maxRowCount = maxRowCount; + } + + @Override + public long getLargeMaxRows() { Review comment: Please remove this method since Avatica provides its implementation. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801590#comment-16801590 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269029315 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -410,6 +417,155 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try(PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { Review comment: Please add spaces here and in other places where needed (and remove where they are excessive, like in the signature of this test). ```suggestion try (PreparedStatement pStmt = connection.prepareStatement(SYS_OPTIONS_SQL)) { ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801597#comment-16801597 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269033910 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { +// Acquire lock if Non-Zero Value (i.e. a test is in progress) +if (sysValueToSet != 0) { + maxRowsSysOptionLock.acquireUninterruptibly(); +} +// Setting the value +try (Statement stmt = connection.createStatement()) { + stmt.executeQuery(ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X + sysValueToSet); + ResultSet rs = stmt.getResultSet(); Review comment: Is it required to obtain a result set and iterate thru it? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801583#comment-16801583 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269013774 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java ## @@ -107,6 +107,23 @@ public QueryContext(final UserSession session, final DrillbitContext drillbitCon this.table = drillbitContext.getOperatorTable(); } +// Checking for limit on ResultSet rowcount and if user attempting to override the system value +final int sessionMaxRowCount = queryOptions.getOption(ExecConstants.QUERY_MAX_ROWS).num_val.intValue(); Review comment: There is no need to make these variables final. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801587#comment-16801587 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269025296 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/QueryManager.java ## @@ -379,6 +379,12 @@ private QueryProfile getQueryProfile(UserException ex) { profileBuilder.setQuery(queryText); } +final int autoLimitRowCount = foreman.getQueryContext().getOptions().getOption(ExecConstants.QUERY_MAX_ROWS).num_val.intValue(); Review comment: Please remove `final` modifier here and in other places where it is not required. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801594#comment-16801594 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269039279 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/StatementTest.java ## @@ -239,4 +246,173 @@ public void testNonTriggeredQueryTimeout() throws SQLException { } } + + // Query maxRows methods: + + /** + * Test for reading of default max rows + */ + @Test + public void testDefaultGetMaxRows() throws SQLException { +try(Statement stmt = connection.createStatement()) { + int maxRowsValue = stmt.getMaxRows(); + assertEquals(0, maxRowsValue); +} + } + + /** + * Test Invalid parameter by giving negative maxRows value + */ + @Test + public void testInvalidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting negative value + int valueToSet = -10; + try { +stmt.setMaxRows(valueToSet); + } catch ( final SQLException e) { +assertThat( e.getMessage(), containsString("VALIDATION ERROR: Option exec.query.max_rows must be between 0 and ") ); + } +} + } + + /** + * Test setting a valid maxRows value + */ + @Test + public void testValidSetMaxRows() throws SQLException { +try (Statement stmt = connection.createStatement()) { + // Setting positive value + int valueToSet = RANDOMIZER.nextInt(59)+1; + logger.info("Setting maximum resultset size as {} rows", valueToSet); + stmt.setMaxRows(valueToSet); + assertEquals( valueToSet, stmt.getMaxRows() ); +} + } + + /** + * Test setting maxSize as zero (i.e. no Limit) + */ + @Test + public void testSetMaxRowsAsZero() throws SQLException { +try (Statement stmt = connection.createStatement()) { + stmt.setMaxRows(0); + stmt.executeQuery(SYS_OPTIONS_SQL); + ResultSet rs = stmt.getResultSet(); Review comment: `ResultSet` should be also closed. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801586#comment-16801586 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269021867 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java ## @@ -143,13 +143,18 @@ public Foreman(final WorkerBee bee, final DrillbitContext drillbitContext, this.closeFuture = initiatingClient.getChannelClosureFuture(); closeFuture.addListener(closeListener); +// Apply AutoLimit on resultSet (Usually received via REST APIs) +final int autoLimit = queryRequest.getAutolimitRowcount(); +if (autoLimit > 0) { + connection.getSession().getOptions().setLocalOption(ExecConstants.QUERY_MAX_ROWS, autoLimit); +} this.queryContext = new QueryContext(connection.getSession(), drillbitContext, queryId); this.queryManager = new QueryManager(queryId, queryRequest, drillbitContext.getStoreProvider(), drillbitContext.getClusterCoordinator(), this); this.queryRM = drillbitContext.getResourceManager().newQueryRM(this); this.fragmentsRunner = new FragmentsRunner(bee, initiatingClient, drillbitContext, this); -this.queryStateProcessor = new QueryStateProcessor(queryIdString, queryManager, drillbitContext, new ForemanResult()); this.profileOption = setProfileOption(queryContext.getOptions()); +this.queryStateProcessor = new QueryStateProcessor(queryIdString, queryManager, drillbitContext, new ForemanResult()); Review comment: Could you please explain the reason for this change? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801595#comment-16801595 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269039838 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java ## @@ -537,7 +547,15 @@ public void testclosedPreparedStmtOfOpenConnMethodsThrowRight() { new ClosedPreparedStatementChecker(PreparedStatement.class, closedPreparedStmtOfOpenConn); -checker.testAllMethods(); +//List of methods now supported +@SuppressWarnings("serial") Review comment: Please revert these changes in this class once calls to Avatica methods are used. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801589#comment-16801589 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269026715 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java ## @@ -259,4 +261,17 @@ public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throw checkOpen(); super.setObject(parameterIndex, x, targetSqlType); } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +Statement setMaxStmt = this.connection.createStatement(); +setMaxStmt.execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`=" + maxRowCount); +setMaxStmt.close(); Review comment: Please use `try with resources` for `Statement` instead of manually closing it. Also, please rename `setMaxStmt` into `statement`. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801596#comment-16801596 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269038543 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -462,4 +618,25 @@ public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLExcep } } + + // Sets the SystemMaxRows option + private void setSystemMaxRows(int sysValueToSet) throws SQLException { Review comment: I'm not sure that the approach used for blocking the connection should be implemented in this method. I think unit tests should acquire and release the lock. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801585#comment-16801585 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269022764 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java ## @@ -541,9 +546,9 @@ private void runPreparedStatement(final PreparedStatementHandle preparedStatemen ServerPreparedStatementState.PARSER.parseFrom(preparedStatementHandle.getServerInfo()); } catch (final InvalidProtocolBufferException ex) { throw UserException.parseError(ex) - .message("Failed to parse the prepared statement handle. " + - "Make sure the handle is same as one returned from create prepared statement call.") - .build(logger); + .message("Failed to parse the prepared statement handle. " + Review comment: The initial indentation was better, please revert this change. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801593#comment-16801593 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269036148 ## File path: exec/jdbc/src/test/java/org/apache/drill/jdbc/PreparedStatementTest.java ## @@ -72,12 +73,18 @@ public class PreparedStatementTest extends JdbcTestBase { private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PreparedStatementTest.class); + private static final Random RANDOMIZER = new Random(20150304); private static final String SYS_VERSION_SQL = "select * from sys.version"; private static final String SYS_RANDOM_SQL = "SELECT cast(random() as varchar) as myStr FROM (VALUES(1)) " + "union SELECT cast(random() as varchar) as myStr FROM (VALUES(1)) " + "union SELECT cast(random() as varchar) as myStr FROM (VALUES(1)) "; + private static final String SYS_OPTIONS_SQL = "SELECT * FROM sys.options"; + private static final String SYS_OPTIONS_SQL_LIMIT_10 = "SELECT * FROM sys.options LIMIT 12"; + private static final String ALTER_SYS_OPTIONS_MAX_ROWS_LIMIT_X = "ALTER SYSTEM SET `" + ExecConstants.QUERY_MAX_ROWS + "`="; + //Locks used across StatementTest and PreparedStatementTest + private static Semaphore maxRowsSysOptionLock = StatementTest.maxRowsSysOptionLock; Review comment: `connection` is created in this class, but the same `Semaphore` is used from `StatementTest` class for this test class and another one. Should they use their own instances of `Semaphore`? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801584#comment-16801584 ] ASF GitHub Bot commented on DRILL-7048: --- vvysotskyi commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r269016874 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java ## @@ -283,6 +300,13 @@ public RemoteFunctionRegistry getRemoteFunctionRegistry() { return drillbitContext.getRemoteFunctionRegistry(); } + /** + * Allows to disable autolimit in case it is not applicable + */ + public void disableAutoLimit() { Review comment: This method also may be inlined. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16801044#comment-16801044 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on issue #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#issuecomment-476368650 @vvysotskyi made changes and verified that tests passed. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16800974#comment-16800974 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r268800813 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillStatementImpl.java ## @@ -270,4 +271,10 @@ public void setResultSet(AvaticaResultSet resultSet) { public void setUpdateCount(int value) { updateCount = value; } + + @Override + public void setLargeMaxRows(long maxRowCount) throws SQLException { +execute("ALTER SESSION SET `" + ExecConstants.QUERY_MAX_ROWS + "`="+maxRowCount); +this.maxRowCount = maxRowCount; Review comment: We need this here to ensure that when `getLargeMaxRows()` is called, we are reading it back from the value that was set using `setLargeMaxRows()`. Avatica only holds the value that has been set. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-7048) Implement JDBC Statement.setMaxRows() with System Option
[ https://issues.apache.org/jira/browse/DRILL-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16800919#comment-16800919 ] ASF GitHub Bot commented on DRILL-7048: --- kkhatua commented on pull request #1714: DRILL-7048: Implement JDBC Statement.setMaxRows() with System Option URL: https://github.com/apache/drill/pull/1714#discussion_r268772086 ## File path: exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillPreparedStatement.java ## @@ -32,4 +33,25 @@ */ public interface DrillPreparedStatement extends PreparedStatement { + /** + * @throws SQLException + *Any SQL exception + */ + @Override + int getMaxRows() throws SQLException; Review comment: I think I was declaring it because it seemed Avatica preferred using `setLargeMaxRows() / getLargeMaxRows()` . I, anyway, cannot really override this (all calls to `setMaxRows() / getMaxRows()` are redirected to the `...Large...` methods), so I'll remove it. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement JDBC Statement.setMaxRows() with System Option > > > Key: DRILL-7048 > URL: https://issues.apache.org/jira/browse/DRILL-7048 > Project: Apache Drill > Issue Type: New Feature > Components: Client - JDBC, Query Planning Optimization >Affects Versions: 1.15.0 >Reporter: Kunal Khatua >Assignee: Kunal Khatua >Priority: Major > Labels: doc-impacting > Fix For: 1.17.0 > > > With DRILL-6960, the webUI will get an auto-limit on the number of results > fetched. > Since more of the plumbing is already there, it makes sense to provide the > same for the JDBC client. > In addition, it would be nice if the Server can have a pre-defined value as > well (default 0; i.e. no limit) so that an _admin_ would be able to ensure a > max limit on the resultset size as well. -- This message was sent by Atlassian JIRA (v7.6.3#76005)