Transaction statements [BEGIN, COMMIT, ROLLBACK] are not supported in Hive 4.0 temporarily. Even in Hive's bucketed transaction table, all the statements are committed automatically by the Hive server.
(ctx context.Context, statementsStr string, _ db.ExecuteOptions)
| 145 | // Even in Hive's bucketed transaction table, all the statements are committed automatically by |
| 146 | // the Hive server. |
| 147 | func (d *Driver) Execute(ctx context.Context, statementsStr string, _ db.ExecuteOptions) (int64, error) { |
| 148 | // Hive has limited transaction support: |
| 149 | // - Only ACID tables support transactions, and even then it's limited |
| 150 | // - Transaction statements (BEGIN, COMMIT, ROLLBACK) are not supported in Hive 4.0 |
| 151 | // - All statements are auto-committed by the Hive server |
| 152 | // Due to these limitations, we execute statements individually regardless of transaction mode |
| 153 | // but we still parse and respect the transaction mode directive for consistency |
| 154 | |
| 155 | if d.db == nil { |
| 156 | return 0, errors.New("connection not initialized") |
| 157 | } |
| 158 | |
| 159 | statements, err := base.SplitMultiSQL(storepb.Engine_HIVE, statementsStr) |
| 160 | if err != nil { |
| 161 | return 0, errors.Wrapf(err, "failed to split statements") |
| 162 | } |
| 163 | |
| 164 | var totalAffected int64 |
| 165 | for _, statement := range statements { |
| 166 | query := strings.TrimRight(statement.Text, ";") |
| 167 | |
| 168 | result, err := d.db.ExecContext(ctx, query) |
| 169 | if err != nil { |
| 170 | return totalAffected, errors.Wrapf(err, "failed to execute statement: %s", query) |
| 171 | } |
| 172 | |
| 173 | // Hive may not always return accurate row counts |
| 174 | affected, _ := result.RowsAffected() |
| 175 | totalAffected += affected |
| 176 | } |
| 177 | |
| 178 | return totalAffected, nil |
| 179 | } |
| 180 | |
| 181 | func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, queryCtx db.QueryContext) ([]*v1pb.QueryResult, error) { |
| 182 | if d.db == nil { |
nothing calls this directly
no test coverage detected