Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect SQL statement on "View Query": python-encoded % character (%%) on STR_TO_DATE() #4857

Closed
3 tasks done
hajdbo opened this issue Apr 20, 2018 · 8 comments
Closed
3 tasks done

Comments

@hajdbo
Copy link
Contributor

hajdbo commented Apr 20, 2018

Using Mysql engine, the request displayed when clicking "View Query" shows a python-encoded %: %%

The query should have single % characters, rather than %%.

I followed the trail to get_query_str() in https://github.com/apache/incubator-superset/blob/master/superset/connectors/sqla/models.py#L418

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.24.0

Expected results

The query displayed should be syntactically correct, showing a single % for STR_TO_DATE() function.

Actual results

screen shot 2018-04-20 at 14 58 49

screen shot 2018-04-20 at 15 09 19

Steps to reproduce

Use a mysql engine, create a slice with time constraits, click the "View Query" button.

@xrmx
Copy link
Contributor

xrmx commented Apr 20, 2018

Symptoms looks very similar to #4830

@villebro
Copy link
Member

@hajdbo I can take a look at this in the coming days. Just curious, have you run into this on other database types as well? i don't have a MySQL installation readily at hand, but can set one up if needed. Btw, naming a column "date" seems slightly risky, calling it account_date or similar might save trouble down the road.

@mistercrunch
Copy link
Member

Pretty sure this represents the SQL we're sending to the database driver (dbapi) which has its own %-based formatting function. While we know what it receives I don't think we have a handle on its internal formatting function.

@nick-gray
Copy link

Is this all related to #4098 ?

We are hitting similar issues where we have to enter %% as a single % fails when executed. The text we enter must also be utf-8 encoded

@xrmx
Copy link
Contributor

xrmx commented Apr 29, 2018

This should be fixed in both master and 0.25 branch, please test and close. Thanks!

@hajdbo
Copy link
Contributor Author

hajdbo commented May 9, 2018

Not fixed in 0.25.4 release with SQLalchemy 1.2.2

screen shot 2018-05-09 at 19 27 26

@hajdbo
Copy link
Contributor Author

hajdbo commented May 16, 2018

Seems very closely related to #617

@hajdbo
Copy link
Contributor Author

hajdbo commented Oct 19, 2018

Fixed with 0.28 release. Thank you! 👍

@hajdbo hajdbo closed this as completed Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants