MCPcopy Create free account
hub / github.com/sql-machine-learning/sqlflow / runQuery

Function runQuery

go/executor/sql_stmt.go:62–89  ·  view source on GitHub ↗

query runs slct and writes the retrieved rows into pipe wr.

(wr *pipe.Writer, slct string, db *database.DB)

Source from the content-addressed store, hash-verified

60
61// query runs slct and writes the retrieved rows into pipe wr.
62func runQuery(wr *pipe.Writer, slct string, db *database.DB) error {
63 rows, err := db.Query(slct)
64 if err != nil {
65 return fmt.Errorf("runQuery failed: %v", err)
66 }
67 defer rows.Close()
68
69 columns, err := rows.Columns()
70 if err != nil {
71 return fmt.Errorf("failed to get columns: %v", err)
72 }
73
74 columnTypes, err := rows.ColumnTypes()
75 if err != nil {
76 return fmt.Errorf("failed to get columnTypes: %v", err)
77 }
78 header := make(map[string]interface{})
79 header["columnNames"] = columns
80 if e := wr.Write(header); e != nil {
81 return e
82 }
83 for rows.Next() {
84 if e := parseRow(columns, columnTypes, rows, wr); e != nil {
85 return e
86 }
87 }
88 return nil
89}
90
91// parseRow calls rows.Scan to retrieve the current row, and convert
92// each cell value from {}interface to an accuracy value. It then

Callers 1

runNormalStmtFunction · 0.85

Calls 4

parseRowFunction · 0.85
ErrorfMethod · 0.80
CloseMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected