-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
SQL: Extract SQL request and response classes #30457
Conversation
Extracts SQL request and response classes. This is the first step towards creation of a small minimal dependencies jdbc driver. Relates elastic#29856
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
retest this please |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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 Exception
s (runtime or otherwise) are thrown - is that the case here?
Otherwise they need to be converted.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.)
There was a problem hiding this 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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.)
retest this please |
…t-jdbc-protocol-classes
Extracts SQL request and response classes. This is the first step towards creation of a small minimal dependencies jdbc driver. Relates #29856
* 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)
Extracts SQL request and response classes. This is the first step
towards creation of a small minimal dependencies jdbc driver.
Relates #29856