Skip to content

ATHENA INTERNAL_ERROR_QUERY_ENGINE

0

Hi,

I’m trying to run a query on Athena, but I started getting the following error:

[ErrorCode: INTERNAL_ERROR_QUERY_ENGINE] Amazon Athena experienced an internal error while executing this query. Please contact AWS support for further assistance. You will not be charged for this query. We apologize for the inconvenience.

I suspect the issue is related to this part of the query:

sql Copiar código nfe_sped_tunada_10 AS ( SELECT sped.isn, seq_nota_fiscal, tip_oper, tip_emit, cod_sit, sped.seq_contribuinte, cod_cnpj, sped.seq_r0000_declaracao, num_ano_referencia, num_mes_referencia, dat_ini_declaracao, dat_fim_declaracao, seq_rc100_nota_fiscal, vlr_chv_nfe, dat_doc, vlr_doc, vlr_icms, sta_saldo, CASE WHEN rx.isn IS NULL THEN sped.sta_ajuste ELSE 1 END AS sta_ajuste, sta_efd_vlr_doc, sta_efd_vlr_icms, num_ordem_prioridade FROM nfe_sped_tunada_9 AS sped LEFT JOIN ( SELECT d.isn, d.seq_r0000_declaracao, d.seq_contribuinte FROM nfe_sped_tunada_9 AS d JOIN ( SELECT s.seq_contribuinte, s.seq_r0000_declaracao FROM nfe_sped_tunada_9 AS s JOIN nfe_analise_7 AS n ON n.seq_rc100_nota_fiscal = s.seq_rc100_nota_fiscal JOIN nfe_tunada2 AS f ON f.seq_nota_fiscal = s.seq_nota_fiscal WHERE n.cod_papel_nfe = 'D' AND n.seq_rc100_nota_fiscal > 0 AND sta_ajuste = 1 GROUP BY s.seq_contribuinte, s.seq_r0000_declaracao ) AS rs ON rs.seq_contribuinte = d.seq_contribuinte AND d.tip_oper = '0' AND d.seq_rc100_nota_fiscal > 0 AND sta_ajuste = 0 AND rs.seq_r0000_declaracao = d.seq_r0000_declaracao ) AS rx ON sped.isn = rx.isn )

SELECT * FROM nfe_sped_tunada_10; The query worked fine until I added this new part. Could you help me figure out the issue?

asked 2 years ago1.2K views

2 Answers
1

The INTERNAL_ERROR_QUERY_ENGINE error you're experiencing is an internal Athena error that occurs on the query engine side. This type of error is not caused by user input but rather by an issue within Athena's system itself.

Given the complexity of your query, it's possible that it's pushing the limits of Athena's query engine, especially if you've recently added new components to it. However, it's important to note that this error is not something you can directly fix as a user.

Here are a few steps you can try:

  1. Retry the query: Sometimes, these internal errors are transient and can be resolved by simply running the query again.

  2. Break down the query: Try running smaller parts of the query separately to identify if a specific part is causing the issue.

  3. Check your data: Ensure that all the tables referenced in your query exist and have the expected schema.

  4. Optimize your query: Look for ways to simplify your query, especially complex joins or subqueries.

  5. Check Athena service status: Verify if there are any ongoing issues with the Athena service in your region.

If the problem persists after trying these steps, you should contact AWS support as suggested in the error message. They have access to more detailed logs and can investigate the root cause of the internal error.

Remember, you won't be charged for queries that result in this error, so don't hesitate to retry or experiment with query modifications to resolve the issue.
Sources
Athena error catalog - Amazon Athena
AthenaError - Amazon Athena
QueryExecutionStatus - Amazon Athena

answered 2 years ago

EXPERT

reviewed 2 years ago

1
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

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.