Browse data using SQL extension
To open the SQL extension user interface (UI), choose the SQL extension icon
(
) in the navigation pane of your JupyterLab application in
Studio. The left panel data discovery view expands and displays all pre-configured data
store connections to Amazon Athena, Amazon Redshift, and Snowflake.
From there, you can:
-
Expand a specific connection to explore its databases, schemas, tables or views, and columns.
-
Search for a specific connection using the search box in the SQL extension UI. The search returns any databases, schemas, tables, or views that partially match the string you enter.
Note
If Athena is already set up in your AWS account, you can enable a
default-athena-connection
in your JupyterLab application. This allows you to
run Athena queries without needing to manually create the connection. To enable the default
Athena connection:
-
Check with your administrator that your execution role has the required permissions to access Athena and the AWS Glue catalog. For details on the permissions required, see Configure an AWS Glue connection for Athena
-
In your JupyterLab application, navigate to the Settings menu in the top navigation bar and open the Settings Editor menu.
-
Choose Data Discovery.
-
Check the box for Enable default Athena connection.
-
You can update the default
primary
WorkGroup if needed.
To query a database, schema, or table in a JupyterLab notebook, from a given connection in the SQL extension pane:
-
Choose the three dots icon (
) on the right side of any database, schema, or table.
-
Select Query in notebook from the menu.
This automatically populates a notebook cell in JupyterLab with the relevant
%%sm_sql
magic command to connect to the data source. It also adds a sample SQL statement to help you start querying right away. You can further refine the SQL query using the auto-complete and highlighting features of the extension. See SQL editor features of the JupyterLab SQL extension for more information on using the SQL extension SQL editor.
At the table level, the three dots icon provides the additional option to choose to Preview a table's metadata.
The JupyterLab notebook cell content below shows an example of what is automatically
generated when selecting the Query in notebook menu on a
redshift-connection
data source in the SQL extension pane.
%%sm_sql --metastore-id redshift-connection --metastore-type GLUE_CONNECTION -- Query to list tables from schema 'dev.public' SHOW TABLES FROM SCHEMA "dev"."public"
Use the less than symbol (
) at the top of the SQL extension pane to clear the search box or return
to the list of your connections.
Note
The extension caches your exploration results for fast access. If the cached results are outdated or a connection is missing from your list, you can manually refresh the cache by choosing the Refresh button at the bottom of the SQL extension panel. For more information on connection caching, see SQL extension connection caching.