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/13 09:16:15 UTC

[GitHub] villebro opened a new issue #4412: Comment row at end of query in SQL Lab fails to render in Explore window

villebro opened a new issue #4412: Comment row at end of query in SQL Lab fails to render in Explore window
URL: https://github.com/apache/incubator-superset/issues/4412
 
 
   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.0dev
   
   ### Expected results
   When commenting out the last lines in a query in the SQL Lab UI, the query runs just fine. This is rather common when developing new queries to match the exact use case. However, when pressing "Visualize", the query fails due to the "--" leaking into the closing of the subquery. This can be seen in  I tried doing a quick hack of adding "\n\n" to the end of the query in the connectors/sqla/models.py file fixed the issue. I am glad to make a more elegant fix if someone can give me some guidance on the preferred type of fix.
   
   ```
   diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
   index b2e21c7d..ff1a37a8 100644
   --- a/superset/connectors/sqla/models.py
   +++ b/superset/connectors/sqla/models.py
   @@ -423,7 +423,7 @@ class SqlaTable(Model, BaseDatasource):
        def get_from_clause(self, template_processor=None, db_engine_spec=None):
            # Supporting arbitrary SQL statements in place of tables
            if self.sql:
   -            from_sql = self.sql
   +            from_sql = self.sql + "\n\n"
                if template_processor:
                    from_sql = template_processor.process_template(from_sql)
                if db_engine_spec:
   ```
   <img width="828" alt="screen shot 2018-02-13 at 9 51 12" src="https://user-images.githubusercontent.com/33317356/36139214-587a7ef0-10a5-11e8-9872-f4c94f5acd84.png">
   
   
   ### Actual results
   <img width="830" alt="screen shot 2018-02-13 at 9 50 04" src="https://user-images.githubusercontent.com/33317356/36139202-4fbc88b2-10a5-11e8-895a-d649ecf4c323.png">
   
   <img width="1091" alt="screen shot 2018-02-13 at 11 13 53" src="https://user-images.githubusercontent.com/33317356/36141884-1265492c-10af-11e8-808c-a76f51155c10.png">
   
   
   ### Steps to reproduce
   <img width="946" alt="screen shot 2018-02-13 at 9 50 15" src="https://user-images.githubusercontent.com/33317356/36139223-63843d68-10a5-11e8-9979-8636e8cb2545.png">
   
   
   

----------------------------------------------------------------
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