mistercrunch commented on a change in pull request #5655: Handling bigquery
dialect when previewing data
URL:
https://github.com/apache/incubator-superset/pull/5655#discussion_r210814815
##########
File path: superset/db_engine_specs.py
##########
@@ -1410,6 +1414,18 @@ def fetch_data(cls, cursor, limit):
data = [r.values() for r in data]
return data
+ """
+ BigQuery dialect requires us to not use backtick in the fieldname which are
+ nested.
+ Using literal_column handles that issue.
+
http://docs.sqlalchemy.org/en/latest/core/tutorial.html#using-more-specific-text-with-table-literal-column-and-column
+ Also explicility specifying column names so we don't encounter duplicate
+ column names in the result.
+ """
+ @classmethod
+ def _get_fields(cls, cols):
+ return [sqla.literal_column(c.get('name') + ' as ' +
c.get('name').replace('.','__')) for c in cols]
Review comment:
how about
`literal_column(c.get('name')).label(c.get('name').replace('.','__')))`
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]