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

More columns than values in query response #3608

Closed
aviau opened this issue Aug 10, 2015 · 6 comments
Closed

More columns than values in query response #3608

aviau opened this issue Aug 10, 2015 · 6 comments

Comments

@aviau
Copy link
Contributor

aviau commented Aug 10, 2015

Hello,

I am sure this is a duplicate of something somewhere... but here goes:

Using mean() in a query breaks the response format: there are more columns than values in the query response.

With mean():

Query:
SELECT host, mean(zzz) as hello, host, value as value, zzz, host FROM cpu_value
Response:
{"series": [{"values": [["1970-01-01T00:00:00Z", 34545]], "name": "cpu_value", "columns": ["time", "host", "hello", "host", "value", "zzz", "host"], "tags": {"host": "server01"}}]}

Without mean():

Query:
SELECT host, zzz as hello, host, value as value, zzz, host FROM cpu_value
Response:
{"series": [{"values": [["2015-08-10T14:03:44.833892297Z", 34545, 2.34, 34545]], "name": "cpu_value", "columns": ["time", "zzz", "value", "zzz"], "tags": {"host": "server01"}}]}

easy reproduction:
This is the script I used to test this:

from influxdb import InfluxDBClient
import json

client = InfluxDBClient('localhost', 8086, 'root', 'root', 'example')
resp = client.query('DROP measurement cpu_value')

points = [
    {
        "measurement": "cpu_value",
        "tags": {
            "host": "server01",
            "region": "us-west",
            "type_instance": "idle",
        },
        "fields": {
            "value": 0.64,
            "zzz": 34545,
        }
    },
    {
        "measurement": "cpu_value",
        "tags": {
            "host": "server01",
            "region": "us-west",
            "type_instance": "idle",
        },
        "fields": {
            "value": 2.34,
            "zzz": 34545,
        }
    }

]

client.write_points(points)
QUERY = """SELECT host, zzz as hello, host, value as value, zzz, host FROM cpu_value"""
resp = client.query(QUERY)
print json.dumps(resp.raw)

See the influxdb-python issue: influxdata/influxdb-python#228

@aviau aviau changed the title Using mean breaks the response format More columns that values in query response Aug 10, 2015
@aviau aviau changed the title More columns that values in query response More columns than values in query response Aug 10, 2015
@otoolep
Copy link
Contributor

otoolep commented Aug 10, 2015

@corylanou

Can you be more precise? What in the output don't you like?

@aviau
Copy link
Contributor Author

aviau commented Aug 10, 2015

Not sure if you noticed it, but the issue here is that host is a tag. So it should not be included in the columns list.

Not that i'm against it being included. But if it's included, include it in the values too!

@corylanou
Copy link
Contributor

I just fixed a bug with the alias (which is shown in your last query - #3564). I'm also making changes right now to the select behavior that if you put a tag in the select clause, it comes back as a column, not as another grouped set of output (#3549).

This may address your concerns, I'm not sure.

@aviau
Copy link
Contributor Author

aviau commented Aug 10, 2015

if you put a tag in the select clause, it comes back as a column

Great! Ping me here when this is merged and I will test it. I think that will fix the issue.

@beckettsean
Copy link
Contributor

@aviau the code @corylanou referenced has been checked in and is in the nightly build. Can you try to repro with the latest?

@aviau
Copy link
Contributor Author

aviau commented Aug 19, 2015

With the same test, this is the new result:

{"series": [{"values": [["2015-08-19T14:18:34.794532536Z", "server01", 34545, "server01", 0.64, 34545, "server01"]], "name": "cpu_value", "columns": ["time", "host", "hello", "host", "value", "zzz", "host"]}]}

Thanks!

@aviau aviau closed this as completed Aug 19, 2015
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

No branches or pull requests

4 participants