我想使用 ETL 从 S3 读取数据。由于使用 ETL 作业,我可以设置 DPU 以加快速度。
但是我该怎么做呢?我试过
import sys
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.job import Job
## @params: [JOB_NAME]
args = getResolvedOptions(sys.argv, ['JOB_NAME'])
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
job = Job(glueContext)
job.init(args['JOB_NAME'], args)
inputGDF = glueContext.create_dynamic_frame_from_options(connection_type = "s3", connection_options = {"paths": ["s3://pinfare-glue/testing-csv"]}, format = "csv")
outputGDF = glueContext.write_dynamic_frame.from_options(frame = inputGDF, connection_type = "s3", connection_options = {"path": "s3://pinfare-glue/testing-output"}, format = "parquet")
但是好像什么都没写。我的文件夹看起来像:
什么不正确?我的输出 S3 只有一个文件,如:
testing_output_$folder$
最佳答案
我相信这里的问题是您在 testing-csv 文件夹中有子文件夹,因为您 没有指定递归 确实,Glue 无法在 2018-09-26 子文件夹(或实际上任何其他子文件夹)中找到文件。
您需要添加递归选项如下
inputGDF = glueContext.create_dynamic_frame_from_options(connection_type = "s3", connection_options = {"paths": ["s3://pinfare-glue/testing-csv"], "recurse"=True}, format = "csv")
此外,关于您在评论中关于爬虫的问题,它们有助于推断您的数据文件的架构。因此,在您的情况下,这里什么也不做,因为您是直接从 s3 创建 dynamicFrame 的。
关于amazon-web-services - AWS 胶水 : ETL to read S3 CSV files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53104036/