MCPcopy Create free account
hub / github.com/featureform/featureform / atomicUpdate

Method atomicUpdate

provider/sql.go:1560–1575  ·  view source on GitHub ↗
(db *sql.DB, tableName string, tempName string, query string)

Source from the content-addressed store, hash-verified

1558}
1559
1560func (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
1577func (q defaultOfflineSQLQueries) trainingSetCreate(store *sqlOfflineStore, def TrainingSetDef, tableName string, labelName string) error {
1578 return q.trainingSetQuery(store, def, tableName, labelName, false)

Callers 2

trainingSetQueryMethod · 0.95
transformationUpdateMethod · 0.95

Calls 1

sanitizeFunction · 0.70

Tested by

no test coverage detected