(ctx context.Context, _ *sql.Conn, statement string, queryContext db.QueryContext)
| 79 | } |
| 80 | |
| 81 | func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, queryContext db.QueryContext) ([]*v1pb.QueryResult, error) { |
| 82 | var results []*v1pb.QueryResult |
| 83 | stmts, err := base.SplitMultiSQL(storepb.Engine_DATABRICKS, statement) |
| 84 | if err != nil { |
| 85 | return nil, err |
| 86 | } |
| 87 | |
| 88 | for _, stmt := range stmts { |
| 89 | result := &v1pb.QueryResult{} |
| 90 | startTime := time.Now() |
| 91 | dataArr, colInfo, err := d.execStatementSync(ctx, stmt.Text, int64(queryContext.Limit)) |
| 92 | if err != nil { |
| 93 | return nil, err |
| 94 | } |
| 95 | if dataArr == nil || colInfo == nil { |
| 96 | break |
| 97 | } |
| 98 | |
| 99 | colNames, colTypeNames := toStrColInfo(colInfo) |
| 100 | result.ColumnNames = colNames |
| 101 | result.ColumnTypeNames = colTypeNames |
| 102 | |
| 103 | // process rows. |
| 104 | for _, rowData := range dataArr { |
| 105 | queryRow := &v1pb.QueryRow{} |
| 106 | // process a single row. |
| 107 | for idx, rowVal := range rowData { |
| 108 | v1pbRowVal, err := toV1pbRowVal(colInfo[idx].TypeName, rowVal) |
| 109 | if err != nil { |
| 110 | return nil, err |
| 111 | } |
| 112 | queryRow.Values = append(queryRow.Values, v1pbRowVal) |
| 113 | } |
| 114 | result.Rows = append(result.Rows, queryRow) |
| 115 | } |
| 116 | result.Latency = durationpb.New(time.Since(startTime)) |
| 117 | result.RowsCount = int64(len(result.Rows)) |
| 118 | results = append(results, result) |
| 119 | } |
| 120 | |
| 121 | return results, nil |
| 122 | } |
| 123 | |
| 124 | func (d *Driver) Execute(ctx context.Context, statement string, _ db.ExecuteOptions) (int64, error) { |
| 125 | // Parse transaction mode from the script |
no test coverage detected