Incubator-superset: Forced LIMIT clause not being applied correctly when SQL has a trailing comment

Created on 10 May 2019  路  1Comment  路  Source: apache/incubator-superset

When a user submits a query that ends in a comment, Superset incorrectly appends its built-in LIMIT clause to that same last line which makes the LIMIT clause commented out as well.

Expected results

Ideally the limit would be added on a new line so that SQL comments cannot have any effect on it.

Actual results

Superset appends the LIMIT clause to the same line which is functionally equivalent to not adding a limit at all.

Screenshots

User submits the following query (with a default LIMIT of 500 in the UI set):

SELECT y, m, d, COUNT(*)
FROM some_table
GROUP BY y, m, d -- uh oh a trailing comment!

Superset submits to the database engine:

SELECT y, m, d, COUNT(*)
FROM some_table
GROUP BY y, m, d -- uh oh a trailing comment! LIMIT 500

How to reproduce the bug

Run a query that ends in a trailing comment, such as the example user submission in the Screenshots section above.

Environment

  • superset version: 0.32.0rc2
  • python version: 3.6
  • node.js version: ???
  • npm version: ???

Checklist

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 there are 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.

Additional context

I'm not sure if its as simple as inserting a newline here but I'm having trouble getting the tests to pass locally so I didn't want to submit a PR that I'm not confident about.

#bug

Most helpful comment

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.84. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

>All comments

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.84. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Was this page helpful?
0 / 5 - 0 ratings