Skip to content

Instantly share code, notes, and snippets.

View kylebrandt's full-sized avatar
🦥
🛠️

Kyle Brandt kylebrandt

🦥
🛠️
View GitHub Profile
@kylebrandt
kylebrandt / README.md
Created October 15, 2025 14:39
SQL Expressions Tests for Panics to address
func TestWhereOnNullNumber(t *testing.T) {
	f := &data.Frame{
		RefID: "a",
		Name:  "a",
		Fields: []*data.Field{
			//data.NewField("d", nil, []*float64{p(2.35), p(math.NaN())}),
			data.NewField("d", nil, []float64{2.35, math.NaN()}),
		},
	}
@kylebrandt
kylebrandt / README.md
Created October 11, 2025 13:52
SQL Expressions: Errors, No Data and Dynamic Schema Query Responses DRAFT

SQL Expressions -- Errors, No Data and Dynamic Schema Query Responses

There are three general situations that SQL expressions does not handle gracefully that users should be aware of that are not bugs, but rather current limitations of the feature. Those are:

  1. Error Responses
  2. No Data Responses
  3. Dynamic Schema responses (Ones where columns are labels change between executions of the query)

Why are there these limitations?

@kylebrandt
kylebrandt / dashboard.json
Created October 2, 2025 16:19
SQL Expressions Conversion To Full Long Example Dashboard
{
"__inputs": [
{
"name": "DS_MOCK",
"label": "Mock",
"description": "",
"type": "datasource",
"pluginId": "grafana-mock-datasource",
"pluginName": "Mock"
},
@kylebrandt
kylebrandt / DataplaneFAQ.md
Last active October 6, 2025 13:16
SQL Expressions and Dataplane DOC drafts

Dataplane FAQ

Note: much of this is moved to grafana/dataplane#56

How does dataplane relate to Dataframes?

Dataplane adds a data typing layer on top of data frames. By analogy Dataplane Types are to dataframes as typescript is to javascript.

Specifically, a property is added to the dataframe to indicate its type with is made up of a kind and a format, for example "Timeseries Wide".

@kylebrandt
kylebrandt / 0response.json
Last active September 19, 2025 14:52
sqlSchema endpoint example
HTTP/1.1 200 OK
Audit-Id: 5b82aaf1-4ba7-48bc-bb7b-94a7b89c6c5e
Cache-Control: no-store
Content-Type: application/json
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Xss-Protection: 1; mode=block
Date: Fri, 19 Sep 2025 14:51:41 GMT
Content-Length: 902
Connection: close
@kylebrandt
kylebrandt / README.md
Last active May 13, 2025 00:49
Audible Dashboard for fun (Sheets and SQL Expressions)

image

The queries

Panel: Main Sheet

SQL:

SELECT title, author, copyright, href, image, rating, series
FROM main
@kylebrandt
kylebrandt / genre.sql
Created May 12, 2025 19:33
Some Wide/Long SQL
/* Long
WITH movie_genre AS (
SELECT
A.title,
A.year,
B.Genre AS genre
FROM A
JOIN B ON A.imdb_id = B.imdb_id
),
genre_totals AS (
@kylebrandt
kylebrandt / screenshots.md
Last active April 30, 2025 15:59
SQL Expression Example Screenshots

Smooth Time Series (PromQL DS)

image

Trend line over Time Series (PromQL DS)

image

Aggregation and Math across Different Queries (Azure Metrics)

Calculate percentage of syn packages against total packets, per direction image

@kylebrandt
kylebrandt / time_funcs.go
Created April 1, 2025 18:33
Can't implement FunctionProvider
package sql
import (
"context"
"time"
mysql "github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/types"
)
@kylebrandt
kylebrandt / sql_expr_basic_usage_chatgpt.md
Created March 27, 2025 14:05
Basic Usage of SQL Expressions in Grafana

📘 Basic Usage of SQL Expressions in Grafana

SQL expressions in Grafana let you perform lightweight SQL-like transformations on the results of other queries — directly within the panel. This is great for reshaping, renaming, filtering, and aggregating data without modifying the original datasource query.


🔧 How SQL Expressions Work

SQL expressions operate on the output of another query in the same panel, referenced by its query letter (e.g., A, B). These expressions are parsed and executed by Grafana — not sent to an external database.