Validate translated queries
Validation checks that a translated query works on DuckDB before you move it, so that you find problems early. Validation translates an engine version 3 query, runs the original on engine version 3 and the translated query on DuckDB, and compares the row count, column count, column names, and data types of the results, not the row values. If the translated query fails, the migration agent can adjust it and run it again.
Validation doesn't change your data. Read queries, such as SELECT, WITH, SHOW, and DESCRIBE statements, run on both engine version 3 and DuckDB. Statements that change data or catalog objects, such as data manipulation language (DML) write statements and data definition language (DDL) statements, run only as EXPLAIN, so the migration agent checks the syntax and the query plan.
Validation runs the original query again on engine version 3, even if the migration agent already translated an earlier run of it. This includes validating a query from the Recent queries tab. The original query doesn't run again only if the migration agent applies the result of an earlier validation of a query with the same structure.
A query can pass every check and still return different values, because some expressions return a different result without an error. Before you move a query, compare its values.
In the console
To validate a query
Open the Athena console at https://console.aws.amazon.com/athena/
. -
In the query editor, choose an engine version 3 workgroup that has the migration agent setting on.
-
Enter the engine version 3 query that you want to validate.
-
Choose Use migration agent, and then choose Validate query. Athena opens the Validate results tab.
Read the results
The Validate results tab shows a tag for each check: Syntax, Row count, Column count, Column name, and Column datatype. Each tag shows whether that check passed.
A passing validation checks the query against your current data. Review the query for any future additions to the input tables.
When you validate a query, the migration agent updates its status from the result. A passing validation sets it to Translated or No translation needed, and a failed validation or a failed check sets it to Needs review. In the query editor, the Translation status column shows the validation result instead, such as Validated or Failed. Before you move a query, validate it, or check its results with your own data quality checks.
The Column datatype check compares the type of each column by type family:
-
Types in the same family pass, for example
bigintandHUGEINT. -
Types in different families fail, for example
bigintandDECIMAL(38,0).
The following table lists the type families.
| Type family | Engine version 3 types | DuckDB types |
|---|---|---|
| Integer | tinyint, smallint, integer, bigint | TINYINT, SMALLINT, INTEGER, BIGINT, HUGEINT, UTINYINT, USMALLINT, UINTEGER, UBIGINT, UHUGEINT |
| Floating point | real, double | FLOAT, DOUBLE |
| Decimal | decimal | DECIMAL, NUMERIC |
| String | varchar, char, json | VARCHAR, CHAR, JSON |
| Boolean | boolean | BOOLEAN |
| Date | date | DATE |
| Time | time | TIME |
| Time with time zone | time with time zone | TIME WITH TIME ZONE |
| Timestamp | timestamp | TIMESTAMP, TIMESTAMP_S, TIMESTAMP_MS, TIMESTAMP_NS |
| Timestamp with time zone | timestamp with time zone | TIMESTAMP WITH TIME ZONE |
| Interval | interval year to month, interval day to second | INTERVAL |
| Binary | varbinary | BLOB |
| UUID | uuid | UUID |
| Array | array | List types, such as INTEGER[] |
| Map | map | MAP |
| Struct | row | STRUCT |
If you validated a query with the same structure before, the migration agent applies that earlier result, and the change summary says so.
If validation can't finish, the tab shows Validation failed with the reason. If a check fails, edit the query and validate it again, using the Change summary to see what the migration agent changed. To find a result later, choose the query on the Recent queries tab.
View the compatibility result with the API
To read the result of a validation, call the GetQueryExecution or BatchGetQueryExecution API operation. For each query that the migration agent translated, the QueryExecution object in the response includes a CompatibilityResult object.
The CompatibilityResult object contains the following fields.
Id-
The ID of the translation, in the form
t-.uuidType: String
TargetQuery-
The translated query. Empty when
StatusisFAILED.Type: String
Status-
The status of the translation, and of the validation if one ran. A query whose
ConfidenceisTRANSLATION_NEEDS_REVIEWcan still have the statusSUCCEEDED.Type: String
Valid values:
SUCCEEDED|FAILED Confidence-
How well the query translated. For more information, see Assess a workgroup for DuckDB compatibility.
Type: String
Valid values:
NO_TRANSLATION_NEEDED|TRANSLATED_TO_TARGET_DIALECT|TRANSLATION_NEEDS_REVIEW ResultSummary-
A JSON-formatted summary of the translation and validation. Parse it, and then read its
Summaryfield for the list of changes.Type: String
SourceQueryExecutionId-
The ID of an earlier query execution whose translation the migration agent reused for this query, if any.
Type: String
TargetQueryExecutionId-
The ID of the query execution that ran the translated query on DuckDB during validation.
Type: String
TargetQueryExecutionAttempts-
The IDs of all the query executions that the migration agent ran to validate the translated query. Present only when the query was validated.
Type: Array of strings
A query execution has no CompatibilityResult if the setting was off when it ran, if the query failed, or if the translation hasn't finished. To see CompatibilityResult, use a client version that includes the updated Athena API model. See Regions and availability.