gpt4 book ai didi

csv - 加载 tempView 时,空字符串显示为 null

转载 作者:行者123 更新时间:2023-11-28 21:18:58 25 4
gpt4 key购买 nike

我正在 spark 中运行一些测试。为此,我正在加载一个 csv 文件来比较我的结果。

我的标准具

;;NULL;2017-03-21
;;NULL;2017-03-21
;;NULL;2017-03-21

这是我加载文件的方式

spark.read.schema(Table.schema)
.format("com.databricks.spark.csv")
.option("delimiter", ";")
.option("nullValue", "NULL")
.load(pathTable)
.createTempView(param.TABLE)

这是我的模式

  val fields = Seq(
StructField("balance", StringType, nullable = true),
StructField("status", StringType, nullable = true),
StructField("status_date", DateType, nullable = true),
StructField("time_key", StringType, nullable = true)
)
val schema = StructType(fields)

由于某些原因,balancestatus 在本应为空字符串时被加载为 NULL。

+-------+------+-----------+----------+
|balance|status|status_date| time_key|
+-------+------+-----------+----------+
| null| null| null|2017-03-21|
| null| null| null|2017-03-21|
| null| null| null|2017-03-21|
+-------+------+-----------+----------+

为什么会这样,我怎样才能将它显示为空字符串?

最佳答案

似乎为此提出了一个问题,并在 2.4 中解决了

Spark 17916

关于csv - 加载 tempView 时,空字符串显示为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54480117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com