diff --git a/connection.go b/connection.go index a387d07..26386fd 100644 --- a/connection.go +++ b/connection.go @@ -101,6 +101,10 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name ctx = driverctx.NewContextWithConnId(ctx, c.id) + if len(args) > 0 && c.session.ServerProtocolVersion < cli_service.TProtocolVersion_SPARK_CLI_SERVICE_PROTOCOL_V8 { + return nil, dbsqlerrint.NewDriverError(ctx, dbsqlerr.ErrParametersNotSupported, nil) + } + exStmtResp, opStatusResp, err := c.runQuery(ctx, query, args) if exStmtResp != nil && exStmtResp.OperationHandle != nil { @@ -141,6 +145,10 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam ctx = driverctx.NewContextWithConnId(ctx, c.id) + if len(args) > 0 && c.session.ServerProtocolVersion < cli_service.TProtocolVersion_SPARK_CLI_SERVICE_PROTOCOL_V8 { + return nil, dbsqlerrint.NewDriverError(ctx, dbsqlerr.ErrParametersNotSupported, nil) + } + // first we try to get the results synchronously. // at any point in time that the context is done we must cancel and return exStmtResp, opStatusResp, err := c.runQuery(ctx, query, args) @@ -274,7 +282,7 @@ func (c *conn) executeStatement(ctx context.Context, query string, args []driver req := cli_service.TExecuteStatementReq{ SessionHandle: c.session.SessionHandle, Statement: query, - RunAsync: c.cfg.RunAsync, + RunAsync: true, QueryTimeout: int64(c.cfg.QueryTimeout / time.Second), GetDirectResults: &cli_service.TSparkGetDirectResults{ MaxRows: int64(c.cfg.MaxRows), diff --git a/errors/errors.go b/errors/errors.go index 600f887..6a71245 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -14,6 +14,7 @@ const ( ErrTransactionsNotSupported = "transactions are not supported" ErrReadQueryStatus = "could not read query status" ErrSentinelTimeout = "sentinel timed out waiting for operation to complete" + ErrParametersNotSupported = "query parameters are not supported by this server" // Request error messages (connection, authentication, network error) ErrCloseConnection = "failed to close connection" diff --git a/internal/config/config.go b/internal/config/config.go index b6ccace..d5ede1c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -29,7 +29,6 @@ type Config struct { UserConfig TLSConfig *tls.Config // nil disables TLS ArrowConfig - RunAsync bool // TODO PollInterval time.Duration ClientTimeout time.Duration // max time the http request can last PingTimeout time.Duration // max time allowed for ping @@ -68,7 +67,6 @@ func (c *Config) DeepCopy() *Config { UserConfig: c.UserConfig.DeepCopy(), TLSConfig: c.TLSConfig.Clone(), ArrowConfig: c.ArrowConfig.DeepCopy(), - RunAsync: c.RunAsync, PollInterval: c.PollInterval, ClientTimeout: c.ClientTimeout, PingTimeout: c.PingTimeout, @@ -188,7 +186,6 @@ func WithDefaults() *Config { UserConfig: UserConfig{}.WithDefaults(), TLSConfig: &tls.Config{MinVersion: tls.VersionTLS12}, ArrowConfig: ArrowConfig{}.WithDefaults(), - RunAsync: true, PollInterval: 1 * time.Second, ClientTimeout: 900 * time.Second, PingTimeout: 60 * time.Second, @@ -196,7 +193,7 @@ func WithDefaults() *Config { DriverName: "godatabrickssqlconnector", // important. Do not change ThriftProtocol: "binary", ThriftTransport: "http", - ThriftProtocolVersion: cli_service.TProtocolVersion_SPARK_CLI_SERVICE_PROTOCOL_V7, + ThriftProtocolVersion: cli_service.TProtocolVersion_SPARK_CLI_SERVICE_PROTOCOL_V8, ThriftDebugClientProtocol: false, } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index df5e4bd..3def76b 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -640,7 +640,6 @@ func TestConfig_DeepCopy(t *testing.T) { cfg := &Config{ UserConfig: UserConfig{}.WithDefaults(), TLSConfig: &tls.Config{MinVersion: tls.VersionTLS12}, - RunAsync: true, PollInterval: 1 * time.Second, ClientTimeout: 900 * time.Second, PingTimeout: 15 * time.Second,