apache-beam - 使用 Apache Beam 和 ParquetIO 读取多个 parquet 文件
问题描述
我需要在 Apache Beam 中读取多个 parquet 文件,所有文件都在同一个文件夹中。我尝试使用通配符 *.
我已经设法使用 ParquetIO 读取了单独的 parquet 文件,这是我读取一个 parquet 文件的片段:
pipeline.apply(ParquetIO.read(SCHEMA).from(filePath + File.separator + "*"));
其中 filePath 是例如 /path/xxx.parquet。
我尝试读取多个镶木地板文件的代码片段是
pipeline.apply(ParquetIO.read(SCHEMA).from(folderPath + File.separator + "*.parquet" + File.separator + "*"));
其中文件夹路径例如 /path/to/parquet/files/
我也试过没有最后一部分 File.separator + "*",但结果是一样的。我得到的信息是:
FileIO:654 - 匹配 0 个文件模式 /path/to/parquet/files/*.parquet/ *
此外,我可以拥有各种数量和名称的镶木地板文件。
是否可以使用 Apache Beam 读取多个 parquet 文件,因为我找到了读取多个 txt 文件的方法?
解决方案
是的,可以读取多个镶木地板文件,ParquetIO
因为它FileIO
在引擎盖下使用。只需尝试使用另一种匹配模式即可。在您的情况下,它可能是这样的(我希望folderPath
是“/path/to”):
pipeline.apply(ParquetIO.read(SCHEMA).from(folderPath + File.separator + "parquet" + File.separator + "*" + File.separator + "*"));
或者最后只是双星:
pipeline.apply(ParquetIO.read(SCHEMA).from(folderPath + File.separator + "parquet" + File.separator + "**");
您不能将.
其用作 glob 模式的一部分,因为它可以是文件路径的合法部分。用于?
匹配单个目录中的任何单个字符或*
任何字符串。此外,“**”模式匹配任何字符串,并跨越目录边界。
推荐阅读
- r - 使用 spread() 获取错误:每行输出必须由唯一的键组合标识
- azure - 如何根据employeeId字段创建动态安全组
- python - 如何将 float64 值转换为等效的日期时间格式?
- php - Laravel Livewire 分页链接不起作用
- ios - 将静态库 (Rust .a) 导入 iOS 中的 Flutter 项目
- javascript - 创建时如何在 html 中显示本地存储中的数据
- r - 无法在 R-studio 中安装 R 包源
- apache-spark - 优化从 s3 存储桶中的分区镶木地板文件中读取
- javascript - 在 React 应用程序中检索 JSON 数据时的不同结果
- google-cloud-platform - 获取 GCP 日志查看器以突出显示自定义标签