Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRILL-6834: Introduce option to disable result set on CTAS, create vi… #1549

Closed
wants to merge 1 commit into from

Conversation

KazydubB
Copy link
Member

@KazydubB KazydubB commented Nov 21, 2018

…ew and drop table/view etc. for JDBC connection

  • Added session-scoped option drill.exec.fetch_resultset_for_ddl to control whether update count or result set should be returned for JDBC connection session. Eligible queries are CTAS, CREATE VIEW, CREATE FUNCTION, DROP TABLE, DROP VIEW, DROP FUNCTION, USE schema, SET option, REFRESH METADATA TABLE. By default the option is set to true which ensures that result set is returned;
  • Updated Drill JDBC: DrillCursor and DrillStatement to achieve desired behaviour;

Copy link
Member

@vvysotskyi vvysotskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question regarding the used approach. With the current implementation, updateCount is taken from the writer, or somewhere else and set to the hidden value vector, which is handled later. Is it possible to use some other mechanisms to specify updateCount, for example, use additional query option etc?

if (qrb.getHeader().hasUpdateCount()) {
int updateCount = qrb.getHeader().getUpdateCount();
int currentUpdateCount = statement.getUpdateCount() == -1 ? 0 : statement.getUpdateCount();
((DrillStatement) statement).setUpdateCount(updateCount + currentUpdateCount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to set updateCount and other fields which are changed there during statement creation? It may allow us to avoid adding additional setters to the DrillStatement interface.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not, because ResultSet is set before actual data is queried (AvaticaConnection).
However, DrillStatement#setResultSet(AvaticaResultSet) may be removed and openResultSet (see DrillStatementImpl below) can be nullified when update count is set with #setUpdateCount(int) method.

Copy link
Member Author

@KazydubB KazydubB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vvysotskyi, I've updated the PR, please take a look.

Regarding your question, I do not see any other mechanism (yet) for passing affected row (update) count. Passing it as an option is not a good idea either, because the updateCount is actually a query result.

if (qrb.getHeader().hasUpdateCount()) {
int updateCount = qrb.getHeader().getUpdateCount();
int currentUpdateCount = statement.getUpdateCount() == -1 ? 0 : statement.getUpdateCount();
((DrillStatement) statement).setUpdateCount(updateCount + currentUpdateCount);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not, because ResultSet is set before actual data is queried (AvaticaConnection).
However, DrillStatement#setResultSet(AvaticaResultSet) may be removed and openResultSet (see DrillStatementImpl below) can be nullified when update count is set with #setUpdateCount(int) method.

@KazydubB KazydubB force-pushed the DRILL-6834 branch 5 times, most recently from fac1d40 to d463641 Compare November 23, 2018 18:21
@@ -34,7 +34,15 @@ public FragmentOptionManager(OptionManager systemOptions, OptionList options) {

private static Map<String, OptionValue> getMapFromOptionList(final OptionList options) {
final Map<String, OptionValue> tmp = Maps.newHashMap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please replace Maps.newHashMap() with constructor

for (final OptionValue option : options) {
OptionValue value = tmp.get(option.name);
if (value != null) {
// As there may be the same option defined for different scopes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain cases, when the same option defined for different scopes will be present in options list. Should this logic be added to other option managers?

Is it possible to construct options list considering options precedence to avoid adding the same logic for other option managers?


assertFalse("SET query should not return result set", hasResult);
assertNull("No result", s.getResultSet());
assertNotEquals("Update count should be >= 0", -1, s.getUpdateCount());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that we should also verify updateCount value. It is required to check that there is no result set.

Copy link
Member

@vvysotskyi vvysotskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making changes, +1

@KazydubB
Copy link
Member Author

KazydubB commented Nov 26, 2018

@vvysotskyi, thanks for your review. I've updated the PR

…r JDBC connection

- Added session-scoped option `drill.exec.fetch_resultset_for_ddl` to control whether update count or result set should be returned for JDBC connection session. By default the option is set to `true` which ensures that result set is returned;
- Updated Drill JDBC: `DrillCursor` and `DrillStatement` to achieve desired behaviour.
@asfgit asfgit closed this in cd4d68b Nov 26, 2018
mattpollack pushed a commit to mattpollack/drill that referenced this pull request Feb 25, 2019
…r JDBC connection

- Added session-scoped option `drill.exec.fetch_resultset_for_ddl` to control whether update count or result set should be returned for JDBC connection session. By default the option is set to `true` which ensures that result set is returned;
- Updated Drill JDBC: `DrillCursor` and `DrillStatement` to achieve desired behaviour.

closes apache#1549
lushuifeng pushed a commit to lushuifeng/drill that referenced this pull request Jun 21, 2019
…r JDBC connection

- Added session-scoped option `drill.exec.fetch_resultset_for_ddl` to control whether update count or result set should be returned for JDBC connection session. By default the option is set to `true` which ensures that result set is returned;
- Updated Drill JDBC: `DrillCursor` and `DrillStatement` to achieve desired behaviour.

closes apache#1549
xiangt920 pushed a commit to xiangt920/drill that referenced this pull request Dec 26, 2019
…r JDBC connection

- Added session-scoped option `drill.exec.fetch_resultset_for_ddl` to control whether update count or result set should be returned for JDBC connection session. By default the option is set to `true` which ensures that result set is returned;
- Updated Drill JDBC: `DrillCursor` and `DrillStatement` to achieve desired behaviour.

closes apache#1549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants