在Glue目录中,对于每个表计算行数的Athena查询

0

【以下的问题经过翻译处理】 根据这篇文章: 获取MySQL数据库中所有表的记录数, 在Presto上的Athena中是否有与下面MySQL查询类似的语法?

SELECT table_name
       , table_rows
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = schema_name;

profile picture
EXPERTO
preguntada hace 5 meses49 visualizaciones
1 Respuesta
0

【以下的回答经过翻译处理】 您可以将此视为两个步骤的过程。

  1. 动态生成用于获取计数的SQL查询。
  2. 运行SQL查询的输出以生成计数结果。
with tname_vw(i) as (
    SELECT concat(
            'select ''',
            table_name,
            ''' as table_name,  count(*) from ',
            table_name
        )
    FROM information_schema.tables
    WHERE table_schema = 'schema_name'
)
select array_join(array_agg(i), ' union ') as result
from tname_vw
profile picture
EXPERTO
respondido hace 5 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas