You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/12/03 22:22:01 UTC
[GitHub] [incubator-superset] betodealmeida commented on issue #8727: How to
use custom SQL in metric field in chart?
betodealmeida commented on issue #8727: How to use custom SQL in metric field in chart?
URL: https://github.com/apache/incubator-superset/issues/8727#issuecomment-561384117
The custom SQL allows you to define a metric using any valid expression for the DB you're targeting. For example, if you're using Postgres with the GIS extension you could define a metric that is the area of a given geometry by using the following expression in the custom SQL tab:
```sql
ST_Area(geom)
```
When clicking "Run Query" Superset will compose a query that would look like:
```sql
SELECT ST_Area(geom) AS `ST_Area(geom)`
...
```
You can inspect the query generated by going into the hamburger menu in the top right and clicking "View query":
<img width="1298" alt="Screen Shot 2019-12-03 at 2 21 35 PM" src="https://user-images.githubusercontent.com/1534870/70094871-40a69680-15d8-11ea-8dc8-2733929ba49c.png">
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org