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

[BUG] Double Quote Inclusion Around Measurement Names #22

Closed
ckatsulis opened this issue Jul 7, 2017 · 3 comments
Closed

[BUG] Double Quote Inclusion Around Measurement Names #22

ckatsulis opened this issue Jul 7, 2017 · 3 comments
Labels

Comments

@ckatsulis
Copy link

Is it possible for you to include a double quote around the names of measurements? When the measurement has special characters, the string needs to be sent as a literal, in which case I have to wrap all of the measurements with:
paste0('\"',x,'\"')

I don't believe this causes issues for measurements without this need, so it would just be a relief in the case where .!@#$%^&*(/ are used in a name.

@dleutnant
Copy link
Owner

I'm not quite sure if I get you right (s. Line Protocol Tutorial: "Do not double or single quote measurement names, tag keys, tag values, and field keys. It is valid Line Protocol but InfluxDB assumes that the quotes are part of the name."). Therefore, could you please propose a PR with all relevant code changes? Thanks!

@ckatsulis
Copy link
Author

ckatsulis commented Aug 20, 2017

When it comes to changes, I'm pretty useless :)

Measurements with Special Characters

Erroneous Queries

> influx_select(con, "dbdata", measurement = "tag/value", field_keys = "*", limit = 100L)[[1]]
NULL
Warning message:
http: error parsing query: found /, expected ; at line 1, char 18 

> influx_select(con, "dbdata", measurement = 'tag/value', field_keys = "*", limit = 100L)[[1]]
NULL
Warning message:
http: error parsing query: found /, expected ; at line 1, char 18 

> influx_select(con, "dbdata", measurement = "'tag/value'", field_keys = "*", limit = 100L)[[1]]
NULL
Warning message:
http: error parsing query: found tag/value, expected identifier at line 1, char 14 

> influx_select(con, "dbdata", measurement = "\'tag/value\'", field_keys = "*", limit = 100L)[[1]]
NULL
Warning message:
http: error parsing query: found tag/value, expected identifier at line 1, char 14 

> influx_select(con, "dbdata", measurement = sQuote(dQuote("tag/value")), field_keys = "*", limit = 100L)[[1]]
NULL
Warning message:
http: error parsing query: found ‘, expected identifier at line 1, char 15 

> influx_select(con, "dbdata", measurement = sQuote("tag/value"), field_keys = "*", limit = 100L)[[1]]
NULL
Warning message:
http: error parsing query: found ‘, expected identifier at line 1, char 15 

> influx_select(con, "dbdata", measurement = dQuote("tag/value"), field_keys = "*", limit = 100L)[[1]]
NULL
Warning message:
http: error parsing query: found “, expected identifier at line 1, char 15 

Working Queries

> influx_select(con, "dbdata", measurement = '"tag/value"', field_keys = "*", limit = 100L)[[1]]

Suggested Fix

My guess is that because measurement names can have special characters in influx (e.g. / as I do in the above example), and those require to be double quoted in the line protocol. However, tag key values that have special characters require single quoting in the query line protocol. I don't know exactly why that is the case, but I will look on the boards and ask Dix if there isn't anything there.
influxdata/influxdb#6011

Tag Keys with Special Characters

Erroneous Queries

> influx_select(con, "dbdata", measurement = "data", field_keys = "L1BP,L1BV,L1AP,L1AV", where = 'symbol='tag/value' and time >= now() - 2d', limit = 100L)[[1]]

Working Queries

> influx_select(con, "dbdata", measurement = "data", field_keys = "L1BP,L1BV,L1AP,L1AV", where = "symbol='tag/value' and time >= now() - 2d", limit = 100L)
### AND
> influx_select(con, "dbdata", measurement = "data", field_keys = "L1BP,L1BV,L1AP,L1AV", where = 'symbol::tag=\'tag/value\' and time >= now() - 2d', limit = 100L)
### AND
influx_select(con, "dbdata", measurement = "data", field_keys = "L1BP,L1BV,L1AP,L1AV", where = 'symbol=\'tag/value\' and time >= now() - 2d', limit = 100L)[[1]]

Seems it's much easier to find a working set of quotes for your package when dealing with tag values with special characters.

@ckatsulis ckatsulis changed the title double quote inclusion around measurement names [BUG} Double Quote Inclusion Around Measurement Names Aug 20, 2017
@ckatsulis ckatsulis changed the title [BUG} Double Quote Inclusion Around Measurement Names [BUG] Double Quote Inclusion Around Measurement Names Aug 20, 2017
@dleutnant dleutnant added the bug label Aug 20, 2017
@dleutnant
Copy link
Owner

Measurements are now double quoted in influx_select. However, some of the errors you've got are more related to R's useFancyQuotes option.

http: error parsing query: found “, expected identifier at line 1, char 15

Setting option("useFancyQuotes" = FALSE) yields to correct results.
Current dev version e498186 takes care of this.

Let me know if this works out.

@dleutnant dleutnant reopened this Sep 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants