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

Cannot correctly escape table name containing "-" symbol #440

Closed
chenlujjj opened this issue Aug 15, 2022 · 13 comments
Closed

Cannot correctly escape table name containing "-" symbol #440

chenlujjj opened this issue Aug 15, 2022 · 13 comments
Assignees
Milestone

Comments

@chenlujjj
Copy link

Suppose database name is "test", table name is "a.b.c-d", then the escaped result is "test.a.b.c-d", it will lead to syntax error in sql.

Expected result is "test.a.b.c-d", it will work.

Maybe some change shoule be made to func (q *EvalQuery) escapeIdentifier(identifier string) string

@Slach
Copy link
Collaborator

Slach commented Aug 24, 2022

Sorry for late response,

could you share your ogirinal query with $table macro?
and query which you see in "Generated SQL"?

@Slach Slach closed this as completed in 8dfba84 Aug 24, 2022
@chenlujjj
Copy link
Author

original query:

SELECT
    $timeSeries as t,
    count()
FROM $table

WHERE $timeFilter

GROUP BY t

ORDER BY t

generated sql:

SELECT
    (intDiv(toFloat64(timestamp) * 1000, (5 * 1000)) * (5 * 1000)) as t,
    count()
FROM test.a.b.c-d

WHERE toDateTime64(timestamp, 3) >= toDateTime64(1661337946, 3)

GROUP BY t

ORDER BY t

@Slach
Copy link
Collaborator

Slach commented Aug 24, 2022

lets wait when grafana team will review https://github.com/Altinity/clickhouse-grafana/releases/tag/v2.5.1

@chenlujjj
Copy link
Author

Cool!

@chenlujjj
Copy link
Author

BTW, I'm wondering about when would the escapeIdentifier function in the go and typescript files takes effect respectively.

I think when I click the "Generated SQL" button, the escapeIdentifier function in the typescript file works. How about the function in go file ?

@Slach
Copy link
Collaborator

Slach commented Aug 25, 2022

same changes applied to golang part to
look to 8dfba84 for details

@visago
Copy link

visago commented Aug 30, 2022

lets wait when grafana team will review https://github.com/Altinity/clickhouse-grafana/releases/tag/v2.5.1

We still need to wait for Grafana team to update something before 2.5.1 will work ?

@Slach
Copy link
Collaborator

Slach commented Aug 30, 2022

@visago 2.5.1 released on grafana.com, just install new plugin version

@visago
Copy link

visago commented Aug 30, 2022

Ah ! okay, yeah just did a grafana-cli plugins install vertamedia-clickhouse-datasource 2.5.1 !

@visago
Copy link

visago commented Aug 30, 2022

I just tested 2.5.1 and getting the same issue. I noticed escapeTableIdentifier function was created in src/sql_query.ts, but its not called like in the go code ?

https://github.com/Altinity/clickhouse-grafana/blob/master/src/sql_query.ts#L122-L125

@Slach Slach reopened this Aug 30, 2022
@Slach
Copy link
Collaborator

Slach commented Aug 30, 2022

Oh, sorry, my fault ;(

@Slach Slach self-assigned this Aug 30, 2022
@Slach Slach added this to the 2.5.2 milestone Sep 5, 2022
@Slach Slach closed this as completed in cd0c76e Sep 5, 2022
@Slach
Copy link
Collaborator

Slach commented Sep 6, 2022

@visago 2.5.2 released, please test

@visago
Copy link

visago commented Sep 7, 2022

@Slach tested and verified working ! Thanks so much for the quick response !

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

3 participants