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

command "select * from measurement" do not return all the columns #3045

Closed
huangyukun2012 opened this issue Jun 19, 2015 · 10 comments
Closed

Comments

@huangyukun2012
Copy link

when we use the command "select * from MEASUREMENT", we want to get all the columns. However, there is something wrong with my influxdb. The following is the test case:


> show field keys
name: cache1
------------
fieldKey
CDN
Device
InsertMethod
StreamHealth
StreamId


name: cache2
------------
fieldKey
CDN
Device
InsertMethod
StreamCount
StreamHealth

> select * from cache1
name: cache1
tags: CDN=2, Device=1, InsertMethod=., StreamHealth=5, StreamId=6 +080
time
----
2015-06-19T01:21:21.455221226Z

my influxdb version is 0.9.0, build from source code, the commit id is 9f45a9eea3017e372711d3ae5949056d53a4ba6a, the machine is MAC.

As you can see, the tag keys and field keys duplicated in my measurement. This is the reason why I get the bug?

@beckettsean
Copy link
Contributor

@huangyukun2012 To understand what might have happened we need to see how you are creating your data. Can you provide some examples of your write statements?

@huangyukun2012
Copy link
Author

@beckettsean
The following is how I created my data:

> insert cache,CDN=2,Device=1 CDN=2,Device=1
cache,CDN=2,Device=1 CDN=2,Device=1

> select * from cache
name: cache
tags: CDN=2, Device=1
time
----
2015-06-23T10:31:42.174821461Z

@beckettsean
Copy link
Contributor

@huangyukun2012 your insert statements have a strange and I believe unintended syntax. For the line protocol, whitespace has very specific meaning. Whitespace separates the measurement and tag set from the field set, and the field set from the timestamp.

The syntax is

measurement,tag_key=tag+value[,tag_key2=tag_value2...] field_key=field_value[,field_key2=field_value2] timestamp

Your point, insert cache,CDN=2,Device=1 CDN=2,Device=1, is writing to the measurement cache with a tag set of CDN=2 and Device=1 and with fields CDN=2,Device=1 and no timestamp. The reason your tags and fields are duplicates is because your insert statements are inserting them that way. Do you intend for CDN and Device to be tags or fields? What metrics are you storing?

Please see #2696 for a more detailed write-up of the line protocol syntax. Website documentation is coming soon.

@huangyukun2012
Copy link
Author

@beckettsean I want to store CDN and Device as both tags and fields, So I get the error.
With a the tag name modified:insert cache,CDN=2,Device=1 fCDN=2,fDevice=1, no errors occur when i execute select * from cache.

Does this mean that tags and fields should not have the same name?

@otoolep
Copy link
Contributor

otoolep commented Jun 24, 2015

No, they should not use the same name. Field and tag names sets must never
overlap. The behavior is undefined and the software will soon be modified
to prevent it.

On Tuesday, June 23, 2015, Yukun Huang notifications@github.com wrote:

@beckettsean https://github.com/beckettsean I want to store CDN and
Device as both tags and fields, So I get the error.
With a the tag name modified:insert cache,CDN=2,Device=1 fCDN=2,fDevice=1,
no errors occur when i execute select * from cache.

Does this mean that tags and fields should not have the same name?


Reply to this email directly or view it on GitHub
#3045 (comment).

@beckettsean
Copy link
Contributor

See #2615 for more on field keys and tag keys must be mutually exclusive.

@huangyukun2012 What is your use case that you want the values to be stored as both fields and tags? I don't see any benefit to duplicating the data. Most likely we can help you solve your challenge in a different way.

@huangyukun2012
Copy link
Author

@beckettsean The situation is:I must query the database base with group by and it only supports tags. And others will use the same data as field. Now, I just modified the name of the tags.

@neonstalwart
Copy link
Contributor

I must query the database base with group by and it only supports tags. And others will use the same data as field. Now, I just modified the name of the tags.

i have been doing the same thing. the tags are part of the data i need to consume so i've been duplicating it as a field and as a tag because i hadn't found a better way to do this. would be glad to know of a better approach if it exists.

EDIT: this was based on what was possible in approx rc28. things may have improved but i don't recall seeing anything.

@beckettsean
Copy link
Contributor

@neonstalwart @huangyukun2012 Can one of you open a new issue describing the reason you can't write this data as only tags or only fields?

@huangyukun2012
Copy link
Author

@beckettsean Ok, I will open a new issue later~

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