You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在运行时修改Typesafe Config中Parquet路径的日期参数?

How to Update a List Element in Typesafe Config

Let's break down what went wrong here and fix it step by step.

First, here's your original config for context:

project {
  inputs {
    baseFile {
      paths = ["project/src/test/resources/inputs/parquet1/date=2020-11-01/"]
      type = parquet
      applyConversions = false
    }
  }
}

Your error stems from using incorrect syntax to target the list element in the Config path. Typesafe Config uses [index] notation to access elements in a list, not Scala-style parentheses (0). When you wrote "project.inputs.baseFile.paths"(0), you were accidentally calling the apply method on the string itself, which resulted in an invalid truncated path (hence the error about adjacent periods).

The Correct Approach

To modify the first element in the paths list, use the proper path syntax with [0] to target the index, then create your new Config instance like this:

val newConfig = config.withValue(
  "project.inputs.baseFile.paths[0]",
  ConfigValueFactory.fromAnyRef("project/src/test/resources/inputs/parquet1/date=2020-10-01/")
)

Why This Works

  • The path "project.inputs.baseFile.paths[0]" correctly points to the first element (index 0) of the paths list in your config.
  • Since Config objects are immutable, withValue returns a brand new Config instance with your updated value, leaving the original config untouched.

If you ever need to replace the entire paths list instead of a single element, you can also pass a new list directly using fromIterable:

val updatedPaths = List("project/src/test/resources/inputs/parquet1/date=2020-10-01/")
val newConfig = config.withValue(
  "project.inputs.baseFile.paths",
  ConfigValueFactory.fromIterable(updatedPaths)
)

内容的提问来源于stack exchange,提问作者l3rn1ngData

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:40:27