Skip to content

Text to SQL redshift querying athena external table (awsdatacatalog)

0

hello. i have a question. cant we use the awsdatacatalog database (external table in glue data catalog) in redshift + amazon q(generative sql)? is this disabled? if can, is there any guidelines to use it?

1 Answer
2
Accepted Answer

Yes, you can use the AWS Glue Data Catalog (referenced as the 'awsdatacatalog' database in Amazon Redshift) with Amazon Redshift. However, there are some limitations and guidelines to be aware of when using Amazon Q (generative SQL) with external tables from the AWS Glue Data Catalog.

Amazon Redshift allows you to query data cataloged in the AWS Glue Data Catalog. The 'awsdatacatalog' database is a reserved name that references the external Data Catalog database in your account. You can query these external tables using three-part notation in your SELECT statements, where the first part is the database name ('awsdatacatalog'), the second part is the AWS Glue database name, and the third part is the AWS Glue table name.

However, when it comes to using Amazon Q generative SQL with external tables from the AWS Glue Data Catalog, there are some restrictions:

  1. Amazon Q generative SQL is designed to work with data stored in the connected Redshift database. It cannot directly reference external schemas or tables.

  2. Your questions for Amazon Q must be in reference to data that is stored in the connected database. It does not support querying external tables directly.

To use external tables from the AWS Glue Data Catalog in combination with Amazon Q generative SQL, you would need to:

  1. Ensure you have the necessary permissions to access the AWS Glue Data Catalog from Redshift.

  2. Create a view or materialized view in your Redshift database that references the external table.

  3. Use Amazon Q generative SQL to query this view or materialized view, rather than the external table directly.

When using the AWS Glue Data Catalog with Redshift in general (without Amazon Q), keep these guidelines in mind:

  1. You need appropriate IAM permissions to query the AWS Glue Data Catalog.

  2. Use the correct three-part notation in your queries to reference external tables.

  3. Queries against the 'awsdatacatalog' database are read-only.

  4. Some data formats, like Apache Hudi, are only supported when using an AWS Glue Data Catalog (not with an Apache Hive metastore).

Remember to always test and review any generated SQL for errors and vulnerabilities before using it in your environment, especially when working with external data sources.
Sources
Querying the AWS Glue Data Catalog - Amazon Redshift
Interacting with Amazon Q generative SQL - Amazon Redshift
External tables for Redshift Spectrum - Amazon Redshift

answered 2 years ago

EXPERT

reviewed 2 years ago

  • thank you so much.

  • i just tried creating view that references external table(awsdatacatalog) and amazon Q with generative SQL says "No metadata retrieved, please check if you have the relevant database selected above." when i create table with the SQL Statement "CREATE TABLE name AS SELECT * FROM awsdatacatalog.schema.table;"

    Amazon Q recognize it and makes generative SQL. is making view that references external table correct solution?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.