Translate queries to DuckDB
Translate Athena engine version 3 queries to DuckDB's SQL dialect, and review the changes. Translation rewrites a query in DuckDB's SQL dialect, so that you don't change functions and syntax by hand, and lists the changes. Translation doesn't run the query.
The migration agent translates queries in the following ways:
-
On demand – In the query editor, choose Translate query. The result opens on the Translate results tab. You don't need to turn on the Athena migration agent setting.
-
Queries that you run – When the Athena migration agent setting is on, the migration agent translates each query that succeeds in the workgroup. The result appears on the Recent queries tab.
-
Queries that you save – When the Athena migration agent setting is on, the migration agent translates each saved query when you create or update it. The result appears on the Saved queries tab.
To turn on the Athena migration agent setting, see Before you start.
In the console
Open the Athena console at https://console.aws.amazon.com/athena/
. -
In the query editor, choose an engine version 3 workgroup.
-
Enter the engine version 3 query that you want to translate.
-
Choose Use migration agent, and then choose Translate query. Athena opens the Translate results tab with the change summary and the original and translated SQL. If the migration agent can't translate the query, the tab shows Translation failed with the reason.
For example, the migration agent translates the following query:
SELECT category, CARDINALITY(ARRAY_AGG(DISTINCT product_name)) AS product_count FROM products GROUP BY category
The translated query is:
SELECT category, ARRAY_LENGTH(ARRAY_AGG(DISTINCT product_name)) AS product_count FROM products GROUP BY category
The Change summary shows "CARDINALITY(ARRAY_AGG(DISTINCT product_name)) -> ARRAY_LENGTH(ARRAY_AGG(DISTINCT product_name))".
View translation results
The Recent queries tab shows the translations of the queries that you run when the Athena migration agent setting is on, and of the queries that an assessment reads. The Saved queries tab shows the translations of your saved queries. A query that you translate on demand appears only on the Translate results tab.
To view a translation
Open the Athena console at https://console.aws.amazon.com/athena/
. -
In the query editor, choose the engine version 3 workgroup.
-
Choose the Recent queries tab or the Saved queries tab. The Translation status column shows each query's status, such as Translated, No translation needed, Needs review, Validated, or Failed.
-
Choose a query. A split view opens with the change summary and the original and translated SQL.
A query with the status Needs review (TRANSLATION_NEEDS_REVIEW) means that the migration agent isn't confident in its translation, or didn't produce one. Choose the query on the Recent queries or Saved queries tab, and then review and edit the translated SQL. If the migration agent didn't produce a translation, the translated SQL panel shows the original query unchanged, and you rewrite it yourself. Then validate the query.