(cl *ir.ExplainStmt)
| 342 | } |
| 343 | |
| 344 | func (s *paiExecutor) ExecuteExplain(cl *ir.ExplainStmt) error { |
| 345 | // TODO(typhoonzero): Do **NOT** create tmp table when the select statement is like: |
| 346 | // "SELECT fields,... FROM table" |
| 347 | dbName, tableName, err := createTmpTableFromSelect(cl.Select, s.Session.DbConnStr) |
| 348 | if err != nil { |
| 349 | return err |
| 350 | } |
| 351 | cl.TmpExplainTable = strings.Join([]string{dbName, tableName}, ".") |
| 352 | defer dropTmpTables([]string{cl.TmpExplainTable}, s.Session.DbConnStr) |
| 353 | |
| 354 | ossModelPath, e := getModelPath(cl.ModelName, s.Session) |
| 355 | if e != nil { |
| 356 | return e |
| 357 | } |
| 358 | |
| 359 | currProject, err := database.GetDatabaseName(s.Session.DbConnStr) |
| 360 | if err != nil { |
| 361 | return err |
| 362 | } |
| 363 | modelType, estimator, err := getOSSSavedModelType(ossModelPath, currProject) |
| 364 | if err != nil { |
| 365 | return err |
| 366 | } |
| 367 | // format resultTable name to "db.table" to let the codegen form a submitting |
| 368 | // argument of format "odps://project/tables/table_name" |
| 369 | // PAIML do not need to create explain result manually, PAI will |
| 370 | // create the result table. |
| 371 | if cl.Into != "" && modelType != model.PAIML { |
| 372 | resultTableParts := strings.Split(cl.Into, ".") |
| 373 | if len(resultTableParts) == 1 { |
| 374 | cl.Into = fmt.Sprintf("%s.%s", currProject, cl.Into) |
| 375 | } |
| 376 | db, err := database.OpenAndConnectDB(s.Session.DbConnStr) |
| 377 | if err != nil { |
| 378 | return err |
| 379 | } |
| 380 | defer db.Close() |
| 381 | err = createExplainResultTable(db, cl, cl.Into, modelType, estimator) |
| 382 | if err != nil { |
| 383 | return err |
| 384 | } |
| 385 | } |
| 386 | scriptPath := fmt.Sprintf("file://%s/%s", s.Cwd, tarball) |
| 387 | paramsPath := fmt.Sprintf("file://%s/%s", s.Cwd, paramsFile) |
| 388 | if err := createPAIHyperParamFile(s.Cwd, paramsFile, ossModelPath); err != nil { |
| 389 | return err |
| 390 | } |
| 391 | expn, e := pai.Explain(cl, s.Session, scriptPath, paramsPath, cl.ModelName, ossModelPath, s.Cwd, modelType) |
| 392 | if e != nil { |
| 393 | return e |
| 394 | } |
| 395 | |
| 396 | if e = s.submitPAITask(expn.Code, expn.PaiCmd, expn.Requirements, estimator); e != nil { |
| 397 | return e |
| 398 | } |
| 399 | if img, e := expn.Draw(); e == nil { |
| 400 | s.Writer.Write(Figures{img, ""}) |
| 401 | } |
nothing calls this directly
no test coverage detected