Skip to content

Commit d8bb0c9

Browse files
authored
Removed old comments and transferred todos to jira (#82)
Stale comments from development work removed. TODOs and call-outs transferred to Jira (Go Driver v1.1 epic) Signed-off-by: Matthew Kim <[email protected]>
2 parents d470885 + 7ecf65c commit d8bb0c9

File tree

7 files changed

+4
-71
lines changed

7 files changed

+4
-71
lines changed

connection.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name
117117
}
118118
}
119119
if err != nil {
120-
// TODO: are there error situations in which the operation still needs to be closed?
121-
// Currently if there is an error we never get back a TExecuteStatementResponse so
122-
// can't try to close.
123120
log.Err(err).Msgf("databricks: failed to execute query: query %s", query)
124121
return nil, wrapErrf(err, "failed to execute query")
125122
}
@@ -153,7 +150,6 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam
153150
defer log.Duration(msg, start)
154151

155152
if err != nil {
156-
// gotta also think about close operation here
157153
log.Err(err).Msgf("databricks: failed to run query: query %s", query)
158154
return nil, wrapErrf(err, "failed to run query")
159155
}
@@ -175,7 +171,6 @@ func (c *conn) runQuery(ctx context.Context, query string, args []driver.NamedVa
175171
if err != nil {
176172
return exStmtResp, nil, err
177173
}
178-
// hold on to the operation handle
179174
opHandle := exStmtResp.OperationHandle
180175
if opHandle != nil && opHandle.OperationId != nil {
181176
log = logger.WithContext(
@@ -191,14 +186,12 @@ func (c *conn) runQuery(ctx context.Context, query string, args []driver.NamedVa
191186
// terminal states
192187
// good
193188
case cli_service.TOperationState_FINISHED_STATE:
194-
// return results
195189
return exStmtResp, opStatus, nil
196190
// bad
197191
case cli_service.TOperationState_CANCELED_STATE,
198192
cli_service.TOperationState_CLOSED_STATE,
199193
cli_service.TOperationState_ERROR_STATE,
200194
cli_service.TOperationState_TIMEDOUT_STATE:
201-
// do we need to close the operation in these cases?
202195
logBadQueryState(log, opStatus)
203196
return exStmtResp, opStatus, errors.New(opStatus.GetDisplayMessage())
204197
// live states
@@ -213,7 +206,6 @@ func (c *conn) runQuery(ctx context.Context, query string, args []driver.NamedVa
213206
// terminal states
214207
// good
215208
case cli_service.TOperationState_FINISHED_STATE:
216-
// return handle to fetch results later
217209
return exStmtResp, statusResp, nil
218210
// bad
219211
case cli_service.TOperationState_CANCELED_STATE,
@@ -242,7 +234,6 @@ func (c *conn) runQuery(ctx context.Context, query string, args []driver.NamedVa
242234
// terminal states
243235
// good
244236
case cli_service.TOperationState_FINISHED_STATE:
245-
// return handle to fetch results later
246237
return exStmtResp, statusResp, nil
247238
// bad
248239
case cli_service.TOperationState_CANCELED_STATE,
@@ -273,13 +264,9 @@ func (c *conn) executeStatement(ctx context.Context, query string, args []driver
273264
Statement: query,
274265
RunAsync: c.cfg.RunAsync,
275266
QueryTimeout: int64(c.cfg.QueryTimeout / time.Second),
276-
// this is specific for databricks. It shortcuts server round trips
277267
GetDirectResults: &cli_service.TSparkGetDirectResults{
278268
MaxRows: int64(c.cfg.MaxRows),
279269
},
280-
// CanReadArrowResult_: &t,
281-
// CanDecompressLZ4Result_: &f,
282-
// CanDownloadResult_: &t,
283270
}
284271

285272
ctx = driverctx.NewContextWithConnId(ctx, c.id)
@@ -339,7 +326,6 @@ func (c *conn) pollOperation(ctx context.Context, opHandle *cli_service.TOperati
339326
log.Debug().Msgf("databricks: status %s", statusResp.GetOperationState().String())
340327
}
341328
return func() bool {
342-
// which other states?
343329
if err != nil {
344330
return true
345331
}

connector.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
3434
return nil, wrapErr(err, "error initializing thrift client")
3535
}
3636

37-
// we need to ensure that open session will eventually end
3837
session, err := tclient.OpenSession(ctx, &cli_service.TOpenSessionReq{
3938
ClientProtocol: c.cfg.ThriftProtocolVersion,
4039
Configuration: make(map[string]string),

driver.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,3 @@ func (d *databricksDriver) OpenConnector(dsn string) (driver.Connector, error) {
4545

4646
var _ driver.Driver = (*databricksDriver)(nil)
4747
var _ driver.DriverContext = (*databricksDriver)(nil)
48-
49-
// type databricksDB struct {
50-
// *sql.DB
51-
// }
52-
53-
// func OpenDB(c driver.Connector) *databricksDB {
54-
// db := sql.OpenDB(c)
55-
// return &databricksDB{db}
56-
// }
57-
58-
// func (db *databricksDB) QueryContextAsync(ctx context.Context, query string, args ...any) (rows *sql.Rows, queryId string, err error) {
59-
// return nil, "", nil
60-
// }
61-
62-
// func (db *databricksDB) ExecContextAsync(ctx context.Context, query string, args ...any) (result sql.Result, queryId string) {
63-
// //go do something
64-
// return nil, ""
65-
// }
66-
67-
// func (db *databricksDB) CancelQuery(ctx context.Context, queryId string) error {
68-
// //go do something
69-
// return nil
70-
// }
71-
72-
// func (db *databricksDB) GetQueryStatus(ctx context.Context, queryId string) error {
73-
// //go do something
74-
// return nil
75-
// }
76-
77-
// func (db *databricksDB) FetchRows(ctx context.Context, queryId string) (rows *sql.Rows, err error) {
78-
// //go do something
79-
// return nil, nil
80-
// }
81-
82-
// func (db *databricksDB) FetchResult(ctx context.Context, queryId string) (rows sql.Result, err error) {
83-
// //go do something
84-
// return nil, nil
85-
// }

internal/client/client.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,6 @@ func (tsc *ThriftServiceClient) CancelOperation(ctx context.Context, req *cli_se
167167
return resp, CheckStatus(resp)
168168
}
169169

170-
// log.Debug().Msg(fmt.Sprint(c.transport.response.StatusCode))
171-
// log.Debug().Msg(c.transport.response.Header.Get("X-Databricks-Org-Id"))
172-
// log.Debug().Msg(c.transport.response.Header.Get("x-databricks-error-or-redirect-message"))
173-
// log.Debug().Msg(c.transport.response.Header.Get("x-thriftserver-error-message"))
174-
// log.Debug().Msg(c.transport.response.Header.Get("x-databricks-reason-phrase"))
175-
176170
// InitThriftClient is a wrapper of the http transport, so we can have access to response code and headers.
177171
// It is important to know the code and headers to know if we need to retry or not
178172
func InitThriftClient(cfg *config.Config) (*ThriftServiceClient, error) {

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func WithDefaults() *Config {
147147
ClientTimeout: 900 * time.Second,
148148
PingTimeout: 15 * time.Second,
149149
CanUseMultipleCatalogs: true,
150-
DriverName: "godatabrickssqlconnector", //important. Do not change
150+
DriverName: "godatabrickssqlconnector", // important. Do not change
151151
DriverVersion: "0.9.0",
152152
ThriftProtocol: "binary",
153153
ThriftTransport: "http",

rows.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (r *rows) Next(dest []driver.Value) error {
147147
return err
148148
}
149149

150-
// populate the destinatino slice
150+
// populate the destination slice
151151
for i := range dest {
152152
val, err := value(r.fetchResults.Results.Columns[i], metadata.Schema.Columns[i], r.nextRowIndex, r.location)
153153

@@ -202,10 +202,9 @@ func (r *rows) ColumnTypeDatabaseTypeName(index int) string {
202202
}
203203

204204
// ColumnTypeNullable returns a flag indicating whether the column is nullable
205-
// and an ok value of true if the status of the column is known. Otherwise
205+
// and an ok value of true if the status of the column is known. Otherwise
206206
// a value of false is returned for ok.
207207
func (r *rows) ColumnTypeNullable(index int) (nullable, ok bool) {
208-
// TODO: Update if we can figure out this information
209208
return false, false
210209
}
211210

@@ -216,8 +215,6 @@ func (r *rows) ColumnTypeLength(index int) (length int64, ok bool) {
216215
}
217216

218217
typeName := getDBTypeID(columnInfo)
219-
// TODO: figure out how to get better metadata about complex types
220-
// currently map, array, and struct are returned as strings
221218
switch typeName {
222219
case cli_service.TTypeId_STRING_TYPE,
223220
cli_service.TTypeId_VARCHAR_TYPE,
@@ -248,7 +245,6 @@ var (
248245

249246
func getScanType(column *cli_service.TColumnDesc) reflect.Type {
250247

251-
// TODO: handle non-primitive types
252248
entry := column.TypeDesc.Types[0].PrimitiveEntry
253249

254250
switch entry.Type {
@@ -289,15 +285,13 @@ func getScanType(column *cli_service.TColumnDesc) reflect.Type {
289285
}
290286

291287
func getDBTypeName(column *cli_service.TColumnDesc) string {
292-
// TODO: handle non-primitive types
293288
entry := column.TypeDesc.Types[0].PrimitiveEntry
294289
dbtype := strings.TrimSuffix(entry.Type.String(), "_TYPE")
295290

296291
return dbtype
297292
}
298293

299294
func getDBTypeID(column *cli_service.TColumnDesc) cli_service.TTypeId {
300-
// TODO: handle non-primitive types
301295
entry := column.TypeDesc.Types[0].PrimitiveEntry
302296
return entry.Type
303297
}
@@ -336,7 +330,6 @@ func (r *rows) getColumnMetadataByIndex(index int) (*cli_service.TColumnDesc, er
336330
return nil, errors.Errorf("invalid column index: %d", index)
337331
}
338332

339-
// tColumns := resultMetadata.Schema.GetColumns()
340333
return columns[index], nil
341334
}
342335

@@ -394,7 +387,7 @@ func (r *rows) fetchResultPage() error {
394387

395388
for !r.isNextRowInPage() {
396389

397-
// determine the direction of page fetching. Currently we only handle
390+
// determine the direction of page fetching. Currently we only handle
398391
// TFetchOrientation_FETCH_PRIOR and TFetchOrientation_FETCH_NEXT
399392
var direction cli_service.TFetchOrientation = r.getPageFetchDirection()
400393
if direction == cli_service.TFetchOrientation_FETCH_PRIOR {

testserver.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ func (h *thriftHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
2020

2121
func initThriftTestServer(handler cli_service.TCLIService) *httptest.Server {
2222

23-
// endpoint := fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)
2423
tcfg := &thrift.TConfiguration{
2524
TLSConfig: nil,
2625
}

0 commit comments

Comments
 (0)