TL;DR: I was talking more about how the query is generated in Superet, not what 
is valid SQL syntax. I believe that in this instance putting quotes around 
`{col}` for Postgres is probably the simplest solution, but I would not apply 
the same to all other engine types.

Long answer: I was referring to how Superset generates SQL queries. Currently 
most other parts of the query are generated using SQL Alchemy constructs that 
automatically detect the need for quotes. For example, selecting a column 
`ColumnName` with an alias `col_alias` is in fact roughly defined as 
`column('ColumnName').label('col_alias')`, which is then compiled into `SELECT 
"ColumnName" AS col_alias`. If either require quoting, `ColumnName` in this 
example, SQL Alchemy automatically puts quotes around it.

The problem here is that time grain expressions don't contain a reference to a 
SQL Alchemy column object, but are static strings inside a `literal_column` 
object, which makes it impossible for SQL Alchemy to apply conditional quoting. 
See below where this happens:

https://github.com/apache/incubator-superset/blob/master/superset/connectors/sqla/models.py#L139-L143

I believe that Postgres is pickier than other engines in this case, i.e. most 
other engines probably wouldn't require quotes around the column name in the 
time grain expression. Therefore I would not force quotes into the time grain 
expressions of other engines at this time.

[ Full content available at: 
https://github.com/apache/incubator-superset/issues/5886 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to