Running queries from Builder
Once you have created your Redshift connection in the CARTO Workspace (see Getting Access for details), you can create custom SQL layers in Builder that make use of the Analytics Toolbox for Redshift.
To get started, let’s run a simple example query to compute the paths that interconnect a set of points using the
ST_GREATCIRCLE function from the transformations module.
- Click on the Add source from button in Builder, that can be found at the bottom left of the screen.
- Select the second tab Custom Query (SQL) and pick the Redshift connection that you will use to run the query. Please make sure this connection has access to the Analytics Toolbox database.
- Click on Add source. A SQL console will be displayed.
- Copy and paste the following query:
You can also take advantage of this function directly from a table from your database:
- Run the first query. In this example we will showcase how easily we can compute all the paths that interconnect the main four US airports using the Analytics Toolbox.
This query first creates all the possible combinations between airports and then generates the paths between them using the
ST_GREATCIRCLE function. The resulting paths contain 25 points, but you can set the number of points in order to make the lines smoother if needed.