Skip to content

Commit beea4c4

Browse files
committed
Introduced protocol checking
1 parent 388ec47 commit beea4c4

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

connection.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name
101101

102102
ctx = driverctx.NewContextWithConnId(ctx, c.id)
103103

104+
if len(args) > 0 && c.session.ServerProtocolVersion < cli_service.TProtocolVersion_SPARK_CLI_SERVICE_PROTOCOL_V8 {
105+
return nil, dbsqlerrint.NewDriverError(ctx, dbsqlerr.ErrParametersNotSupported, nil)
106+
}
107+
104108
exStmtResp, opStatusResp, err := c.runQuery(ctx, query, args)
105109

106110
if exStmtResp != nil && exStmtResp.OperationHandle != nil {
@@ -141,6 +145,10 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam
141145

142146
ctx = driverctx.NewContextWithConnId(ctx, c.id)
143147

148+
if len(args) > 0 && c.session.ServerProtocolVersion < cli_service.TProtocolVersion_SPARK_CLI_SERVICE_PROTOCOL_V8 {
149+
return nil, dbsqlerrint.NewDriverError(ctx, dbsqlerr.ErrParametersNotSupported, nil)
150+
}
151+
144152
// first we try to get the results synchronously.
145153
// at any point in time that the context is done we must cancel and return
146154
exStmtResp, opStatusResp, err := c.runQuery(ctx, query, args)
@@ -274,7 +282,7 @@ func (c *conn) executeStatement(ctx context.Context, query string, args []driver
274282
req := cli_service.TExecuteStatementReq{
275283
SessionHandle: c.session.SessionHandle,
276284
Statement: query,
277-
RunAsync: c.cfg.RunAsync,
285+
RunAsync: true,
278286
QueryTimeout: int64(c.cfg.QueryTimeout / time.Second),
279287
GetDirectResults: &cli_service.TSparkGetDirectResults{
280288
MaxRows: int64(c.cfg.MaxRows),

errors/errors.go

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const (
1414
ErrTransactionsNotSupported = "transactions are not supported"
1515
ErrReadQueryStatus = "could not read query status"
1616
ErrSentinelTimeout = "sentinel timed out waiting for operation to complete"
17+
ErrParametersNotSupported = "query parameters are not supported by this server"
1718

1819
// Request error messages (connection, authentication, network error)
1920
ErrCloseConnection = "failed to close connection"

internal/config/config.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type Config struct {
2929
UserConfig
3030
TLSConfig *tls.Config // nil disables TLS
3131
ArrowConfig
32-
RunAsync bool // TODO
3332
PollInterval time.Duration
3433
ClientTimeout time.Duration // max time the http request can last
3534
PingTimeout time.Duration // max time allowed for ping
@@ -68,7 +67,6 @@ func (c *Config) DeepCopy() *Config {
6867
UserConfig: c.UserConfig.DeepCopy(),
6968
TLSConfig: c.TLSConfig.Clone(),
7069
ArrowConfig: c.ArrowConfig.DeepCopy(),
71-
RunAsync: c.RunAsync,
7270
PollInterval: c.PollInterval,
7371
ClientTimeout: c.ClientTimeout,
7472
PingTimeout: c.PingTimeout,
@@ -188,15 +186,14 @@ func WithDefaults() *Config {
188186
UserConfig: UserConfig{}.WithDefaults(),
189187
TLSConfig: &tls.Config{MinVersion: tls.VersionTLS12},
190188
ArrowConfig: ArrowConfig{}.WithDefaults(),
191-
RunAsync: true,
192189
PollInterval: 1 * time.Second,
193190
ClientTimeout: 900 * time.Second,
194191
PingTimeout: 60 * time.Second,
195192
CanUseMultipleCatalogs: true,
196193
DriverName: "godatabrickssqlconnector", // important. Do not change
197194
ThriftProtocol: "binary",
198195
ThriftTransport: "http",
199-
ThriftProtocolVersion: cli_service.TProtocolVersion_SPARK_CLI_SERVICE_PROTOCOL_V7,
196+
ThriftProtocolVersion: cli_service.TProtocolVersion_SPARK_CLI_SERVICE_PROTOCOL_V8,
200197
ThriftDebugClientProtocol: false,
201198
}
202199

internal/config/config_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,6 @@ func TestConfig_DeepCopy(t *testing.T) {
640640
cfg := &Config{
641641
UserConfig: UserConfig{}.WithDefaults(),
642642
TLSConfig: &tls.Config{MinVersion: tls.VersionTLS12},
643-
RunAsync: true,
644643
PollInterval: 1 * time.Second,
645644
ClientTimeout: 900 * time.Second,
646645
PingTimeout: 15 * time.Second,

0 commit comments

Comments
 (0)