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

SQL: Extract SQL request and response classes #30457

Merged

Conversation

imotov
Copy link
Contributor

@imotov imotov commented May 8, 2018

Extracts SQL request and response classes. This is the first step
towards creation of a small minimal dependencies jdbc driver.

Relates #29856

Extracts SQL request and response classes. This is the first step
towards creation of a small minimal dependencies jdbc driver.

Relates elastic#29856
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs


@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
// This is needed just to test parsing of SqlTranslateRequest, so we can reuse SqlQuerySerialization
Copy link
Member

Choose a reason for hiding this comment

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

What if you remove the xcontent stuff from the requests and responses entirely and always use the objects from the sql-proto jar for that. On the way in you'd parse using the proto objects and then build this request from the proto object. On the way out you'd use a response to build the proto object and then let it render the xcontent. No more funny round trip testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nik9000 then we are going back to all the weirdness with QueryBuilder that you so didn't like in the previous iteration.

Copy link
Member

Choose a reason for hiding this comment

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

Nah, I don't mean that the Request and Response should contain the proto objects, but that they should be built from them or build them.

Copy link
Member

Choose a reason for hiding this comment

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

I see now - we can't parse the XContent in proto because it contains a QueryBuilder.

@imotov
Copy link
Contributor Author

imotov commented May 8, 2018

retest this please

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

Ok. I get it now. I think this is indeed better than the other way. Do you want to merge this as is and then make a followup to shuffle things around and remove the deps?


@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
// This is needed just to test parsing of SqlTranslateRequest, so we can reuse SqlQuerySerialization
Copy link
Member

Choose a reason for hiding this comment

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

I see now - we can't parse the XContent in proto because it contains a QueryBuilder.

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

Left some minor comments; LGTM

@@ -43,7 +43,7 @@
private String catalog;
private String schema;

public JdbcConnection(JdbcConfiguration connectionInfo) throws SQLException {
public JdbcConnection(JdbcConfiguration connectionInfo) {
Copy link
Member

Choose a reason for hiding this comment

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

The SQLException is the only type of Exception the JDBC API can throw (and that the user expects).
If we remove it, we need to make sure no other types of Exceptions (runtime or otherwise) are thrown - is that the case here?
Otherwise they need to be converted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I will bring it back and add a comment.

@@ -7,7 +7,7 @@

import org.elasticsearch.xpack.sql.jdbc.net.client.Cursor;
import org.elasticsearch.xpack.sql.jdbc.net.client.RequestMeta;
import org.elasticsearch.xpack.sql.plugin.SqlTypedParamValue;
import org.elasticsearch.xpack.sql.proto.SqlTypedParamValue;
Copy link
Member

Choose a reason for hiding this comment

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

+1 for the package change.

*/
public enum Mode {
PLAIN,
JDBC;
Copy link
Member

Choose a reason for hiding this comment

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

I propose to rename JDBC to something like DRIVER or METADATA since it's used by ODBC as well (can be a follow-up since this PR passes).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think it is out of scope for this PR.

/**
* Global choice for the default fetch size.
*/
public static final int FETCH_SIZE = 1000;
Copy link
Member

Choose a reason for hiding this comment

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

We need to be careful in externalizing the defaults as outside the initial config, we should always be explicit about the values of these parameters since they are user configurable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just moved them from the original request here since we now have 2 requests. We can address this, but I think it should be in another PR, since this will change the protocol as well (these parameters are used not only for the initial client config, but also on the server side as part of the protocol. For example, we don't serialize these parameters if they have default values.)

Copy link
Contributor Author

@imotov imotov left a comment

Choose a reason for hiding this comment

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

Will push an update in a bit.

*/
public enum Mode {
PLAIN,
JDBC;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think it is out of scope for this PR.

@@ -43,7 +43,7 @@
private String catalog;
private String schema;

public JdbcConnection(JdbcConfiguration connectionInfo) throws SQLException {
public JdbcConnection(JdbcConfiguration connectionInfo) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I will bring it back and add a comment.

/**
* Global choice for the default fetch size.
*/
public static final int FETCH_SIZE = 1000;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just moved them from the original request here since we now have 2 requests. We can address this, but I think it should be in another PR, since this will change the protocol as well (these parameters are used not only for the initial client config, but also on the server side as part of the protocol. For example, we don't serialize these parameters if they have default values.)

@imotov
Copy link
Contributor Author

imotov commented May 11, 2018

retest this please

@imotov imotov merged commit 56d32bc into elastic:master May 14, 2018
imotov added a commit that referenced this pull request May 15, 2018
Extracts SQL request and response classes. This is the first step
towards creation of a small minimal dependencies jdbc driver.

Relates #29856
dnhatn added a commit that referenced this pull request May 15, 2018
* 6.x:
  Revert "Silence IndexUpgradeIT test failures. (#30430)"
  [DOCS] Remove references to changelog and to highlights
  Revert "Mute ML upgrade test (#30458)"
  [ML] Fix BWC version for backport of #30125
  [Docs] Improve section detailing translog usage (#30573)
  [Tests] Relax allowed delta in extended_stats aggregation (#30569)
  Fail if reading from closed KeyStoreWrapper (#30394)
  [ML] Reverse engineer Grok patterns from categorization results (#30125)
  Derive max composite buffers from max content len
  Update build file due to doc file rename
  SQL: Extract SQL request and response classes (#30457)
  Remove the changelog (#30593)
  Revert "Add deprecation warning for default shards (#30587)"
  Silence IndexUpgradeIT test failures. (#30430)
  Add deprecation warning for default shards (#30587)
  [DOCS] Adds 6.4.0 release highlight pages
  [DOCS] Adds release highlight pages (#30590)
  Docs: Document how to rebuild analyzers (#30498)
  [DOCS] Fixes title capitalization in security content
  LLRest: Add equals and hashcode tests for Request (#30584)
  [DOCS] Fix realm setting names (#30499)
  [DOCS] Fix path info for various security files (#30502)
  Docs: document precision limitations of geo_bounding_box (#30540)
  Fix non existing javadocs link in RestClientTests
  Auto-expand replicas only after failing nodes (#30553)
@imotov imotov deleted the issue-29856-extract-jdbc-protocol-classes branch May 1, 2020 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants