villebro opened a new pull request #17195: URL: https://github.com/apache/superset/pull/17195
### SUMMARY When limiting a query with top n series on a db that doesn't support subqueries (e.g. Druid), numeric values are sometimes returned as `numpy` types. For instance, integer values are returned as `numpy.int64` instead of `int`. If the groupby column type is set to String type, despite the expression returning a numeric value, this causes the following SQLAlchemy compilation error:   This is due to SQLAlchemy attempting to perform a string replacement operation on the numeric value when escaping hyphens during query compilation. However, by ensuring that the value is first converted into its native Python equivalent (`np.inp64` to `int`), SQLAlchemy is able to ignore the incorrect target type (in this case `String`), and is able to successfully compile the query:  ### TESTING INSTRUCTIONS 1. Use a database that doesn't support subqueries, e.g. Druid 2. Create a dataset with a calculated column that returns a numeric value but set it to "STRING" type 3. Create a chart with a limit on the series count 3. Notice how the query raises a 500 when fetching data ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
