AWS Glue Scala字符串转换为Seq [产品]

时间:2018-11-05 21:35:23

标签: scala aws-glue

我有一个scala胶水作业,需要进行以下步骤进行贴图。

val applymapping1 = datasource0.applyMapping(mappings = Seq(("seqnum", "long", "seqnum", "long")), caseSensitive = false, transformationContext = "applymapping1")

但是,我想在“ seqnum”,“ long”,“ seqnum”,“ long”的地方传递一个变量,当我尝试时,我不断收到错误提示

Found String, Required Seq[Product]. 

有人知道如何解决此问题吗?

1 个答案:

答案 0 :(得分:0)

当您将字符串作为mapping而不是Seq传递字符串时发生错误:

val applymapping1 = datasource0.applyMapping(
    mappings = "<string>", 
    caseSensitive = false, 
    transformationContext = "applymapping1"
)

但是,在您提供的代码中,它看起来不错并且对我有用:

val applymapping1 = datasource0.applyMapping(
    mappings = Seq(("seqnum", "long", "seqnum", "long")), 
    caseSensitive = false, 
    transformationContext = "applymapping1"
)

请确保您完全运行此脚本。

更新

可以通过将映射提取到变量中然后在applyMapping中使用它来完成此操作:

val mapping1 = ("seqnum", "long", "seqnum", "long")
val applymapping1 = datasource0.applyMapping(
    mappings = Seq(mapping1), 
    caseSensitive = false, 
    transformationContext = "applymapping1"
)