Order of clauses in select statement
Opened this issue · 4 comments
It seems the current implementation has slightly different order of clauses compared to InfluxDB documentation, see for example https://docs.influxdata.com/influxdb/v1.5/query_language/spec/#select
select_stmt = "SELECT" fields from_clause [ into_clause ] [ where_clause ]
[ group_by_clause ] [ order_by_clause ] [ limit_clause ]
[ offset_clause ] [ slimit_clause ] [ soffset_clause ] [ timezone_clause ] .
whereas the query generated by influxable is
initial_query = ' '.join([
'{select_clause}',
'{into_clause}',
'{from_clause}',
'{where_clause}',
'{limit_clause}',
'{offset_clause}',
'{slimit_clause}',
'{soffset_clause}',
'{group_by_clause}',
'{order_by_clause}',
'{timezone_clause}',
])
A query with a group by clause and limit cause will fail with error "Invalid query" with InfluxDB 1.8, however the same query works if order of the clauses is flipped.
It seems that the web page of the influxdb changed when I began to create this project.
As I recall, I tested with different combinations of clauses and no influx error was generated.
I agree with you that the order of clauses should be equal to order written in the documentation.
I will update it soon.
Thanks for doing the comparison.
Javid
Some of my tests cases failed due to changed order of into_clause
This query " SELECT * FROM "default" INTO new " will fail.
https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#the-into-clause
That's mildly funny. I checked v1.3 and v1.8 spec, and in those the order is from before into. In v1.7 spec it's flipped.
https://docs.influxdata.com/influxdb/v1.3/query_language/spec/#select
https://docs.influxdata.com/influxdb/v1.7/query_language/spec/#select
https://docs.influxdata.com/influxdb/v1.8/query_language/spec/#select
but in these the into is always before from
https://docs.influxdata.com/influxdb/v1.3/query_language/data_exploration/#the-into-clause
https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#the-into-clause
https://docs.influxdata.com/influxdb/v1.8/query_language/explore-data/#the-into-clause
so.. I guess the spec page is wrong for v1.3 and v1.8?
I will try to run tests on several different versions of InfluxDB.
If there are different clauses orders, we have to add a condition depends on the version of InfluxDB and reroute to the correct order.
If there is only one order, I will revert your commit about the order.
Maybe like you said, the specification page is incorrect