Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow selecting tag within subquery #8051

Merged
merged 1 commit into from
Feb 23, 2017

Conversation

jsternberg
Copy link
Contributor

@jsternberg jsternberg commented Feb 23, 2017

Previously, subqueries would only be able to select tag fields within a
subquery if the subquery used a selector. But, it didn't filter out
aggregates like mean() so it would panic instead.

Now it is possible to select the tag directly instead of rewriting the
query in an invalid way.

Some queries in this form will still not work though. For example, the
following still does not function (but also doesn't panic):

SELECT count(host) FROM (SELECT mean, host FROM (SELECT mean(value) FROM cpu GROUP BY host))

Fixes #7968.

  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

@jsternberg
Copy link
Contributor Author

@jwilder this one isn't perfect, but it works for stopping the most common use case. The other use case it doesn't cover doesn't panic and uses a different code path.

@jsternberg jsternberg force-pushed the js-7968-panic-when-selecting-tag-from-inner-query branch from 6d25442 to 3b3541e Compare February 23, 2017 16:19
@@ -26,7 +38,8 @@ func (itr *iteratorMapper) Next() (*FloatPoint, error) {

itr.e.readInto(t, name, tags, itr.buf)
for i, f := range itr.fields {
itr.auxFields[i] = itr.buf[f]
//fmt.Println(i, f)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@jwilder jwilder added this to the 1.2.1 milestone Feb 23, 2017
@jsternberg jsternberg force-pushed the js-7968-panic-when-selecting-tag-from-inner-query branch from 3b3541e to 1ce8fa2 Compare February 23, 2017 17:07
Previously, subqueries would only be able to select tag fields within a
subquery if the subquery used a selector. But, it didn't filter out
aggregates like `mean()` so it would panic instead.

Now it is possible to select the tag directly instead of rewriting the
query in an invalid way.

Some queries in this form will still not work though. For example, the
following still does not function (but also doesn't panic):

    SELECT count(host) FROM (SELECT mean, host FROM (SELECT mean(value) FROM cpu GROUP BY host))
@jsternberg jsternberg force-pushed the js-7968-panic-when-selecting-tag-from-inner-query branch from 1ce8fa2 to 72e4dd0 Compare February 23, 2017 17:16
@jsternberg jsternberg merged commit a20c2dc into 1.2 Feb 23, 2017
@jsternberg jsternberg deleted the js-7968-panic-when-selecting-tag-from-inner-query branch February 23, 2017 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants