1

I am trying to run multiple queries in one Databricks transaction. I am using golang for that. But getting not implemented error. When I look at the library code:

// Not supported in Databricks.
func (c *conn) Begin() (driver.Tx, error) {
    return nil, dbsqlerrint.NewDriverError(context.TODO(), dbsqlerr.ErrNotImplemented, nil)
}

// Not supported in Databricks.
func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
    return nil, dbsqlerrint.NewDriverError(context.TODO(), dbsqlerr.ErrNotImplemented, nil)
}

Is there a way I can run multiple queries in one transaction in databricks?

Gilo
  • 640
  • 3
  • 23

1 Answers1

0

This is not supported by Databricks. See How are transactions scoped on Databricks? :

Databricks manages transactions at the table level. Transactions always apply to one table at a time. For managing concurrent transactions, Databricks uses optimistic concurrency control. This means that there are no locks on reading or writing against a table, and deadlock is not a possibility.

By default, Databricks provides snapshot isolation on reads and write-serializable isolation on writes. Write-serializable isolation provides stronger guarantees than snapshot isolation, but it applies that stronger isolation only for writes.

Read operations referencing multiple tables return the current version of each table at the time of access, but do not interrupt concurrent transactions that might modify referenced tables.

Databricks does not have BEGIN/END constructs that allow multiple operations to be grouped together as a single transaction. Applications that modify multiple tables commit transactions to each table in a serial fashion. You can combine inserts, updates, and deletes against a table into a single write transaction using MERGE INTO.

Zeke Lu
  • 6,349
  • 1
  • 17
  • 23