Getting started - Amazon Redshift Serverless automatic mounting of AWS Glue Data Catalog
Tags: aws, database, analytics, tutorial
Published: 2023-07-30 10:58:50


## Run queries from your data lakes

Amazon Redshift [announced](https://aws.amazon.com/about-aws/whats-new/2023/07/amazon-redshift-automatic-mounting-aws-glue-data-catalog/) a new feature on 25 July 2023 that allows developers, data engineers, data analysts and data scientists to run SQL queries easily using Query Editor v2 in a provisioned environment or Amazon Redshift Serverless by querying data from AWS Glue Data Catalog.

### Lesson Objectives

In this lesson, you will learn how to:

* Change the system-level configuration of the data catalog auto mount.
* Show a list of schemas in the database named in the awsdatacatalog.
* Show a list of tables in a schema.
* Show a list of columns in a table.

### How does this work?

This new AWS service integration means that developers and analysts will no longer have to create an **external schema** from Amazon Redshift in order to be able to query data in data lakes (i.e. Amazon S3 bucket) from AWS Glue Data Catalog.

I have included an image below to demonstrate that an external schema will no longer need to be created.

![external scehema](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7osb2om1glr4hr409mm.jpg)

Hence, you will be able use Query Editor v2 to query data that is cataloged in your AWS Glue Data Catalog.

(Note: Querying the AWS Glue Data Catalog is not available in all Amazon Redshift Regions).

### Solution Overview

This is my interpretation of the solution architecture with this new integration between Amazon Redshift Serverless to query directly from AWS Glue Data Catalog using Query Editor v2.0.



![query glue](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fibx9mesbxcyu09vmfqz.jpg)

### Pre-requisites

If you would like to learn more about getting started using AWS Glue and AWS Glue Studio you may read my previous blog posts below:

* [How to ETL with AWS Glue and AWS Glue Studio to transform your data - Part 1](https://dev.to/aws-builders/how-to-etl-with-aws-glue-and-amazon-glue-studio-to-transform-your-data-328b)

* [How to ETL with AWS Glue and AWS Glue Studio to transform your data - Part 2](https://dev.to/aws-builders/how-to-etl-with-aws-glue-and-amazon-glue-studio-to-transform-your-data-part-2-3ng5)

### Tutorial: Querying the AWS Glue Data Catalog using Amazon Redshift Serverless.

Step 1: Sign into your AWS account.

If you do not have an AWS account you may create one [here](https://dev.to/aws-builders/getting-started-with-aws-a-sweet-journey-5cjj).

Step 2: Sign into the AWS Management Console as an IAM Admin User.

If you do not have an IAM Admin user role you may create one [here](https://dev.to/aws-builders/creating-your-first-iam-admin-user-and-user-group-in-your-aws-account-machine-learning-part-1-3cne).

Step 3: Navigate to the AWS Glue dashboard.

I have previously created a database called 'community'. 

![database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pfuceizx7p3qv26mquo.jpg)

I have a table called 'aws_community_builders_apj' which I cataloged in the AWS Glue Data Catalog last year.

![table](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2ss4vnc86a0lsekq8cq.jpg)

Step 3: I already created an instance of Amazon Redshift Serverless by navigating to the Amazon Redshift dashboard. 

If you wanted to know how to get started with Amazon Redshift Serverless you may read my previous blog [here](https://dev.to/aws-builders/analyzing-sydney-property-prices-with-amazon-redshift-serverless-preview-3ph0).

![serveerless](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xgssj22d7czki1lousf2.jpg)

Step 4: Once an instance of Amazon Redshift Serverless is created, click on the namespace. In this example, I will click 'default-namespace'.


![names](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rvetev4vrbzgmitaw48q.jpg)

Step 5: Navigate to the left-handside menu and select 'Query Editor v2'.


![Query v2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60w991ala90xfa2rydhv.jpg)

Step 6: Double click on **serverless-workspace** and enter your database credentials as a Federated User. Enter the database name, username and your password.


Step 7: In Query Editor v2 enter these SQL commands.

This command will display whether awsdatacatalog is mounted for the Amazon Redshift Serverless data warehouse.
```
SHOW data_catalog_auto_mount;
```
Step 8: ALTER command will change the system level configuration when Amazon Redshift Serverless is paused or resumed.

```
ALTER SYSTEM SET data_catalog_auto_mount = on;
```

![rwsumed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0h7mxclyn6ka3ro0z9us.jpg)

Step 9: Show a list of schemas that is cataloged in the AWS Glue Data Catalog.

```
SHOW SCHEMAS FROM DATABASE awsdatacatalog;
```

![show sc](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/do2kd9mtlepu4gw6h8dq.jpg)


Step 10: Show a list of tables in the schema for community.

```
SHOW TABLES FROM SCHEMA awsdatacatalog.community;
```

![schmea](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q9405v7lugmwfvz0dn3u.jpg)


Step 11: Show a list of columns within the table.

```
SHOW COLUMNS FROM TABLE awsdatacatalog.community.aws_community_builders_apj;
```

![apj tables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zhrt6u3v6omchca6fcdc.jpg)

Step 12: If you would like to query the AWS Glue Data Catalog, you will have to grant your user the necessary permission. e.g.The IAM user role to access the database.

```
GRANT USAGE ON DATABASE awscatalog to'IAM:myIAM USER"
```
### Conclusion

As organizations innovate and wish to analyze all of their data to provide quick answers to their business questions, we have learnt how to empower developers, data analysts, data scientists and business analysts to access data from the AWS Glue Data Catalog without creating an external schema and using Query Editor v2 from Amazon Redshift Serverless or a provisioned data warehouse to generate SQL queries with insights in seconds.

### Resource

You may read more about this new capability in the [AWS Big Data Blog](https://aws.amazon.com/blogs/big-data/simplify-external-object-access-in-amazon-redshift-using-automatic-mounting-of-the-aws-glue-data-catalog/).

### Reference

* [Getting Started with AWS Glue Data Catalog](https://docs.aws.amazon.com/glue/latest/dg/start-data-catalog.html)

* [AWS Announcement](https://aws.amazon.com/about-aws/whats-new/2023/07/amazon-redshift-automatic-mounting-aws-glue-data-catalog/)

Until the next lesson, happy learning! 😀

### Last Week - AWS Summit New York, 26 July 2023 keynote VP of analytics, databases and machine learning, Dr Swami Sivasubramanian

You may watch the AWS Summit New York keynote from VP of analytics, databases and machine learning Dr Swami Sivasubramanian.

{% embed https://www.youtube.com/watch?v=1PkABWCJINM&feature=youtu.be %}

You may also read all the latest announcements and highlights from analytics, database and Generative AI [here](https://aws.amazon.com/blogs/aws/top-announcements-of-the-aws-summit-in-new-york-2023/).

### Last Week - AWSonAir on Twitch, 26 July 2023

Watch on-demand on AWSonAir on Twitch below, the latest announcements including **AWS Glue** from AWS Summit New York.

{% embed https://twitter.com/AWSonAir/status/1684185369846358017 %}

### Next Month - AWS Innovate Data Edition - 30 August 2023

You may join us and register for AWS Innovate, Data Edition in APJ on 30 August 2023. You may register [here](https://aws.amazon.com/events/aws-innovate/apj/data/) and how to unlock the value of data and develop your data strategy as you hear  from AWS Experts.


![AWS innovate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uqx1hcgkz8ekz5sw60el.jpg)