pyspark - 如何使用 ETL (AWS Glue) 聚合数据,以便我们可以使用 Athena 通过特定属性仅选择一部分数据
问题描述
如果有更好的地方可以问这类问题,请告诉我。
我有一个存储和尝试阅读文档的服务。对于每个文档,该服务都会以一定的信心提取和读取行和单词。
单个文档(ETL 前)的有效负载如下所示
{
"Blocks": [
{
"Type": "LINE",
"Confidence": 90
"Value": "this is a sentence"
...
},
{
"Type": "WORD",
"Confidence": 99
"Value": "this"
...
},
{
"Type": "WORD",
"Confidence": 97
"Value": "is"
...
},
{
"Type": "WORD",
"Confidence": 89
"Value": "a"
...
},
{
"Type": "WORD",
"Confidence": 99
"Value": "sentence"
...
},
{
"Type": "WORD",
"Confidence": 50
},
{
"Type": "LINE",
"Confidence": 90
"Value": "example of another line"
...
},
...
]
}
我正在为 ETL 聚合函数寻找高级算法或想法,这样我就可以使用 Athena 进行查询,这会给我类似的东西
“给我所有 30% 单词置信度 > 60 的文档”
解决方案
您不需要 etl,雅典娜可以原生读取 json,请参阅
https://docs.aws.amazon.com/athena/latest/ug/querying-JSON.html
在您创建表之后,您需要为您的任务编写正确的查询。你的陈述“给我所有的文档,其中 x% 的单词有一些信任”是非常标准的。细节取决于你如何定义你的表列,但你可以这样做:
SELECT docid from mytable group by docid
having count_if(confidende>60)* 1./count(*) > 0.3
推荐阅读
- python - 查找字符串并在同一列中返回不同的字符串
- javascript - 使用 puppeteer 获取自定义元素,然后执行单击操作
- c# - 通过 Windows 服务连接 SQL Server 2012
- regex - awk 无法拆分大文件 (10Gb+)
- node.js - 如何决定应将视频转码为哪些分辨率和比特率?
- r - 使用一个分组为线条着色,另一个分组使用“ggplot2”确定线条样式
- discord - REFRENCEERROR:嵌入未定义,我该怎么办?(不和谐.JS)
- javascript - 提供本地笑话模拟后立即禁用调试或运行单个测试
- c# - 使用 C# DownloadFile() 下载后损坏的 Excel 文件
- r - 使用 R 中的应用在几列上运行 cor.test 时出错