Custom SQL with Lat and Long fields won't let me create a map

I am running into the same problem as in this closed issue:

When I do an SQL query including latitude and longitude fields, the result does not let those fields be used for map visualizations because it is not recognizing them as latitude and longitude fields.

I am using version v0.40.1.

Is there any workaround or other way that I can do a query combining tables and use the result for map visualizations?

My strongest suggestion is to upgrade to the latest version, as you're running a version that has a lot of bugs. Also, your version has a lot of security issues.