AWS胶 - iLlegalargumentException:路径的重复值
我有一个混乱的数据源,其中某些字段值可以带有两个不同的名称,但应映射到输出上的一个符合的字段名称。
例如,数据源包含update_date
或modified_date
,并且两个都应映射到timestamp
。
两个字段名称永远不会同时存在于同一行数据上。
胶脚本看起来像这样。有些线已被编辑为清晰:
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
args = getResolvedOptions(sys.argv, ["JOB_NAME"])
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
job = Job(glueContext)
job.init(args["JOB_NAME"], args)
# Script generated for node Data Catalog table
DataCatalogtable_node1 = glueContext.create_dynamic_frame.from_catalog(
database="mydb",
table_name="crawl_rawdata",
transformation_ctx="DataCatalogtable_node1",
)
# Script generated for node ApplyMapping
ApplyMapping_node2 = ApplyMapping.apply(
frame=DataCatalogtable_node1,
mappings=[
...
("update_date", "string", "timestamp", "string"),
...
("modified_date", "string", "timestamp", "string"),
...
],
transformation_ctx="ApplyMapping_node2",
)
# Script generated for node S3 bucket
S3bucket_node3 = glueContext.write_dynamic_frame.from_options(
frame=ApplyMapping_node2,
connection_type="s3",
format="orc",
connection_options={
"path": "s3://mybucket/data-lake/glue/",
"compression": "snappy",
"partitionKeys": [ ... ],
},
transformation_ctx="S3bucket_node3",
)
job.commit()
如何使其运行?
I have a messy data source where some field values can come in with two different names but should map to one conformed field name on the output.
e.g. data source contains update_date
or modified_date
and both should map to timestamp
.
Both field names are never present simultaneously on the same row of data.
The glue script looks like this. Some lines have been redacted for clarity:
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
args = getResolvedOptions(sys.argv, ["JOB_NAME"])
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
job = Job(glueContext)
job.init(args["JOB_NAME"], args)
# Script generated for node Data Catalog table
DataCatalogtable_node1 = glueContext.create_dynamic_frame.from_catalog(
database="mydb",
table_name="crawl_rawdata",
transformation_ctx="DataCatalogtable_node1",
)
# Script generated for node ApplyMapping
ApplyMapping_node2 = ApplyMapping.apply(
frame=DataCatalogtable_node1,
mappings=[
...
("update_date", "string", "timestamp", "string"),
...
("modified_date", "string", "timestamp", "string"),
...
],
transformation_ctx="ApplyMapping_node2",
)
# Script generated for node S3 bucket
S3bucket_node3 = glueContext.write_dynamic_frame.from_options(
frame=ApplyMapping_node2,
connection_type="s3",
format="orc",
connection_options={
"path": "s3://mybucket/data-lake/glue/",
"compression": "snappy",
"partitionKeys": [ ... ],
},
transformation_ctx="S3bucket_node3",
)
job.commit()
How to make it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否提供有关引起此错误的行的信息?您可以在AWS日志中找到它。我也遇到了同样的错误。就我而言,解决方案只是用此字符串列表替换一个字符串列表。让我向您展示一个代码:
Could you provide the information about the line that is provoking this error? You can find it in AWS logs. I also experienced the same error. In my case, the solution was just replacing a variable with a list of strings with this list of strings. Let me show you a piece of code: