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

Function runSQLProgram

go/sql/executor_ir.go:134–159  ·  view source on GitHub ↗
(wr *pipe.Writer, sqlProgram string, db *database.DB, modelDir string, session *pb.Session)

Source from the content-addressed store, hash-verified

132}
133
134func runSQLProgram(wr *pipe.Writer, sqlProgram string, db *database.DB, modelDir string, session *pb.Session) error {
135 sqlProgram, err := parser.RemoveCommentInSQLStatement(sqlProgram)
136 if err != nil {
137 return err
138 }
139
140 stmts, err := parser.Parse(db.DriverName, sqlProgram)
141 if err != nil {
142 return err
143 }
144 // NOTE(tony): We generate IR and execute its translated program one-by-one since IR generation may depend on the execution
145 // of the previous statement. For example, consider a SQL program
146 //
147 // create table some_table as (select ...);
148 // select * from some_table to train ...
149 //
150 // The IR generation on the second statement would fail since it requires inspection the schema of some_table,
151 // which depends on the execution of create table some_table as (select ...);.
152 sqls := RewriteStatementsWithHints(stmts, db.DriverName)
153 for _, sql := range sqls {
154 if err := runSingleSQLFlowStatement(wr, sql, db, modelDir, session); err != nil {
155 return err
156 }
157 }
158 return nil
159}
160
161func runSingleSQLFlowStatement(wr *pipe.Writer, sql *parser.SQLFlowStmt, db *database.DB, modelDir string, session *pb.Session) (e error) {
162 defer func(startTime int64) {

Callers 1

RunSQLProgramFunction · 0.85

Calls 4

ParseFunction · 0.92

Tested by

no test coverage detected