You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2018/02/02 20:36:53 UTC
[GitHub] davelpz opened a new issue #4335: Not quoting column name when doing a time series
davelpz opened a new issue #4335: Not quoting column name when doing a time series
URL: https://github.com/apache/incubator-superset/issues/4335
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
Commit
1f8fccc0f923de0b119b22303e504e9efeeff417
### Expected results
time series should work if column name has a space in it
### Actual results
get sql error because column is not properly quoted
### Steps to reproduce
Have a table with columns where column names have spaces, including
date columns, for example 'CREATED DATE'
Create a slice and in the Time section select a column with a space in the name.
Also select a 'Time Grain' of 'Time Column'. When you run the query, you will see that the
generated query is not quoting the column like it should.
I've been debugging this and I think the problem lies in superset/connectors/sqla/models.py
I think the get_timestamp_expression function should return column at end of function
and not literal_column
def get_timestamp_expression(self, time_grain):
"""Getting the time component of the query"""
expr = self.expression or self.column_name
if not self.expression and not time_grain:
return column(expr, type_=DateTime).label(DTTM_ALIAS)
if time_grain:
pdf = self.python_date_format
if pdf in ('epoch_s', 'epoch_ms'):
# if epoch, translate to DATE using db specific conf
db_spec = self.table.database.db_engine_spec
if pdf == 'epoch_s':
expr = db_spec.epoch_to_dttm().format(col=expr)
elif pdf == 'epoch_ms':
expr = db_spec.epoch_ms_to_dttm().format(col=expr)
grain = self.table.database.grains_dict().get(time_grain, '{col}')
expr = grain.function.format(col=expr)
return literal_column(expr, type_=DateTime).label(DTTM_ALIAS)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services