我将配置单元表作为Dataframe读取,并在新的数据集中检索它。我正在从结构类型中读取特定的值(字符串),我想在将这些值存储在case类中之前格式化它们。
例如:我将结构类型读作“listelements.sneaker.colors”,它返回一个数组,因为有几种颜色。在将它们存储到新数据集中之前,我希望颜色的格式如下:
“红”、“蓝”、“黄”(引号和逗号分隔)
并存储为单个字符串。
concat\u ws用逗号连接数组元素,但我还需要用双引号将它们括起来。
session.read
.table(footWear)
.select(
$"id",
$"footWearCategory".as("category"),
concat_ws(",", $"listelements".getField("sneaker").getField("colors")).as("availableColors"))
.where($"date" === runDate)
.as[FootWearInformation]
case class FootWearInformation(id: String, category: String, availableColors: String)
1条答案
按热度按时间bvuwiixz1#
自定义项: