MCPcopy Index your code
hub / github.com/sql-machine-learning/sqlflow / RunSQLProgram

Function RunSQLProgram

go/sql/executor_ir.go:47–66  ·  view source on GitHub ↗

RunSQLProgram run a SQL program. TODO(wangkuiyi): Make RunSQLProgram return an error in addition to *pipe.Reader, and remove the calls to log.Printf.

(sqlProgram string, modelDir string, session *pb.Session)

Source from the content-addressed store, hash-verified

45// TODO(wangkuiyi): Make RunSQLProgram return an error in addition to
46// *pipe.Reader, and remove the calls to log.Printf.
47func RunSQLProgram(sqlProgram string, modelDir string, session *pb.Session) *pipe.Reader {
48 rd, wr := pipe.Pipe()
49 go func() {
50 var db *database.DB
51 var err error
52 defer wr.Close()
53 if db, err = database.OpenAndConnectDB(session.DbConnStr); err != nil {
54 wr.Write(fmt.Errorf("create DB failed: %v", err))
55 return
56 }
57 defer db.Close()
58 err = runSQLProgram(wr, sqlProgram, db, modelDir, session)
59 if err != nil {
60 if e := wr.Write(fmt.Errorf("runSQLProgram error: %v", err)); e != nil {
61 log.GetDefaultLogger().Errorf("runSQLProgram error(piping): %v", e)
62 }
63 }
64 }()
65 return rd
66}
67
68func initializeAndCheckAttributes(stmt ir.SQLFlowStmt) error {
69 switch s := stmt.(type) {

Calls 7

PipeFunction · 0.92
OpenAndConnectDBFunction · 0.92
GetDefaultLoggerFunction · 0.92
runSQLProgramFunction · 0.85
ErrorfMethod · 0.80
CloseMethod · 0.45
WriteMethod · 0.45