superset icon indicating copy to clipboard operation
superset copied to clipboard

Weird query generated when using Time Series Line Chart with Group By column

Open vnnw opened this issue 8 years ago • 3 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stacktraces and included it here as text if any
  • [x] I have reproduced the issue with at least the latest released version of superset
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.23.0rc2

Expected results

It should generate a normal and efficient SQL query.

Actual results

Weird SQL query syntax, like below one:

image

Steps to reproduce

Make a Time Series Line Chart and add any Group BY column, then click View Query.

vnnw avatar Feb 10 '18 13:02 vnnw

After hours of researching, I found that overriding the default variable values of BaseEngineSpec in db_engine_specs.py may fix this problem.

For example:

class SqliteEngineSpec(BaseEngineSpec):
    engine = 'sqlite'
    time_secondary_columns = True // add this line
    time_groupby_inline = True // and this one too
    ……

vnnw avatar Feb 11 '18 03:02 vnnw

We also observed this issue. Interestingly enough, if you change the 'Series Limit' field from 50 to 0, the SQL syntax will be written normally.

As a short-term solution, we changed the default value for this field to be 0, so our users aren't generating charts with inefficient SQL.

anthonymhho avatar Feb 12 '18 03:02 anthonymhho

It is the expected query if you want to get the time series for the top N dimension members. I agree the default should be to not apply this

mistercrunch avatar Feb 13 '18 05:02 mistercrunch