MCPcopy Create free account
hub / github.com/bytebase/bytebase / execStatementSync

Method execStatementSync

backend/plugin/db/databricks/databricks.go:163–194  ·  view source on GitHub ↗

Execute SQL statement synchronously and return row data or error. rowLimit caps the result set when > 0; 0 means no limit (used by sync and dump paths). DDL/DML callers should pass 0.

(ctx context.Context, statement string, rowLimit int64)

Source from the content-addressed store, hash-verified

161// rowLimit caps the result set when > 0; 0 means no limit (used by sync
162// and dump paths). DDL/DML callers should pass 0.
163func (d *Driver) execStatementSync(ctx context.Context, statement string, rowLimit int64) ([][]string, []dbsql.ColumnInfo, error) {
164 // Bind the connected Bytebase database (= Unity Catalog) to the
165 // session, so unqualified `schema.table` references resolve like in
166 // other RDBMSes. Equivalent to issuing `USE CATALOG <name>` first.
167 req := dbsql.ExecuteStatementRequest{
168 Statement: statement,
169 WarehouseId: d.WarehouseID,
170 Catalog: d.curCatalog,
171 }
172 // Honor the user-selected row limit (default 1000 from the SQL Editor).
173 // Without it, INLINE results above ~25 MiB are aborted server-side
174 // with no result available — see DispositionExternalLinks for the
175 // large-result path.
176 if rowLimit > 0 {
177 req.RowLimit = rowLimit
178 }
179 resp, err := d.Client.StatementExecution.ExecuteAndWait(ctx, req)
180 if err != nil {
181 return nil, nil, err
182 }
183 if resp.Result == nil {
184 return nil, nil, errors.New("no response")
185 }
186
187 if len(resp.Result.DataArray) != 0 {
188 if resp.Manifest == nil || resp.Manifest.Schema == nil || len(resp.Manifest.Schema.Columns) == 0 {
189 return nil, nil, errors.New("missing column info")
190 }
191 return resp.Result.DataArray, resp.Manifest.Schema.Columns, nil
192 }
193 return nil, nil, nil
194}
195
196// return a column type name array and a column name array.
197func toStrColInfo(colInfo []dbsql.ColumnInfo) ([]string, []string) {

Callers 4

SyncInstanceMethod · 0.95
QueryConnMethod · 0.95
showCreateTableMethod · 0.95
descTblMethod · 0.95

Implementers 15

MockDriverbackend/plugin/advisor/utils_for_tests
Driverbackend/plugin/db/bigquery/bigquery.go
Driverbackend/plugin/db/mongodb/mongodb.go
Driverbackend/plugin/db/trino/trino.go
Driverbackend/plugin/db/redshift/redshift.go
Driverbackend/plugin/db/oracle/oracle.go
Driverbackend/plugin/db/dynamodb/dynamodb.go
Driverbackend/plugin/db/cosmosdb/cosmosdb.go
Driverbackend/plugin/db/spanner/spanner.go
Driverbackend/plugin/db/mssql/mssql.go
Driverbackend/plugin/db/mysql/mysql.go
Driverbackend/plugin/db/pg/pg.go

Calls

no outgoing calls

Tested by

no test coverage detected