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

0

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

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

1개 답변
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
전문가
답변함 5달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠