davelpz opened a new issue #4335: Not quoting column name when doing a time 
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
   ### 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 
   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 
   I think the get_timestamp_expression function should return column at end of 
   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, 
               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:

With regards,
Apache Git Services

Reply via email to