You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When performing a select query with ORDER BY and GROUP BY keywords that reference a function field with an alias, it does not result in the expected SQL statement. Below is the code and the query it should result in:
SELECT time_bucket('60.000s',"time") AS"time_bucket", AVG(datapoint.value) AS"avg_value"FROM datapoint GROUP BY1ORDER BY1
group_by and order_by support a dict with {"alias": "bucket"} but this does not seem to result in the target SQL query. The group by and order by cannot use the alias name of the function but have to either:
Use a number to reference the position of the select statement
Repeat the function in the select statement (i.e., time_bucket('60.000s',"time"))
As reference, the outputs of the above queries are:
>query.get_sql()
>'SELECT time_bucket(\'60.000s\',"time") AS "time_bucket", AVG(datapoint.value) AS "avg_value" FROM datapoint'>query.group_by({"alias": "time_bucket"}).get_sql()
>'SELECT time_bucket(\'60.000s\',"time") AS "time_bucket", AVG(datapoint.value) AS "avg_value" FROM datapoint GROUP BY alias'>query.group_by({"alias": "time_bucket"}).order_by("time_bucket").get_sql()
>'SELECT time_bucket(\'60.000s\',"time") AS "time_bucket", AVG(datapoint.value) AS "avg_value" FROM datapoint GROUP BY alias ORDER BY time_bucket ASC'>query.group_by(time_bucket).order_by(time_bucket).get_sql()
>'SELECT time_bucket(\'60.000s\',"time") AS "time_bucket", AVG(datapoint.value) AS "avg_value" FROM datapoint GROUP BY time_bucket ORDER BY time_bucket ASC'
The text was updated successfully, but these errors were encountered:
When performing a select query with ORDER BY and GROUP BY keywords that reference a function field with an alias, it does not result in the expected SQL statement. Below is the code and the query it should result in:
group_by
andorder_by
support a dict with{"alias": "bucket"}
but this does not seem to result in the target SQL query. The group by and order by cannot use the alias name of the function but have to either:time_bucket('60.000s',"time")
)As reference, the outputs of the above queries are:
The text was updated successfully, but these errors were encountered: