SQL Expressions: Re-implement feature using go-mysql-server (#99521)

* Under feature flag `sqlExpressions` and is experimental
* Excluded from arm32
* Will not work with the Query Service yet
* Does not have limits in place yet
* Does not working with alerting yet
* Currently requires "prepare time series" Transform for time series viz
 
---------

Co-authored-by: Sam Jewell <sam.jewell@grafana.com>
This commit is contained in:
Kyle Brandt
2025-02-06 07:27:28 -05:00
committed by GitHub
parent 4e6bdce41c
commit d64f41afdc
33 changed files with 1969 additions and 405 deletions

View File

@ -93,11 +93,10 @@ func (gr *SQLCommand) Execute(ctx context.Context, now time.Time, vars mathexp.V
rsp := mathexp.Results{}
db := sql.NewInMemoryDB()
var frame = &data.Frame{}
db := sql.DB{}
logger.Debug("Executing query", "query", gr.query, "frames", len(allFrames))
err := db.QueryFramesInto(gr.refID, gr.query, allFrames, frame)
frame, err := db.QueryFrames(ctx, gr.refID, gr.query, allFrames)
if err != nil {
logger.Error("Failed to query frames", "error", err.Error())
rsp.Error = err
@ -105,12 +104,11 @@ func (gr *SQLCommand) Execute(ctx context.Context, now time.Time, vars mathexp.V
}
logger.Debug("Done Executing query", "query", gr.query, "rows", frame.Rows())
frame.RefID = gr.refID
if frame.Rows() == 0 {
rsp.Values = mathexp.Values{
mathexp.NoData{Frame: frame},
}
return rsp, nil
}
rsp.Values = mathexp.Values{