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

Method Execute

backend/plugin/db/databricks/databricks.go:124–158  ·  view source on GitHub ↗
(ctx context.Context, statement string, _ db.ExecuteOptions)

Source from the content-addressed store, hash-verified

122}
123
124func (d *Driver) Execute(ctx context.Context, statement string, _ db.ExecuteOptions) (int64, error) {
125 // Parse transaction mode from the script
126 config, cleanedStatement := base.ParseTransactionConfig(statement)
127 statement = cleanedStatement
128 transactionMode := config.Mode
129
130 // Apply default when transaction mode is not specified
131 if transactionMode == common.TransactionModeUnspecified {
132 transactionMode = common.GetDefaultTransactionMode()
133 }
134
135 // Databricks has different transaction support based on the target:
136 // - SQL Warehouses: Limited transaction support, primarily for Delta tables
137 // - Unity Catalog: Better transaction support with ACID properties for Delta tables
138 // Since Databricks SQL API doesn't expose direct transaction control (BEGIN/COMMIT/ROLLBACK),
139 // and most DDL operations are auto-committed, we handle this at the statement execution level.
140
141 // For transaction mode "off" or when dealing with non-transactional operations,
142 // we execute statements in auto-commit mode (default behavior).
143 // For transaction mode "on", we note that Databricks will handle transactionality
144 // at the operation level for supported operations (e.g., Delta table operations).
145
146 if transactionMode == common.TransactionModeOff {
147 // Execute in auto-commit mode (default Databricks behavior)
148 _, err := d.QueryConn(ctx, nil, statement, db.QueryContext{})
149 return 0, err
150 }
151
152 // Transaction mode "on": Execute with implicit transaction support
153 // Note: Databricks SQL Warehouses don't support explicit transaction control via the REST API.
154 // Transactions are handled implicitly for supported operations (e.g., Delta table DML).
155 // DDL operations are always auto-committed.
156 _, err := d.QueryConn(ctx, nil, statement, db.QueryContext{})
157 return 0, err
158}
159
160// Execute SQL statement synchronously and return row data or error.
161// rowLimit caps the result set when > 0; 0 means no limit (used by sync

Callers

nothing calls this directly

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 3

QueryConnMethod · 0.95
ParseTransactionConfigFunction · 0.92

Tested by

no test coverage detected