Please do not mark this question as duplicate. I have checked the below question and it gives solution for python or scala. And for java method is different. How to replace null values with a specific value in Dataframe using spark in Java?
I have a Dataset Dataset<Row> ds
which I created from reading a parquet file. So, all column values are string. Some of the values are null. I am using .na().fill("") for replacing null values with empty string
Dataset<Row> ds1 = ds.na().fill("");
But it is not removing null values. I am unable to understand what can be the reason.
|-- stopPrice: double (nullable = true) |-- tradingCurrency: string (nullable = true)
spark.read.schema(...).csv("xxx.csv")
. If the dataframe is already created however, you need to cast the corresponding columns. In your case, you could probably read the parquet file, extract the schema withdf.schema()
and use it when parsing the CSV. – Oli