(ctx context.Context, statement string, _ db.ExecuteOptions)
| 122 | } |
| 123 | |
| 124 | func (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 |
nothing calls this directly
no test coverage detected