(db *sql.DB, tableName string, tempName string, query string)
| 1558 | } |
| 1559 | |
| 1560 | func (q defaultOfflineSQLQueries) atomicUpdate(db *sql.DB, tableName string, tempName string, query string) error { |
| 1561 | sanitizedTable := sanitize(tableName) |
| 1562 | transaction := fmt.Sprintf( |
| 1563 | "BEGIN TRANSACTION;"+ |
| 1564 | "%s;"+ |
| 1565 | "TRUNCATE TABLE %s;"+ // this doesn't work in a trx for BIGQUERY and REDSHIFT |
| 1566 | "INSERT INTO %s SELECT * FROM %s;"+ |
| 1567 | "DROP TABLE %s;"+ |
| 1568 | "COMMIT;"+ |
| 1569 | "", query, sanitizedTable, sanitizedTable, tempName, tempName) |
| 1570 | var numStatements = 6 |
| 1571 | // Gets around the fact that the go redshift driver doesn't support multi statement trx queries |
| 1572 | stmt, _ := sf.WithMultiStatement(context.TODO(), numStatements) |
| 1573 | _, err := db.QueryContext(stmt, transaction) |
| 1574 | return err |
| 1575 | } |
| 1576 | |
| 1577 | func (q defaultOfflineSQLQueries) trainingSetCreate(store *sqlOfflineStore, def TrainingSetDef, tableName string, labelName string) error { |
| 1578 | return q.trainingSetQuery(store, def, tableName, labelName, false) |
no test coverage detected