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

0

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

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

profile picture
专家
已提问 5 个月前45 查看次数
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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则