Skip to content

Commit c08cf71

Browse files
authored
[PECO-1083] Update Go Thrift files to reflect V8 and add version checking for parameterized queries (#165)
We recently updated the runtime thrift file to add a new version to support parameterized queries.
2 parents f5b366e + beea4c4 commit c08cf71

File tree

7 files changed

+742
-116
lines changed

7 files changed

+742
-116
lines changed

connection.go

Lines changed: 9 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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/cli_service/GoUnusedProtection__.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cli_service/cli_service-consts.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)