Skip to content

Commit 65d878b

Browse files
committed
Removed stale comments and transferred todos to jira
Signed-off-by: Matthew Kim <[email protected]>
1 parent ce7d924 commit 65d878b

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
@@ -111,9 +111,6 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name
111111
}
112112
}
113113
if err != nil {
114-
// TODO: are there error situations in which the operation still needs to be closed?
115-
// Currently if there is an error we never get back a TExecuteStatementResponse so
116-
// can't try to close.
117114
log.Err(err).Msgf("databricks: failed to execute query: query %s", query)
118115
return nil, wrapErrf(err, "failed to execute query")
119116
}
@@ -147,7 +144,6 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam
147144
defer log.Duration(msg, start)
148145

149146
if err != nil {
150-
// gotta also think about close operation here
151147
log.Err(err).Msgf("databricks: failed to run query: query %s", query)
152148
return nil, wrapErrf(err, "failed to run query")
153149
}
@@ -169,7 +165,6 @@ func (c *conn) runQuery(ctx context.Context, query string, args []driver.NamedVa
169165
if err != nil {
170166
return exStmtResp, nil, err
171167
}
172-
// hold on to the operation handle
173168
opHandle := exStmtResp.OperationHandle
174169
if opHandle != nil && opHandle.OperationId != nil {
175170
log = logger.WithContext(
@@ -185,14 +180,12 @@ func (c *conn) runQuery(ctx context.Context, query string, args []driver.NamedVa
185180
// terminal states
186181
// good
187182
case cli_service.TOperationState_FINISHED_STATE:
188-
// return results
189183
return exStmtResp, opStatus, nil
190184
// bad
191185
case cli_service.TOperationState_CANCELED_STATE,
192186
cli_service.TOperationState_CLOSED_STATE,
193187
cli_service.TOperationState_ERROR_STATE,
194188
cli_service.TOperationState_TIMEDOUT_STATE:
195-
// do we need to close the operation in these cases?
196189
logBadQueryState(log, opStatus)
197190
return exStmtResp, opStatus, errors.New(opStatus.GetDisplayMessage())
198191
// live states
@@ -207,7 +200,6 @@ func (c *conn) runQuery(ctx context.Context, query string, args []driver.NamedVa
207200
// terminal states
208201
// good
209202
case cli_service.TOperationState_FINISHED_STATE:
210-
// return handle to fetch results later
211203
return exStmtResp, statusResp, nil
212204
// bad
213205
case cli_service.TOperationState_CANCELED_STATE,
@@ -236,7 +228,6 @@ func (c *conn) runQuery(ctx context.Context, query string, args []driver.NamedVa
236228
// terminal states
237229
// good
238230
case cli_service.TOperationState_FINISHED_STATE:
239-
// return handle to fetch results later
240231
return exStmtResp, statusResp, nil
241232
// bad
242233
case cli_service.TOperationState_CANCELED_STATE,
@@ -267,13 +258,9 @@ func (c *conn) executeStatement(ctx context.Context, query string, args []driver
267258
Statement: query,
268259
RunAsync: c.cfg.RunAsync,
269260
QueryTimeout: int64(c.cfg.QueryTimeout / time.Second),
270-
// this is specific for databricks. It shortcuts server round trips
271261
GetDirectResults: &cli_service.TSparkGetDirectResults{
272262
MaxRows: int64(c.cfg.MaxRows),
273263
},
274-
// CanReadArrowResult_: &t,
275-
// CanDecompressLZ4Result_: &f,
276-
// CanDownloadResult_: &t,
277264
}
278265

279266
ctx = driverctx.NewContextWithConnId(ctx, c.id)
@@ -333,7 +320,6 @@ func (c *conn) pollOperation(ctx context.Context, opHandle *cli_service.TOperati
333320
log.Debug().Msgf("databricks: status %s", statusResp.GetOperationState().String())
334321
}
335322
return func() bool {
336-
// which other states?
337323
if err != nil {
338324
return true
339325
}

connector.go

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

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

driver.go

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

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

internal/client/client.go

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

154-
// log.Debug().Msg(fmt.Sprint(c.transport.response.StatusCode))
155-
// log.Debug().Msg(c.transport.response.Header.Get("X-Databricks-Org-Id"))
156-
// log.Debug().Msg(c.transport.response.Header.Get("x-databricks-error-or-redirect-message"))
157-
// log.Debug().Msg(c.transport.response.Header.Get("x-thriftserver-error-message"))
158-
// log.Debug().Msg(c.transport.response.Header.Get("x-databricks-reason-phrase"))
159-
160154
// This is a wrapper of the http transport so we can have access to response code and headers
161155
// It is important to know the code and headers to know if we need to retry or not
162156

internal/config/config.go

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

rows.go

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

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

@@ -200,10 +200,9 @@ func (r *rows) ColumnTypeDatabaseTypeName(index int) string {
200200
}
201201

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

@@ -214,8 +213,6 @@ func (r *rows) ColumnTypeLength(index int) (length int64, ok bool) {
214213
}
215214

216215
typeName := getDBTypeID(columnInfo)
217-
// TODO: figure out how to get better metadata about complex types
218-
// currently map, array, and struct are returned as strings
219216
switch typeName {
220217
case cli_service.TTypeId_STRING_TYPE,
221218
cli_service.TTypeId_VARCHAR_TYPE,
@@ -246,7 +243,6 @@ var (
246243

247244
func getScanType(column *cli_service.TColumnDesc) reflect.Type {
248245

249-
// TODO: handle non-primitive types
250246
entry := column.TypeDesc.Types[0].PrimitiveEntry
251247

252248
switch entry.Type {
@@ -287,15 +283,13 @@ func getScanType(column *cli_service.TColumnDesc) reflect.Type {
287283
}
288284

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

294289
return dbtype
295290
}
296291

297292
func getDBTypeID(column *cli_service.TColumnDesc) cli_service.TTypeId {
298-
// TODO: handle non-primitive types
299293
entry := column.TypeDesc.Types[0].PrimitiveEntry
300294
return entry.Type
301295
}
@@ -334,7 +328,6 @@ func (r *rows) getColumnMetadataByIndex(index int) (*cli_service.TColumnDesc, er
334328
return nil, errors.Errorf("invalid column index: %d", index)
335329
}
336330

337-
// tColumns := resultMetadata.Schema.GetColumns()
338331
return columns[index], nil
339332
}
340333

@@ -392,7 +385,7 @@ func (r *rows) fetchResultPage() error {
392385

393386
for !r.isNextRowInPage() {
394387

395-
// determine the direction of page fetching. Currently we only handle
388+
// determine the direction of page fetching. Currently we only handle
396389
// TFetchOrientation_FETCH_PRIOR and TFetchOrientation_FETCH_NEXT
397390
var direction cli_service.TFetchOrientation = r.getPageFetchDirection()
398391
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)