Merge branch 'main-2.x' into db/panic-at-the-cursor

db/panic-at-the-cursor
WeblWabl 2025-03-26 15:49:25 -05:00 committed by GitHub
commit 9a9c1e69c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -617,11 +617,8 @@ func (b *exprIteratorBuilder) callIterator(ctx context.Context, expr *influxql.C
}
inputs = append(inputs, input)
case *influxql.SubQuery:
// Identify the name of the field we are using.
arg0 := expr.Args[0].(*influxql.VarRef)
opt.Ordered = false
input, err := buildExprIterator(ctx, arg0, b.ic, []influxql.Source{source}, opt, b.selector, false)
input, err := buildExprIterator(ctx, expr.Args[0], b.ic, []influxql.Source{source}, opt, b.selector, false)
if err != nil {
return err
}

View File

@ -2882,6 +2882,14 @@ func TestSelect(t *testing.T) {
},
now: mustParseTime("1970-01-01T00:02:30Z"),
},
{
// This caused a panic in 1.11.7 and earlier versions
name: "Multiple_Subqueries_Fail",
q: `SELECT ABS(a_count - b_count) FROM
(SELECT COUNT(DISTINCT a_id) AS a_count FROM (SELECT last(v0), tag0 AS a_id FROM m0 GROUP BY tag0) FILL(0)),
(SELECT COUNT(DISTINCT b_id) as b_count FROM (SELECT last(v0), tag0 AS a_id FROM m0 GROUP BY tag0) FILL(0))`,
err: `invalid expression type: *influxql.Distinct`,
},
} {
t.Run(tt.name, func(t *testing.T) {
if tt.onlyArch != "" && runtime.GOARCH != tt.onlyArch {