Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions query/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,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
}
Expand Down
8 changes: 8 additions & 0 deletions query/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,14 @@ func TestSelect(t *testing.T) {
},
now: mustParseTime("1970-01-01T00:02:30Z"),
},
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding a test!

// 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) {
shardMapper := ShardMapper{
Expand Down